@devries-cameron20 / composio Mirror · read-only
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 21, 04:45 UTC

next
ts 44 lines 1.2 KB
Raw
1 import { AuthConfigTypes, Composio } from '@composio/core';
2
3 // Initialize Composio
4 // OpenAI Provider is automatically installed and initialized
5 const composio = new Composio({
6 apiKey: process.env.COMPOSIO_API_KEY,
7 });
8
9 /**
10 * Create a new auth config
11 */
12 const authConfig = await composio.authConfigs.create('github', {
13 type: AuthConfigTypes.COMPOSIO_MANAGED,
14 name: 'My GitHub Auth Config',
15 });
16
17 console.log(`✅ Auth config created: ${authConfig.id}`);
18 console.log(`🔄 Createting a connection request`);
19
20 /**
21 * Create a new connected account
22 */
23 const ConnectionRequest = await composio.connectedAccounts.link('default', authConfig.id);
24
25 console.log(ConnectionRequest);
26
27 console.log(
28 `🔗 Please visit the following URL to authorize the user: ${ConnectionRequest.redirectUrl}`
29 );
30 const connectedAccount = await ConnectionRequest.waitForConnection();
31
32 console.log(`✅ Connected account created: ${connectedAccount.id}`);
33 console.log(connectedAccount);
34 console.log(`🔄 Getting the GitHub tools`);
35
36 const tools = await composio.tools.get('default', {
37 toolkits: ['github'],
38 });
39
40 console.log(tools);
41
42 const authConfigDetails = await composio.authConfigs.get(authConfig.id);
43
44 console.log({ authConfigDetails });