FrameworksJavaScript FrameworksUsing Composio JS SDK with Langchain1Import DependenciesImport Langchain and LangchainToolSet1import { ChatOpenAI } from "@langchain/openai";2import { createOpenAIFunctionsAgent, AgentExecutor } from "langchain/agents";3import { pull } from "langchain/hub";4import { LangchainToolSet } from "composio-core";2Define method to let users connect their GitHub accountDefine method to let users connect their GitHub account1const toolset = new LangchainToolSet({ apiKey: process.env.COMPOSIO_API_KEY, });23async function setupUserConnectionIfNotExists(entityId) {4 const entity = toolset.client.getEntity(entityId);5 const connection = await entity.getConnection({ appName: "GITHUB" });67 if (!connection) {8 // If this entity/user hasn't already connected the account9 const connection = await entity.initiateConnection({appName: appName});10 console.log("Log in via: ", connection.redirectUrl);11 return connection.waitUntilActive(60);12 }1314 return connection;15}Learn more about Entities here3Setup Agent with LangchainDefine your Agent to create issues on Github1async function executeAgent (entityName){2 // Create entity and get tools3 const entity = toolset.client.getEntity(entityName)4 await setupUserConnectionIfNotExists(entity.id);5 const tools = await toolset.getTools({ actions: ["github_issues_create"] },entity.id);67 // Create an agent8 const prompt = await pull("hwchase17/openai-functions-agent");9 const llm = new ChatOpenAI({10 model: "gpt-4o",11 apiKey: process.env.OPEN_AI_API_KEY12 });1314 const agent = await createOpenAIFunctionsAgent({15 llm,16 tools: tools,17 prompt,18 });19 const agentExecutor = new AgentExecutor({agent,tools,verbose: true,});2021 // Invoke the agent22 const body = "TITLE: HELLO WORLD, DESCRIPTION: HELLO WORLD for the repo - himanshu-dixit/custom-repo-breaking"23 const result = await agentExecutor.invoke({24 input: "Please create another github issue with the summary and description with the following details of another issue:- , " + JSON.stringify(body)25 });2627 console.log(result.output)28}4Invoke your AgentInvoke the agent1executeAgent("himanshu")Tada 🎉! It was this simple to create a powerful Agent with Composio and Langchain.5Complete code snippetView the full code snippet hereBuilt with