Composio powers 1000+ toolkits, tool search, context management, authentication, and a sandboxed workbench to help you build AI agents that turn intent into action.
docs: remove Full Stack Chat App cookbook, redirect to Build a Chat App
The vercel-chat cookbook pointed to an external repo with outdated patterns. Build a Chat App covers the same use case with the session-based approach. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Sushmitha Mallesh committed
Feb 25, 2026 at 19:01 UTC
2838ba762999e723081c075d6d32ba4b5854bb33
9 files changed
+5
-314
docs/content/cookbooks/index.mdx
-6
@@ -25,12 +25,6 @@ Browse open-source templates or follow step-by-step guides below.
25
<Card title="Supabase SQL Agent" href="/cookbooks/supabase-sql-agent" description="Execute SQL queries using natural language" />
26
</Cards>
27
28
-## Full Stack Applications
29
-
30
-<Cards>
31
- <Card title="Full Stack Chat App" href="/cookbooks/vercel-chat" description="Build a chat interface with user connections" />
32
-</Cards>
33
-
28
## Behind the Curtain
29
30
<Cards>
docs/content/cookbooks/meta.json
-2
@@ -11,8 +11,6 @@
11
"gmail-labeler",
12
"slack-summariser",
13
"supabase-sql-agent",
14
- "---Full Stack Applications---",
15
- "vercel-chat",
14
"---Behind the Curtain---",
15
"tool-generator"
16
]
docs/content/cookbooks/vercel-chat.mdx
deleted
-306
@@ -1,306 +0,0 @@
1
----
2
-title: Full Stack Chat App
3
-description: Build a chat interface where users can connect and use their own apps
4
----
5
-
6
-In this example, you will learn how to build a chatbot that:
7
-
8
-- Lets users connect their various apps to the chatbot using the Composio SDK.
9
-- Uses the Vercel provider in the Composio SDK to handle and execute tool calls from the LLM.
10
-
11
-This page gives a high-level overview of the Composio SDK and how it is used in the
12
-GitHub repository: [composiohq/chat](https://github.com/composiohq/chat). You can
13
-find the demo live [here](https://chat.composio.dev/).
14
-
15
-## Prerequisites
16
-
17
-Ensure you've followed the README.md in the [composiohq/chat](https://github.com/composiohq/chat)
18
-repository to set up the project locally.
19
-
20
-## Creating auth configs
21
-
22
-For all the apps you want to connect to the chatbot, you need to create their
23
-respective auth configs. Learn how to create auth configs [here](/docs/tools-direct/authenticating-tools#creating-an-auth-config).
24
-Once done, your auth configs will be available in the [Composio dashboard](https://platform.composio.dev/integrations).
25
-
26
-
27
- <img src="/assets/images/examples/auth-configs.png" alt="Auth configs" />
28
-
29
-
30
-### Save auth config IDs to environment variables
31
-
32
-For this project, the auth config IDs should be saved to the environment variables
33
-with the `NEXT_PUBLIC_` prefix.
34
-
35
-```bash .env.local
36
-NEXT_PUBLIC_GMAIL_AUTH_CONFIG_ID=ac_1234567890
37
-NEXT_PUBLIC_GITHUB_AUTH_CONFIG_ID=ac_1234567890
38
-```
39
-
40
-## Create a Composio client instance
41
-
42
-We create a Composio client instance for server-side operations like API routes,
43
-server components, etc.
44
-
45
-```typescript lib/service/composio.ts
46
-import { Composio } from '@composio/core';
47
-import { VercelProvider } from '@composio/vercel';
48
-
49
-const composio = new Composio({
50
- apiKey: process.env.COMPOSIO_API_KEY,
51
- provider: new VercelProvider(),
52
-});
53
-
54
-export default composio;
55
-```
56
-
57
-## Creating an API for fetching toolkits
58
-
59
-The Composio SDK is meant to be used only in server-side code. For client-side
60
-functionality, we create API endpoints in the `/app/api/` directory. In order to
61
-list the toolkits and their connection status, we create a Next.js API route to
62
-fetch the toolkits using Composio SDK.
63
-
64
-
65
- <img src="/assets/images/examples/toolkits.png" alt="Toolkits list with connection status" />
66
-
67
-
68
-### 1. Listing connected accounts
69
-
70
-First, we fetch all connected accounts for a user and create a mapping of toolkit
71
-slugs to their connection IDs:
72
-
73
-```typescript app/api/composio/toolkits.ts
74
-// @noErrors
75
-export async function GET() {
76
- // ... auth logic ...
77
-
78
- // List connected accounts to get connection IDs for each toolkit
79
- const connectedAccounts = await composio.connectedAccounts.list({
80
- userIds: [session.user.id],
81
- });
82
-
83
- const connectedToolkitMap = new Map();
84
- connectedAccounts.items.forEach(account => {
85
- connectedToolkitMap.set(account.toolkit.slug.toUpperCase(), account.id);
86
- });
87
-
88
- // ... continue with toolkit fetching ...
89
-}
90
-```
91
-
92
-### 2. Fetching toolkit data and building response
93
-
94
-Next, we fetch toolkit information for each supported toolkit and combine it with the connection status:
95
-
96
-```typescript app/api/composio/toolkits.ts
97
-// @noErrors
98
-export async function GET() {
99
- // ... auth logic ...
100
- // ... connected accounts mapping ...
101
-
102
- const SUPPORTED_TOOLKITS = ['GMAIL', 'GOOGLECALENDAR', 'GITHUB', 'NOTION'];
103
-
104
- // Fetch toolkit data from slugs
105
- const toolkitPromises = SUPPORTED_TOOLKITS.map(async slug => {
106
- const toolkit = await composio.toolkits.get(slug);
107
- const connectionId = connectedToolkitMap.get(slug.toUpperCase());
108
-
109
- return {
110
- name: toolkit.name,
111
- slug: toolkit.slug,
112
- description: toolkit.meta?.description,
113
- logo: toolkit.meta?.logo,
114
- categories: toolkit.meta?.categories,
115
- isConnected: !!connectionId,
116
- connectionId: connectionId || undefined,
117
- };
118
- });
119
-
120
- const toolkits = await Promise.all(toolkitPromises);
121
- return NextResponse.json({ toolkits });
122
-}
123
-```
124
-
125
-## Managing connections
126
-
127
-Users need to connect and disconnect their accounts from the chatbot to enable tool usage. When users click "Connect" on a toolkit, we initiate an OAuth flow, and when they click "Disconnect", we remove their connection.
128
-
129
-### 1. Initiating a connection
130
-
131
-When a user wants to connect their account, we create a connection request that redirects them to the OAuth provider:
132
-
133
-
134
- <img src="/assets/images/examples/create-connection.png" alt="Create connection dialog" />
135
-
136
-
137
-```typescript app/api/connections/initiate/route.ts
138
-// @noErrors
139
-export async function POST(request: Request) {
140
- // ... auth and validation ...
141
-
142
- const { authConfigId } = requestBody;
143
-
144
- // Initiate connection with Composio
145
- const connectionRequest = await composio.connectedAccounts.initiate(
146
- session.user.id,
147
- authConfigId
148
- );
149
-
150
- return NextResponse.json({
151
- redirectUrl: connectionRequest.redirectUrl,
152
- connectionId: connectionRequest.id,
153
- });
154
-}
155
-```
156
-
157
-### 2. Checking connection status
158
-
159
-After initiating a connection, we need to wait for the OAuth flow to complete. We check the connection status to know when it's ready to use:
160
-
161
-
162
- <img src="/assets/images/examples/connection-status.png" alt="Connection status indicator" />
163
-
164
-
165
-```typescript app/api/connections/status/route.ts
166
-// @noErrors
167
-export async function GET(request: Request) {
168
- // ... auth and validation ...
169
-
170
- const connectionId = searchParams.get('connectionId');
171
-
172
- // Wait for connection to complete
173
- const connection = await composio.connectedAccounts.waitForConnection(connectionId);
174
-
175
- return NextResponse.json({
176
- id: connection.id,
177
- status: connection.status,
178
- authConfig: connection.authConfig,
179
- data: connection.data,
180
- });
181
-}
182
-```
183
-
184
-### 3. Deleting a connection
185
-
186
-When a user wants to disconnect their account, we remove the connection using the connection ID:
187
-
188
-```typescript app/api/connections/delete/route.ts
189
-// @noErrors
190
-export async function DELETE(request: Request) {
191
- // ... auth and validation ...
192
-
193
- const connectionId = searchParams.get('connectionId');
194
-
195
- // Delete the connection
196
- await composio.connectedAccounts.delete(connectionId);
197
-
198
- return NextResponse.json({
199
- success: true,
200
- message: 'Connection deleted successfully',
201
- });
202
-}
203
-```
204
-
205
-## Working with tools
206
-
207
-Once users have connected their accounts, we need to track which toolkits are enabled and fetch the corresponding tools for the LLM.
208
-
209
-### 1. Tracking enabled toolkits
210
-
211
-We keep track of which toolkits the user has enabled in the chat interface:
212
-
213
-```typescript components/chat.tsx
214
-// @noErrors
215
-const { ... } = useChat({
216
- // ... other config ...
217
- experimental_prepareRequestBody: (body) => {
218
- // Get current toolbar state
219
- const currentToolbarState = toolbarStateRef.current;
220
- const enabledToolkits = Array.from(
221
- currentToolbarState.enabledToolkitsWithStatus.entries(),
222
- ).map(([slug, isConnected]) => ({ slug, isConnected }));
223
-
224
- return {
225
- // ... other fields ...
226
- enabledToolkits,
227
- };
228
- },
229
- // ... other handlers ...
230
- });
231
-```
232
-
233
-### 2. Fetching tools for enabled toolkits
234
-
235
-We fetch Composio tools based on the enabled toolkit slugs:
236
-
237
-```typescript lib/ai/tools/composio.ts
238
-// @noErrors
239
-export async function getComposioTools(userId: string, toolkitSlugs: string[]) {
240
- // ... validation ...
241
-
242
- const tools = await composio.tools.get(userId, {
243
- toolkits: toolkitSlugs,
244
- });
245
- return tools || {};
246
-}
247
-```
248
-
249
-```typescript app/api/chat.ts
250
-// @noErrors
251
-export async function POST(request: Request) {
252
- // ... auth and parsing ...
253
-
254
- const toolkitSlugs = enabledToolkits?.map(t => t.slug) || [];
255
-
256
- const composioTools = await getComposioTools(session.user.id, toolkitSlugs);
257
-
258
- const result = streamText({
259
- // ... model config ...
260
- tools: {
261
- ...composioTools,
262
- },
263
- });
264
-}
265
-```
266
-
267
-## Bonus: Creating custom component to show tool calls
268
-
269
-By default, tool calls appear as raw JSON in the chat interface. To create a better user experience, we can build custom components that display tool calls with proper formatting and loading states.
270
-
271
-
272
- <img src="/assets/images/examples/custom-tool-component.png" alt="Custom tool call component" />
273
-
274
-
275
-You can find the `ToolCall` component at `components/tool-call.tsx`. Here's how to integrate it into your message rendering:
276
-
277
-```typescript components/messages.tsx
278
-// @noErrors
279
-if (type === 'tool-invocation') {
280
- const { toolInvocation } = part;
281
- const { toolName, toolCallId, state, args, result } = toolInvocation;
282
-
283
- if (state === 'call') {
284
- return (
285
- <ToolCall
286
- key={toolCallId}
287
- toolName={toolName}
288
- args={args}
289
- isLoading={true}
290
- />
291
- );
292
- }
293
-
294
- if (state === 'result') {
295
- return (
296
- <ToolCall
297
- key={toolCallId}
298
- toolName={toolName}
299
- args={args}
300
- result={result}
301
- isLoading={false}
302
- />
303
- );
304
- }
305
-}
306
-```
docs/next.config.mjs
+5
@@ -37,6 +37,11 @@ const config = {
37
destination: '/cookbooks',
38
permanent: true,
39
},
40
+ {
41
+ source: '/cookbooks/vercel-chat',
42
+ destination: '/cookbooks/chat-app',
43
+ permanent: true,
44
+ },
45
// Specific /examples/ subroutes before the catch-all
46
{
47
source: '/examples/combined/:path*',
docs/public/assets/images/examples/auth-configs.png
Binary files a/docs/public/assets/images/examples/auth-configs.png and /dev/null differ
docs/public/assets/images/examples/connection-status.png
Binary files a/docs/public/assets/images/examples/connection-status.png and /dev/null differ
docs/public/assets/images/examples/create-connection.png
Binary files a/docs/public/assets/images/examples/create-connection.png and /dev/null differ
docs/public/assets/images/examples/custom-tool-component.png
Binary files a/docs/public/assets/images/examples/custom-tool-component.png and /dev/null differ
docs/public/assets/images/examples/toolkits.png
Binary files a/docs/public/assets/images/examples/toolkits.png and /dev/null differ