Access 500+ tools and integrations through Composio’s unified API platform for AI agents, with OAuth handling, event-driven workflows, and multi-user support.
Use this file to discover all available pages before exploring further.
Composio is an integration platform that provides access to 500+ tools across popular applications like GitHub, Slack, Notion, and more. It enables AI agents to interact with external services through a unified API, handling authentication, permissions, and event-driven workflows.
Initialize Composio with the LangChain provider and get tools from specific toolkits. Each toolkit represents a service (e.g., GitHub, Slack) with multiple tools (actions you can perform).
Initialize Composio
import { Composio } from '@composio/core';import { LangchainProvider } from '@composio/langchain';// Initialize Composio with LangChain providerconst composio = new Composio({ apiKey: process.env.COMPOSIO_API_KEY, provider: new LangchainProvider(),});// Get tools from specific toolkitsconst tools = await composio.tools.get('default', 'GITHUB');console.log(`Loaded ${tools.length} tools from GitHub toolkit`);
Here’s a complete example using Composio tools with a LangGraph agent to interact with HackerNews:
import { ChatOpenAI } from '@langchain/openai';import { HumanMessage, AIMessage } from '@langchain/core/messages';import { ToolNode } from '@langchain/langgraph/prebuilt';import { StateGraph, MessagesAnnotation } from '@langchain/langgraph';import { Composio } from '@composio/core';import { LangchainProvider } from '@composio/langchain';// Initialize Composioconst composio = new Composio({ apiKey: process.env.COMPOSIO_API_KEY, provider: new LangchainProvider(),});// Fetch the toolsconsole.log('🔄 Fetching the tools...');const tools = await composio.tools.get('default', 'HACKERNEWS_GET_USER');// Define the tools for the agent to useconst toolNode = new ToolNode(tools);// Create a model and give it access to the toolsconst model = new ChatOpenAI({ model: 'gpt-5',}).bindTools(tools);// Define the function that determines whether to continue or notfunction shouldContinue({ messages }: typeof MessagesAnnotation.State) { const lastMessage = messages[messages.length - 1] as AIMessage; // If the LLM makes a tool call, then we route to the "tools" node if (lastMessage.tool_calls?.length) { return 'tools'; } // Otherwise, we stop (reply to the user) return '__end__';}// Define the function that calls the modelasync function callModel(state: typeof MessagesAnnotation.State) { console.log('🔄 Calling the model...'); const response = await model.invoke(state.messages); return { messages: [response] };}// Define a new graphconst workflow = new StateGraph(MessagesAnnotation) .addNode('agent', callModel) .addEdge('__start__', 'agent') .addNode('tools', toolNode) .addEdge('tools', 'agent') .addConditionalEdges('agent', shouldContinue);// Compile the graphconst app = workflow.compile();// Use the agentconst finalState = await app.invoke({ messages: [new HumanMessage('Find the details of the user `pg` on HackerNews')]});console.log('✅ Message received from the model');console.log(finalState.messages[finalState.messages.length - 1].content);// Continue the conversationconst nextState = await app.invoke({ messages: [...finalState.messages, new HumanMessage('what about haxzie')]});console.log('✅ Message received from the model');console.log(nextState.messages[nextState.messages.length - 1].content);
Before using tools that require authentication, users need to connect their accounts:
import { Composio } from '@composio/core';const composio = new Composio({ apiKey: process.env.COMPOSIO_API_KEY});// Get authentication URL for a userconst authConnection = await composio.integrations.create({ userId: 'user_123', integration: 'github'});console.log(`Authenticate at: ${authConnection.redirectUrl}`);// After authentication, the user's connected account will be available// and tools will work with their credentials
// Each user authenticates their own accountsconst toolsUser1 = await composio.tools.get('user_1', 'GITHUB');const toolsUser2 = await composio.tools.get('user_2', 'GITHUB');// Tools will use the respective user's credentials// User 1's agent will act on User 1's GitHub accountconst agent1 = createAgent(model, toolsUser1);// User 2's agent will act on User 2's GitHub accountconst agent2 = createAgent(model, toolsUser2);
Composio supports triggering agents based on external events. When events occur in connected apps (like new GitHub commits or Slack messages), triggers automatically send structured payloads to your application.
For local development and prototyping, you can subscribe directly to triggers:
import { Composio } from '@composio/core';const composio = new Composio({ apiKey: 'your_api_key' });// Subscribe to trigger eventscomposio.triggers.subscribe( (data) => { console.log(`New commit detected:`, data); // Process the event with your agent // ... invoke your agent with the task }, { triggerId: 'your_trigger_id', // You can also filter by: // userId: 'user@acme.com', // toolkits: ['github', 'slack'], // triggerSlug: ["GITHUB_COMMIT_EVENT"], // authConfigId: "ac_1234567890" });// Note: For production, use webhooks instead
import { Composio } from '@composio/core';import { z } from 'zod';const composio = new Composio({ apiKey: process.env.COMPOSIO_API_KEY});const tool = await composio.tools.createCustomTool({ slug: 'CALCULATE_SQUARE', name: 'Calculate Square', description: 'Calculates the square of a number', inputParams: z.object({ number: z.number().describe('The number to calculate the square of'), }), execute: async input => { const { number } = input; return { data: { result: number * number }, error: null, successful: true, }; },});// Use with your agentconst allTools = [...tools, tool];
// Get tools with specific permissionsconst tools = await composio.tools.get('default', 'GITHUB', { // Limit to read-only operations permissions: ['read']});