Using In-chat authentication

In-chat authentication lets your agent prompt users to connect accounts during chat. When a tool requires authentication, the agent returns a Connect Link URL. The user authenticates, confirms in chat, and the agent retries.

How it works

  1. Agent searches for tools via the COMPOSIO_SEARCH_TOOLS meta-tool
  2. The COMPOSIO_MANAGE_CONNECTIONS meta-tool checks connection status, returns Connect Link URL if needed
  3. User authenticates, confirms in chat, agent continues

Configuration

By just creating a session with default configs, you are enabling in-chat auth. The manage_connections parameter defaults to True, which includes the COMPOSIO_MANAGE_CONNECTIONS meta-tool automatically:

1session = composio.create(user_id="user_123")

Custom callback URL

Redirect users back to your chat page after they complete authentication:

1session = composio.create(
2 user_id="user_123",
3 manage_connections={
4 "callback_url": "https://yourapp.com/chat"
5 },
6)

Examples

1SnippetCode Error: Unexpected error: fullPath is not defined
2
3Props: {
4 "src": "fern/snippets/tool-router/python/quickstart-openai.py",
5 "title": "Python"
6}
7
8Fix the issue above and rebuild.

What this looks like when you run the code:

Assistant: What would you like me to do today?
> Star the composio repo on GitHub
Assistant: I need you to connect your GitHub account first.
Please click here to authorize: https://connect.composio.dev/link/ln_abc123
> Done
Assistant: Done! I've starred ComposioHQ/composio.

To manage authentication outside of chat, see Manually authenticating users.