@devries-cameron20 / composio Mirror · read-only / commits / 6a668e1f0
Fork 0

Composio powers 1000+ toolkits, tool search, context management, authentication, and a sandboxed workbench to help you build AI agents that turn intent into action.

Mirrored from https://github.com/Camo67/composio.git

Synced Nov 22, 07:00 UTC

docs: add chat app tutorial and revamp welcome page

- Add "Build a Chat App" cookbook with external code files via <include> - Restructure welcome page: hero cards, Get Started, AI tools banner, Explore - Create AIToolsBanner component with grid pattern, skills command, and context file links - Add markdown conversion for AIToolsBanner in LLM endpoint - Add chat-app to cookbooks navigation after templates Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

Sushmitha Mallesh committed Feb 23, 2026 at 19:02 UTC 6a668e1f098f4acdad8290f95c2e8e1ac8978229
10 files changed +514 -25
docs/components/ai-tools-banner.tsx new
+105
@@ -0,0 +1,105 @@
1 +'use client';
2 +
3 +import { useState } from 'react';
4 +import Link from 'next/link';
5 +import { Bot, FileText, Copy, Check, ExternalLink } from 'lucide-react';
6 +
7 +function CopyButton({ text }: { text: string }) {
8 + const [copied, setCopied] = useState(false);
9 +
10 + return (
11 + <button
12 + onClick={() => {
13 + navigator.clipboard.writeText(text);
14 + setCopied(true);
15 + setTimeout(() => setCopied(false), 2000);
16 + }}
17 + className="shrink-0 rounded-md p-1 text-fd-muted-foreground/60 hover:text-fd-foreground transition-colors"
18 + aria-label="Copy to clipboard"
19 + >
20 + {copied ? (
21 + <Check className="h-3.5 w-3.5 text-green-500" />
22 + ) : (
23 + <Copy className="h-3.5 w-3.5" />
24 + )}
25 + </button>
26 + );
27 +}
28 +
29 +export function AIToolsBanner() {
30 + const skillsCommand = 'npx skills add composiohq/skills';
31 +
32 + return (
33 + <div className="not-prose relative mt-6 overflow-hidden rounded-xl border border-fd-border bg-gradient-to-br from-fd-card via-fd-card to-fd-muted/50 dark:from-fd-muted/20 dark:via-fd-card dark:to-fd-muted/40">
34 + {/* Subtle grid pattern */}
35 + <div
36 + className="pointer-events-none absolute inset-0 opacity-[0.03] dark:opacity-[0.04]"
37 + style={{
38 + backgroundImage:
39 + 'linear-gradient(var(--color-fd-foreground) 1px, transparent 1px), linear-gradient(90deg, var(--color-fd-foreground) 1px, transparent 1px)',
40 + backgroundSize: '24px 24px',
41 + }}
42 + />
43 + <div className="relative p-5">
44 + {/* Header */}
45 + <div className="mb-4 flex items-center gap-2.5">
46 + <div className="flex h-7 w-7 items-center justify-center rounded-lg bg-fd-muted dark:bg-fd-muted/60">
47 + <Bot className="h-4 w-4 text-fd-muted-foreground" />
48 + </div>
49 + <span className="text-sm font-semibold text-fd-foreground tracking-tight">
50 + For AI tools
51 + </span>
52 + </div>
53 +
54 + {/* Skills command */}
55 + <div className="mb-3 flex items-center gap-2 rounded-lg border border-fd-border bg-fd-background dark:bg-fd-background/50 px-3.5 py-2.5 font-mono text-[13px] text-fd-foreground">
56 + <span className="select-none text-fd-muted-foreground">$</span>
57 + <span className="flex-1 select-all">{skillsCommand}</span>
58 + <CopyButton text={skillsCommand} />
59 + </div>
60 +
61 + {/* Skills links */}
62 + <div className="mb-4 flex items-center gap-3 text-xs">
63 + <Link
64 + href="https://skills.sh/composiohq/skills/composio"
65 + target="_blank"
66 + rel="noopener noreferrer"
67 + className="inline-flex items-center gap-1 text-fd-muted-foreground hover:text-[var(--composio-orange)] transition-colors"
68 + >
69 + Skills.sh
70 + <ExternalLink className="h-3 w-3" />
71 + </Link>
72 + <Link
73 + href="https://github.com/composiohq/skills"
74 + target="_blank"
75 + rel="noopener noreferrer"
76 + className="inline-flex items-center gap-1 text-fd-muted-foreground hover:text-[var(--composio-orange)] transition-colors"
77 + >
78 + GitHub
79 + <ExternalLink className="h-3 w-3" />
80 + </Link>
81 + </div>
82 +
83 + {/* Context files */}
84 + <div className="flex gap-2">
85 + <Link
86 + href="/llms.txt"
87 + className="group flex flex-1 items-center gap-2.5 rounded-lg border border-fd-border/80 bg-fd-card dark:bg-fd-background/30 px-3 py-2 transition-all hover:border-[var(--composio-orange)]/40"
88 + >
89 + <FileText className="h-3.5 w-3.5 shrink-0 text-fd-muted-foreground group-hover:text-[var(--composio-orange)] transition-colors" />
90 + <span className="text-sm font-medium text-fd-foreground">llms.txt</span>
91 + <span className="text-[11px] text-fd-muted-foreground">Index</span>
92 + </Link>
93 + <Link
94 + href="/llms-full.txt"
95 + className="group flex flex-1 items-center gap-2.5 rounded-lg border border-fd-border/80 bg-fd-card dark:bg-fd-background/30 px-3 py-2 transition-all hover:border-[var(--composio-orange)]/40"
96 + >
97 + <FileText className="h-3.5 w-3.5 shrink-0 text-fd-muted-foreground group-hover:text-[var(--composio-orange)] transition-colors" />
98 + <span className="text-sm font-medium text-fd-foreground">llms-full.txt</span>
99 + <span className="text-[11px] text-fd-muted-foreground">Complete</span>
100 + </Link>
101 + </div>
102 + </div>
103 + </div>
104 + );
105 +}
docs/content/cookbooks/chat-app.mdx new
+125
@@ -0,0 +1,125 @@
1 +---
2 +title: Build a Chat App
3 +description: Build an AI chat app with tool access to 1000+ apps in about 30 lines of code
4 +---
5 +
6 +Give your AI agent access to Gmail, GitHub, Slack, Notion, and 1000+ other apps. This tutorial builds a Next.js chat app that handles tool discovery, user authentication, and action execution in about **30 lines of code**.
7 +
8 +## What you'll build
9 +
10 +- A chat app where your agent can find and use tools across 1000+ apps
11 +- In-chat OAuth authentication so users can connect apps directly in the conversation
12 +- A tool call display that shows what the agent is doing in real time
13 +
14 +## Prerequisites
15 +
16 +- Node.js 18+
17 +- [Composio API key](https://platform.composio.dev/settings)
18 +- [OpenAI API key](https://platform.openai.com/api-keys)
19 +
20 +**Stack:** Next.js, Vercel AI SDK, OpenAI, Composio
21 +
22 +## Create the project
23 +
24 +Create a new Next.js app and install the dependencies:
25 +
26 +```bash
27 +pnpm create next-app composio-chat --yes
28 +cd composio-chat
29 +pnpm install @composio/core @composio/vercel @ai-sdk/openai ai @ai-sdk/react
30 +```
31 +
32 +<Callout type="info">
33 +Get your `COMPOSIO_API_KEY` from [Settings](https://platform.composio.dev/settings) and `OPENAI_API_KEY` from [OpenAI](https://platform.openai.com/api-keys).
34 +</Callout>
35 +
36 +Add your API keys to a `.env.local` file in the project root:
37 +
38 +```bash title=".env.local"
39 +COMPOSIO_API_KEY=your_composio_api_key
40 +OPENAI_API_KEY=your_openai_api_key
41 +```
42 +
43 +Start the dev server:
44 +
45 +```bash
46 +pnpm dev
47 +```
48 +
49 +## Build the backend
50 +
51 +A **session** scopes tools and credentials to a specific user. Create `app/api/chat/route.ts`:
52 +
53 +<include meta='title="app/api/chat/route.ts"'>../../examples/chat-app/route.ts</include>
54 +
55 +That's the entire backend. `composio.create("user_123")` creates a session that lets the agent search for tools, authenticate users, and execute actions. This ID scopes all connections and credentials to this user. In production, use the user ID from your auth system.
56 +
57 +## Build the chat UI
58 +
59 +Replace `app/page.tsx`:
60 +
61 +<include meta='title="app/page.tsx"'>../../examples/chat-app/page.tsx</include>
62 +
63 +Go to [localhost:3000](http://localhost:3000). You should see the chat interface.
64 +
65 +## Try a tool call
66 +
67 +Send this message:
68 +
69 +```
70 +Star the composio repo on GitHub
71 +```
72 +
73 +Here's what happens:
74 +
75 +1. The agent searches for relevant tools, finds `GITHUB_STAR_REPO`, and checks your connection status.
76 +2. You haven't connected GitHub yet, so the agent generates an auth link and shows it to you.
77 +3. Click the link, authorize with GitHub, and tell the agent you're done.
78 +4. The agent executes `GITHUB_STAR_REPO` with your credentials.
79 +
80 +Discovery, authentication, and execution all happened automatically. You didn't write any tool-specific code.
81 +
82 +<Callout>
83 +This in-chat authentication flow works out of the box. For production apps, you can [authenticate users ahead of time](/docs/authenticating-users/manually-authenticating) during onboarding.
84 +</Callout>
85 +
86 +## Show tool calls in the UI
87 +
88 +Tool calls happen invisibly by default. Add a component that shows the tool name and status so you can see what the agent is doing.
89 +
90 +Create `components/ToolCallDisplay.tsx`:
91 +
92 +<include meta='title="components/ToolCallDisplay.tsx"'>../../examples/chat-app/ToolCallDisplay.tsx</include>
93 +
94 +Update `app/page.tsx` to render tool calls:
95 +
96 +<include meta='title="app/page.tsx"'>../../examples/chat-app/page-with-tools.tsx</include>
97 +
98 +Tool calls now show inline with a spinner while running and a checkmark when complete. Click to expand and see the raw output.
99 +
100 +## How it works
101 +
102 +The session handles tool discovery and execution at runtime. Instead of loading thousands of tool definitions into your agent's context, the agent searches for what it needs, authenticates the user if necessary, and executes the action. Token refresh and credential management are handled automatically.
103 +
104 +Try a few more requests:
105 +
106 +- "Summarize my emails from today"
107 +- "What's on my calendar this week?"
108 +- "Create a GitHub issue in my repo"
109 +
110 +## Take it further
111 +
112 +<Cards>
113 + <Card title="Configuring sessions" href="/docs/configuring-sessions">
114 + Lock down which toolkits your agent can access
115 + </Card>
116 + <Card title="Manual authentication" href="/docs/authenticating-users/manually-authenticating">
117 + Move authentication to your onboarding flow instead of in-chat
118 + </Card>
119 + <Card title="Users and sessions" href="/docs/users-and-sessions">
120 + Scope sessions to real users for multi-tenant apps
121 + </Card>
122 + <Card title="How Composio works" href="/docs/how-composio-works">
123 + Understand sessions, tool discovery, and execution under the hood
124 + </Card>
125 +</Cards>
docs/content/cookbooks/meta.json
+1
@@ -4,6 +4,7 @@
4 "pages": [
5 "---Getting Started---",
6 "templates",
7 + "chat-app",
8 "fast-api",
9 "hono",
10 "---Productivity & Automation---",
docs/content/docs/index.mdx
+28 -25
@@ -8,44 +8,47 @@ Composio powers 1000+ toolkits, tool search, context management, authentication,
8
9 <Cards>
10 <Card
11 - icon={<Rocket />}
12 - title="Quickstart"
13 - href="/docs/quickstart"
14 - description="Build your first agent in 5 minutes"
11 + title="Tutorial: Build a chat app"
12 + href="/cookbooks/chat-app"
13 + description="Build a Next.js chat app where your agent can discover and use tools across 1000+ apps."
14 />
15 <Card
17 - icon={<Play />}
18 - title="Playground"
19 - href="https://platform.composio.dev/auth?next_page=%2Ftool-router"
20 - description="Try Composio in your browser"
16 + title="How Composio works"
17 + href="/docs/how-composio-works"
18 + description="Learn about sessions, meta tools, authentication, and the architecture behind Composio."
19 />
20 +</Cards>
21 +
22 +## Get Started
23 +
24 +<Cards className="grid-cols-1">
25 <Card
26 icon={<Rocket />}
24 - title="How it works"
25 - href="/docs/how-composio-works"
26 - description="Sessions, meta tools, authentication, and execution"
27 + title="Quickstart"
28 + href="/docs/quickstart"
29 + description="Install the SDK, connect an app, and run your first tool call in 5 minutes."
30 />
31 +</Cards>
32 +
33 +<AIToolsBanner />
34 +
35 +## Explore
36 +
37 +<Cards>
38 <Card
39 icon={<Wrench />}
40 title="Toolkits"
41 href="/toolkits"
32 - description="Browse 1000+ toolkits"
42 + description="Browse 1000+ toolkits across GitHub, Gmail, Slack, Notion, and more."
43 + />
44 + <Card
45 + icon={<Play />}
46 + title="Playground"
47 + href="https://platform.composio.dev/auth?next_page=%2Ftool-router"
48 + description="Try Composio in your browser without writing any code."
49 />
50 </Cards>
51
36 -## For AI tools
37 -
38 -- [composio.dev/llms.txt](/llms.txt) - Documentation index with links
39 -- [composio.dev/llms-full.txt](/llms-full.txt) - Complete documentation in one file
40 -
41 -### Skills
42 -
43 -```bash
44 -npx skills add composiohq/skills
45 -```
46 -
47 -[View on Skills.sh](https://skills.sh/composiohq/skills/composio) · [GitHub](https://github.com/composiohq/skills)
48 -
52 ## Providers
53
54 Composio works with any AI framework. Pick your preferred SDK:
docs/examples/chat-app/ToolCallDisplay.tsx new
+46
@@ -0,0 +1,46 @@
1 +"use client";
2 +
3 +import { useState } from "react";
4 +
5 +export function ToolCallDisplay({
6 + toolName,
7 + input,
8 + output,
9 + isLoading,
10 +}: {
11 + toolName: string;
12 + input: unknown;
13 + output?: unknown;
14 + isLoading: boolean;
15 +}) {
16 + const [expanded, setExpanded] = useState(false);
17 +
18 + return (
19 + <div className="my-1">
20 + <button
21 + onClick={() => setExpanded(!expanded)}
22 + className={`inline-flex items-center gap-2 rounded-md border px-3 py-1.5 text-xs transition-colors ${
23 + isLoading
24 + ? "border-gray-200 bg-gray-50 text-gray-500 dark:border-gray-700 dark:bg-gray-900 dark:text-gray-400"
25 + : "border-gray-200 bg-gray-50 text-gray-700 hover:bg-gray-100 dark:border-gray-700 dark:bg-gray-900 dark:text-gray-300 dark:hover:bg-gray-800"
26 + }`}
27 + >
28 + {isLoading ? (
29 + <span className="inline-block h-3 w-3 animate-spin rounded-full border border-gray-300 border-t-gray-600 dark:border-gray-600 dark:border-t-gray-300" />
30 + ) : (
31 + <span className="text-green-600 dark:text-green-400">✓</span>
32 + )}
33 + <code className="font-mono">{toolName}</code>
34 + {!isLoading && <span className="text-gray-400">{expanded ? "▴" : "▾"}</span>}
35 + </button>
36 +
37 + {expanded && !isLoading && (
38 + <pre className="mt-1 ml-1 max-h-40 max-w-full overflow-auto whitespace-pre-wrap break-words rounded-md border border-gray-200 bg-gray-50 p-2 text-xs text-gray-600 dark:border-gray-700 dark:bg-gray-900 dark:text-gray-400">
39 + {output != null
40 + ? String(JSON.stringify(output, null, 2))
41 + : String(JSON.stringify(input, null, 2))}
42 + </pre>
43 + )}
44 + </div>
45 + );
46 +}
docs/examples/chat-app/page-with-tools.tsx new
+91
@@ -0,0 +1,91 @@
1 +"use client";
2 +
3 +import { useState } from "react";
4 +import { useChat } from "@ai-sdk/react";
5 +import { DefaultChatTransport, getToolName, isToolUIPart } from "ai";
6 +import { ToolCallDisplay } from "../components/ToolCallDisplay";
7 +
8 +export default function Chat() {
9 + const [input, setInput] = useState("");
10 + const { messages, sendMessage, status } = useChat({
11 + transport: new DefaultChatTransport({ api: "/api/chat" }),
12 + });
13 +
14 + const isLoading = status === "streaming" || status === "submitted";
15 +
16 + return (
17 + <main className="max-w-2xl mx-auto p-6">
18 + <h1 className="text-2xl font-bold mb-6">Composio Chat</h1>
19 +
20 + <div className="space-y-4 mb-6 min-h-[200px]">
21 + {messages.length === 0 && (
22 + <p className="text-gray-400 text-center py-12">
23 + Try: &quot;Star the composio repo on GitHub&quot;
24 + </p>
25 + )}
26 + {messages.map((m) => (
27 + <div key={m.id} className="flex gap-2">
28 + <span className="font-semibold shrink-0">
29 + {m.role === "user" ? "You:" : "Agent:"}
30 + </span>
31 + <div className="flex-1 whitespace-pre-wrap">
32 + {m.parts.map((part, i) => {
33 + if (part.type === "text") {
34 + return (
35 + <span key={i}>
36 + {String(part.text)
37 + .split(/(https?:\/\/[^\s)]+)/g)
38 + .map((segment, j) =>
39 + segment.match(/^https?:\/\//) ? (
40 + <a key={j} href={segment} target="_blank" rel="noopener noreferrer" className="text-blue-600 underline">{segment}</a>
41 + ) : (
42 + segment
43 + )
44 + )}
45 + </span>
46 + );
47 + }
48 + if (isToolUIPart(part)) {
49 + return (
50 + <ToolCallDisplay
51 + key={part.toolCallId}
52 + toolName={getToolName(part)}
53 + input={part.input}
54 + output={
55 + part.state === "output-available"
56 + ? part.output
57 + : undefined
58 + }
59 + isLoading={part.state !== "output-available"}
60 + />
61 + );
62 + }
63 + return null;
64 + })}
65 + </div>
66 + </div>
67 + ))}
68 + {isLoading && (
69 + <p className="text-gray-400 text-sm">Thinking...</p>
70 + )}
71 + </div>
72 +
73 + <form
74 + onSubmit={(e) => {
75 + e.preventDefault();
76 + if (!input.trim()) return;
77 + sendMessage({ text: input });
78 + setInput("");
79 + }}
80 + >
81 + <input
82 + value={input}
83 + onChange={(e) => setInput(e.target.value)}
84 + placeholder="Ask me anything..."
85 + disabled={isLoading}
86 + className="w-full p-3 border border-gray-300 rounded-lg"
87 + />
88 + </form>
89 + </main>
90 + );
91 +}
docs/examples/chat-app/page.tsx new
+72
@@ -0,0 +1,72 @@
1 +"use client";
2 +
3 +import { useState } from "react";
4 +import { useChat } from "@ai-sdk/react";
5 +import { DefaultChatTransport } from "ai";
6 +
7 +export default function Chat() {
8 + const [input, setInput] = useState("");
9 + const { messages, sendMessage, status } = useChat({
10 + transport: new DefaultChatTransport({ api: "/api/chat" }),
11 + });
12 +
13 + const isLoading = status === "streaming" || status === "submitted";
14 +
15 + return (
16 + <main className="max-w-2xl mx-auto p-6">
17 + <h1 className="text-2xl font-bold mb-6">Composio Chat</h1>
18 +
19 + <div className="space-y-4 mb-6 min-h-[200px]">
20 + {messages.length === 0 && (
21 + <p className="text-gray-400 text-center py-12">
22 + Try: &quot;Star the composio repo on GitHub&quot;
23 + </p>
24 + )}
25 + {messages.map((m) => (
26 + <div key={m.id} className="flex gap-2">
27 + <span className="font-semibold shrink-0">
28 + {m.role === "user" ? "You:" : "Agent:"}
29 + </span>
30 + <div className="whitespace-pre-wrap">
31 + {m.parts.map((part, i) =>
32 + part.type === "text" ? (
33 + <span key={i}>
34 + {String(part.text)
35 + .split(/(https?:\/\/[^\s)]+)/g)
36 + .map((segment, j) =>
37 + segment.match(/^https?:\/\//) ? (
38 + <a key={j} href={segment} target="_blank" rel="noopener noreferrer" className="text-blue-600 underline">{segment}</a>
39 + ) : (
40 + segment
41 + )
42 + )}
43 + </span>
44 + ) : null
45 + )}
46 + </div>
47 + </div>
48 + ))}
49 + {isLoading && (
50 + <p className="text-gray-400 text-sm">Thinking...</p>
51 + )}
52 + </div>
53 +
54 + <form
55 + onSubmit={(e) => {
56 + e.preventDefault();
57 + if (!input.trim()) return;
58 + sendMessage({ text: input });
59 + setInput("");
60 + }}
61 + >
62 + <input
63 + value={input}
64 + onChange={(e) => setInput(e.target.value)}
65 + placeholder="Ask me anything..."
66 + disabled={isLoading}
67 + className="w-full p-3 border border-gray-300 rounded-lg"
68 + />
69 + </form>
70 + </main>
71 + );
72 +}
docs/examples/chat-app/route.ts new
+32
@@ -0,0 +1,32 @@
1 +import { openai } from "@ai-sdk/openai";
2 +import { Composio } from "@composio/core";
3 +import { VercelProvider } from "@composio/vercel";
4 +import {
5 + streamText,
6 + convertToModelMessages,
7 + generateId,
8 + stepCountIs,
9 + type UIMessage,
10 +} from "ai";
11 +
12 +const composio = new Composio({ provider: new VercelProvider() });
13 +
14 +export async function POST(req: Request) {
15 + const { messages }: { messages: UIMessage[] } = await req.json();
16 +
17 + const session = await composio.create("user_123");
18 + const tools = await session.tools();
19 +
20 + const result = streamText({
21 + model: openai("gpt-5"),
22 + system: "You are a helpful assistant. Use Composio tools to help the user.",
23 + messages: await convertToModelMessages(messages),
24 + tools,
25 + stopWhen: stepCountIs(10),
26 + });
27 +
28 + return result.toUIMessageStreamResponse({
29 + originalMessages: messages,
30 + generateMessageId: () => generateId(),
31 + });
32 +}
docs/lib/source.ts
+12
@@ -227,6 +227,18 @@ export function mdxToCleanMarkdown(content: string): string {
227 '- [$2]($1): $3'
228 );
229
230 + // Convert AIToolsBanner to plain text
231 + result = result.replace(
232 + /<AIToolsBanner\s*\/>/g,
233 + '### For AI tools\n\n' +
234 + '**Skills:**\n' +
235 + '```bash\nnpx skills add composiohq/skills\n```\n' +
236 + '[Skills.sh](https://skills.sh/composiohq/skills/composio) · [GitHub](https://github.com/composiohq/skills)\n\n' +
237 + '**Context files:**\n' +
238 + '- [llms.txt](/llms.txt) — Documentation index with links\n' +
239 + '- [llms-full.txt](/llms-full.txt) — Complete documentation in one file'
240 + );
241 +
242 // Remove wrapper components (Cards, ProviderGrid, Tabs, Frame, div, QuickstartFlow, IntegrationTabs, Accordions, ToolTypeFlow, ToolkitsLanding, TemplateGrid, etc.)
243 result = result.replace(/<\/?(Cards|ProviderGrid|Tabs|Frame|div|QuickstartFlow|IntegrationTabs|Accordions|ToolTypeFlow|ToolkitsLanding|TemplateGrid)[^>]*>/g, '');
244
docs/mdx-components.tsx
+2
@@ -20,6 +20,7 @@ import { CapabilityCard, CapabilityList } from '@/components/capability-card';
20 import { TemplateCard, TemplateGrid } from '@/components/template-card';
21 import { ToolkitsLanding } from '@/components/toolkits/toolkits-landing';
22 import { Mermaid } from '@/components/mermaid';
23 +import { AIToolsBanner } from '@/components/ai-tools-banner';
24 import {
25 ShieldCheck,
26 Route as RouteIcon,
@@ -86,6 +87,7 @@ export function getMDXComponents(components?: MDXComponents): MDXComponents {
87 TemplateGrid,
88 ToolkitsLanding,
89 Mermaid,
90 + AIToolsBanner,
91 StepTitle,
92 // Lucide icons
93 ShieldCheck,