From 343f57a6812c30d83a4d366d5d48ce0487957b64 Mon Sep 17 00:00:00 2001 From: Abhishek Patil <83769052+abhishekpatil4@users.noreply.github.com> Date: Fri, 3 Jan 2025 17:00:30 +0530 Subject: [PATCH 1/5] chore: auth docs (#1116) Co-authored-by: Himanshu Dixit Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> Co-authored-by: Soham Ganatra --- .../newsletter-summarizer-javascript.mdx | 52 +-- .../combined/newsletter_summarizer.mdx | 28 +- .../intro/quickstart-entities.mdx | 16 +- docs/introduction/intro/quickstart-tools.mdx | 26 +- .../intro/quickstart-triggers.mdx | 4 +- .../intro/quickstart_3_backup.mdx | 8 +- docs/javascript/langchain.mdx | 4 +- docs/javascript/openai.mdx | 4 +- docs/patterns/Auth/connected_account.mdx | 303 ++++++++++++------ docs/patterns/Auth/using-connections.mdx | 2 +- .../use-tools/action-guide-without-agents.mdx | 25 +- .../tools/use-tools/use-specific-actions.mdx | 6 +- docs/patterns/triggers/triggers.mdx | 126 ++++++-- docs/sdrkit/ai-scheduling-agent.mdx | 6 +- .../langchain/slacktrigger_with_exa.mjs | 2 +- js/examples/scheduling-agent/demo.mjs | 2 +- 16 files changed, 381 insertions(+), 233 deletions(-) diff --git a/docs/examples/combined/newsletter-summarizer-javascript.mdx b/docs/examples/combined/newsletter-summarizer-javascript.mdx index c8c8ddbd585..00b2aa37c37 100644 --- a/docs/examples/combined/newsletter-summarizer-javascript.mdx +++ b/docs/examples/combined/newsletter-summarizer-javascript.mdx @@ -4,16 +4,10 @@ sidebarTitle: "Newsletter Summarizer" description: "This project serves as an example of how to use Composio to seamlessly fetch and summarize newsletter emails. It automatically retrieves recent newsletters, summarizes their content, and sends a well-formatted email to the specified recipient." --- - - - - Explore the complete source code for the Newsletter Summarizer project. This repository contains all the necessary files and scripts to set up and run the Newsletter Summarizer using Composio and Cloudflare. - - @@ -47,13 +41,13 @@ description: "This project serves as an example of how to use Composio to seamle ```javascript Define Webhook app.get('/webhook', async (req, res) => { try { - const body = `Please research on Arxiv about \`${researchTopic}\`, organize - the top ${nIssues} results as ${nIssues} issues for - a GitHub repository, and finally raise those issues with proper - title, body, implementation guidance, and references in - the ${targetRepo} repo, as well as relevant tags and assignees as + const body = `Please research on Arxiv about \`${researchTopic}\`, organize + the top ${nIssues} results as ${nIssues} issues for + a GitHub repository, and finally raise those issues with proper + title, body, implementation guidance, and references in + the ${targetRepo} repo, as well as relevant tags and assignees as the repo owner.`; - + const toolset = new OpenAIToolSet({ apiKey: process.env.COMPOSIO_API_KEY, }); @@ -79,7 +73,7 @@ description: "This project serves as an example of how to use Composio to seamle assistant_id: assistant.id, }); run = await toolset.wait_and_handle_assistant_tool_calls(client, run, thread); - + // Check if the run is completed if (run.status === "completed") { let messages = await client.beta.threads.messages.list(thread.id); @@ -110,34 +104,11 @@ description: "This project serves as an example of how to use Composio to seamle ``` + - - - - - - - - - - - - - - - - - - - - - - - - ## Putting It All Together @@ -154,11 +125,11 @@ description: "This project serves as an example of how to use Composio to seamle // Function to set up the GitHub connection for the user if it doesn't exist async function setupUserConnectionIfNotExists(toolset, entityId, c) { const entity = await toolset.client.getEntity(entityId); - const connection = await entity.getConnection('github'); + const connection = await entity.getConnection({ appName: "GITHUB" }); if (!connection) { // If the user hasn't connected their GitHub account - const connection = await entity.initiateConnection('github'); + const connection = await entity.initiateConnection({appName: "GITHUB"}); console.log('Log in via: ', connection.redirectUrl); c.json({ redirectUrl: connection.redirectUrl, message: 'Please log in to continue and then call this API again.' }); } @@ -231,6 +202,5 @@ description: "This project serves as an example of how to use Composio to seamle export default app; ``` - - + diff --git a/docs/examples/combined/newsletter_summarizer.mdx b/docs/examples/combined/newsletter_summarizer.mdx index 401f2a5d085..f9a63c97b49 100644 --- a/docs/examples/combined/newsletter_summarizer.mdx +++ b/docs/examples/combined/newsletter_summarizer.mdx @@ -11,8 +11,6 @@ description: "This project serves as an example of how to use Composio to seamle Explore the complete source code for the Newsletter Summarizer project. This repository contains all the necessary files and scripts to set up and run the Newsletter Summarizer using Composio and Cloudflare. - - @@ -150,8 +148,6 @@ description: "This project serves as an example of how to use Composio to seamle Explore the complete source code for the Newsletter Summarizer project. This repository contains all the necessary files and scripts to set up and run the Newsletter Summarizer using Composio and Cloudflare. - - @@ -255,26 +251,6 @@ description: "This project serves as an example of how to use Composio to seamle - - - - - - - - - - - - - - - - - - - - ## Putting It All Together @@ -387,11 +363,11 @@ print(result) // Function to set up the GitHub connection for the user if it doesn't exist async function setupUserConnectionIfNotExists(toolset, entityId, c) { const entity = await toolset.client.getEntity(entityId); - const connection = await entity.getConnection('github'); + const connection = await entity.getConnection({ appName: "GITHUB" }); if (!connection) { // If the user hasn't connected their GitHub account - const connection = await entity.initiateConnection('github'); + const connection = await entity.initiateConnection({appName: "GITHUB"}); console.log('Log in via: ', connection.redirectUrl); c.json({ redirectUrl: connection.redirectUrl, message: 'Please log in to continue and then call this API again.' }); } diff --git a/docs/introduction/intro/quickstart-entities.mdx b/docs/introduction/intro/quickstart-entities.mdx index 8c112c34401..abb3de0779b 100644 --- a/docs/introduction/intro/quickstart-entities.mdx +++ b/docs/introduction/intro/quickstart-entities.mdx @@ -65,11 +65,11 @@ We'll use Jessica as our example user. There are multiple ways to authenticate a - + Set up your development environment: - ```python Initialize Composio and OpenAI + ```python Initialize Composio Toolset and OpenAI from composio_openai import ComposioToolSet, Action from openai import OpenAI @@ -161,7 +161,7 @@ We'll use Jessica as our example user. There are multiple ways to authenticate a const client = new Composio({ apiKey: process.env.COMPOSIO_API_KEY }); const entity = await client.getEntity("Jessica"); - const connection = await entity.initiateConnection('googlecalendar'); + const connection = await entity.initiateConnection({appName: "googlecalendar"}); console.log(`Open this URL to authenticate: ${connection.redirectUrl}`); ``` @@ -177,11 +177,17 @@ We'll use Jessica as our example user. There are multiple ways to authenticate a - + Set up your development environment: +<<<<<<< HEAD + ```javascript Initialize Composio Toolset and OpenAI +||||||| 0378f58b ```javascript Initialize Composio and OpenAI +======= + ```javascript Initialize Composio's OpenAI Toolset and OpenAI +>>>>>>> 44f9adb9f45a48b9ce6bd352c62a5a39f9b74a23 import { OpenAI } from "openai"; import { OpenAIToolSet } from "composio-core"; @@ -314,4 +320,4 @@ Congratulations! You've just: Let's authenticate your user account to perform actions. -
\ No newline at end of file +
diff --git a/docs/introduction/intro/quickstart-tools.mdx b/docs/introduction/intro/quickstart-tools.mdx index 8a809011a68..ac2e74307a9 100644 --- a/docs/introduction/intro/quickstart-tools.mdx +++ b/docs/introduction/intro/quickstart-tools.mdx @@ -42,7 +42,7 @@ Don't forget to set your `COMPOSIO_API_KEY` and `OPENAI_API_KEY` in your environ
- + ```python Python from composio_openai import ComposioToolSet, App @@ -88,7 +88,7 @@ print(result)
- + @@ -120,7 +120,7 @@ print(result) - + ```javascript JavaScript import { OpenAI } from "openai"; @@ -137,19 +137,19 @@ print(result) - ```javascript Star a repo using LLM + ```javascript JavaScript const tools = await composio_toolset.getTools({ - actions: ["github_star_a_repository_for_the_authenticated_user"] - }); + actions: ["github_star_a_repository_for_the_authenticated_user"], + }); const instruction = "Star the repo composiohq/composio on GitHub"; const response = await openai_client.chat.completions.create({ - model: "gpt-4o", - messages: [{ role: "user", content: instruction }], - tools: tools, - tool_choice: "auto", - }); + model: "gpt-4o", + messages: [{ role: "user", content: instruction }], + tools: tools, + tool_choice: "auto", + }); ``` @@ -159,7 +159,7 @@ print(result) - ```javascript Execute Function calls + ```javascript JavaScript const result = await composio_toolset.handleToolCall(response); console.log(result); ``` @@ -205,4 +205,4 @@ Subscribe to triggers to execute actions automatically Learn about workspace environments, using CLI & other concepts - \ No newline at end of file + diff --git a/docs/introduction/intro/quickstart-triggers.mdx b/docs/introduction/intro/quickstart-triggers.mdx index 15a08ec9164..03694cb9481 100644 --- a/docs/introduction/intro/quickstart-triggers.mdx +++ b/docs/introduction/intro/quickstart-triggers.mdx @@ -193,7 +193,7 @@ const agentFunction = async (threadId, subject, senderMail) => { ```javascript JavaScript -toolset.client.triggers.subscribe( +toolset.triggers.subscribe( (data) => { const { payload: { @@ -248,4 +248,4 @@ Subscribe to triggers to execute actions automatically Learn about workspace environments, using CLI & other concepts - \ No newline at end of file + diff --git a/docs/introduction/intro/quickstart_3_backup.mdx b/docs/introduction/intro/quickstart_3_backup.mdx index bcc2ab5111b..3737856c84b 100644 --- a/docs/introduction/intro/quickstart_3_backup.mdx +++ b/docs/introduction/intro/quickstart_3_backup.mdx @@ -76,7 +76,7 @@ Follow these 5 steps to list your emails as soon as you receive them: const client = new Composio(process.env.COMPOSIO_API_KEY); const entity = await client.getEntity("Jessica"); - const connection = await entity.initiateConnection('gmail'); + const connection = await entity.initiateConnection({appName: "gmail"}); console.log(`Open this URL to authenticate: ${connection.redirectUrl}`); ``` @@ -170,7 +170,7 @@ Follow these 5 steps to list your emails as soon as you receive them: - + Set up your development environment: @@ -187,7 +187,7 @@ Follow these 5 steps to list your emails as soon as you receive them: - ```javascript Initialize Composio and OpenAI + ```javascript Initialize Composio's OpenAI Toolset and OpenAI import { OpenAI } from "openai"; import { OpenAIToolSet } from "composio-core"; @@ -285,4 +285,4 @@ Congratulations! You've just: - \ No newline at end of file + diff --git a/docs/javascript/langchain.mdx b/docs/javascript/langchain.mdx index 7c5b15c609a..e1c2e2b43c4 100644 --- a/docs/javascript/langchain.mdx +++ b/docs/javascript/langchain.mdx @@ -24,11 +24,11 @@ const toolset = new LangchainToolSet({ apiKey: process.env.COMPOSIO_API_KEY, }); async function setupUserConnectionIfNotExists(entityId) { const entity = toolset.client.getEntity(entityId); - const connection = await entity.getConnection('github'); + const connection = await entity.getConnection({ appName: "GITHUB" }); if (!connection) { // If this entity/user hasn't already connected the account - const connection = await entity.initiateConnection(appName); + const connection = await entity.initiateConnection({appName: appName}); console.log("Log in via: ", connection.redirectUrl); return connection.waitUntilActive(60); } diff --git a/docs/javascript/openai.mdx b/docs/javascript/openai.mdx index 7f96b46561c..f25fd3918b3 100644 --- a/docs/javascript/openai.mdx +++ b/docs/javascript/openai.mdx @@ -49,10 +49,10 @@ const appName = 'github'; async function setupUserConnectionIfNotExists(entityId) { const entity = toolset.client.getEntity(entityId); - const connection = await entity.getConnection(appName); + const connection = await entity.getConnection({ appName: appName }); if (!connection) { - const connection = await entity.initiateConnection(appName); + const connection = await entity.initiateConnection({appName: appName}); console.log("Log in via: ", connection.redirectUrl); return connection.waitUntilActive(60); } diff --git a/docs/patterns/Auth/connected_account.mdx b/docs/patterns/Auth/connected_account.mdx index e8b07c5a00c..d705eedf9c7 100644 --- a/docs/patterns/Auth/connected_account.mdx +++ b/docs/patterns/Auth/connected_account.mdx @@ -7,158 +7,277 @@ description: "Learn how to securely manage and authenticate multiple user connec ### Entities - Each **user** is represented by a **unique entity ID**. -- If you have two users, **Jessica** and **Melissa**, they will each have **unique entity IDs**. -If not specified, `default` will be used as the entity ID. - -You can use an entity object to manage connected accounts and perform actions on behalf of a user (more on this [here](/patterns/tools/use-tools/action-guide-without-agents#how-can-i-use-tools-for-a-specific-user)). Here's how to retrieve an entity object: +- If you have two users, **default** and **Melissa**, they will each have **unique entity IDs**. +- You can use an entity object to manage connected accounts and perform actions on behalf of a user, learn more [here](/patterns/tools/use-tools/action-guide-without-agents#how-can-i-use-tools-for-a-specific-user). Here's how to retrieve an entity object: ```python Python from composio import ComposioToolSet toolset = ComposioToolSet() -entity = toolset.get_entity(id='Jessica') +entity = toolset.get_entity(id='default') ``` ```javascript JavaScript -import { OpenAIToolSet } from "composio-core"; +import { ComposioToolSet } from "composio-core"; -const toolset = new OpenAIToolSet(); -const entity = toolset.client.getEntity(id='Jessica'); +const toolset = new ComposioToolSet(); +const entity = toolset.client.getEntity(id='default'); ``` +If entity ID is not specified, `default` will be used as the entity ID. ### Connected Accounts - When a user connects their account, a `connected_account` object is created. - **Connected Account** securely stores **authentication data** such as **API keys, access tokens and refresh tokens**. -### How to initiate a new connection for your user -Follow these steps to initiate a new connection for your user (for both OAuth and non-OAuth based Apps): +### Integrations & Connections + +**Integration** +- An integration is your app's configuration for services like Gmail or GitHub +- Each integration contains authentication method, API scopes, client credentials and other app settings +- Developers can create multiple integrations with different configurations, learn more [here](../Auth/Integrations#what-is-an-integration) + +**Connection** +- A connection links a user to an integration +- Multiple connections can be created for the same integration +- Learn how to use connections [here](../Auth/using-connections) +### Initiating a new connection for your user -Initiate a new connection by passing the redirect url, entity id & app. + + -```python Python +```bash Python +pip install composio-core +``` +```bash JavaScript +npm install composio-core +``` + + + + +``` python Python from composio import ComposioToolSet, App toolset = ComposioToolSet() - -# URL that the user will be redirected to after completing the authentication process +``` +``` javascript JavaScript +import { ComposioToolSet } from "composio-core"; +const toolset = new ComposioToolSet(); +``` + + + +Below are the accepted parameters for initiating a new connection: +- `integration_id`: ID of the existing integration, use this to create a connection for an existing integration, If no integration exists for the given app, new one is automatically created +- `app`: name of the app to create a connection for +- `labels`: labels to be assigned to the connection, which can later be used to filter connections +- `entity_id`: ID of the user for whom the connection is being created +- `redirect_url`: URL to redirect the user to after the connection is created (for OAuth auth scheme). If not provided, the user will be redirected to Composio's connection success/failer page +- `connected_account_params`/`data`: If auth mode is non-OAuth, this is where parameters need to be passed for creating a connection (API key, shopify store name, etc) +- `auth_scheme`: Type of authentication to be used for the connection (OAUTH2 or API_KEY, etc), OAUTH2 will be defaulted if not provided +- `auth_config`: If auth mode is OAuth, this is where the configuration needs to be provided for creating a connection (client_id, client_secret, etc) + +Let's create a connection for the user **default** for the Gmail app. + +```python Python +# Store connection parameters redirect_url = "https://yourwebsite.com/connection/success" +entity_id = "default" -# Unique identifier for the user for whom the connection is being created -entity_id = "Jessica" - -# Initiate new connection (You can use integration_id instead of app) connection_request = toolset.initiate_connection(redirect_url=redirect_url, entity_id=entity_id, app=App.GMAIL) - -# Redirect the user to the URL below -print(connection_request.redirectUrl) - -# Check the status of the connection (it can be initiated, active, or failed) -print(connection_request.connectionStatus) ``` - -```javascript Javascript -import { OpenAIToolSet } from "composio-core"; -const toolset = new OpenAIToolSet(); - -// URL that the user will be redirected to after completing the authentication process +```javascript JavaScript +// Store connection parameters const redirectURL = "https://yourwebsite.com/connection/success" +const entityId = "default" -// Unique identifier for the user for whom the connection is being created -const entityId = "Jessica" - -// Initiate new connection (You can use integration_id instead of app) -const connectionRequest = await toolset.client.connectedAccounts.initiate({ +const connectionRequest = await toolset.connectedAccounts.initiate({ appName: "gmail", - redirect_url: redirectURL, + redirectUri: redirectURL, entityId: entityId, authMode: "OAUTH2", - authConfig: {}, }); - -// Redirect the user to the URL below -console.log(connectionRequest.redirectUrl); - -// Check the status of the connection (it can be initiated, active, or failed) -console.log(connectionRequest.connectionStatus); +console.log(connectionRequest); +``` + +Connection request output: + +```bash Python +connectionStatus='INITIATED' +connectedAccountId='' +redirectUrl='https://accounts.google.com...' +``` +```bash JavaScript +connectionStatus='INITIATED' +connectedAccountId='' +redirectUrl='https://accounts.google.com...' ``` +- `connectionStatus`: status of the connection, initially it will be **INITIATED** and will change to **ACTIVE** or **FAILED** after user completes the auth flow +- `connectedAccountId`: ID of the newly created account, you can use this ID to retrieve the connection object +- `redirectUrl`: URL to redirect to perform authentication, post the authentication flow user will be redirect to the page specified in the `redirectUrl` parameter + + +Use the connectedAccountId to get the detailed information about the connection, learn more [here](../Auth/using-connections). + +```python Python +connection = toolset.get_connected_account(id="83f5e791-e6c4-4cd6-8e3a-dada66b0a8f1") +print(connection.status) +``` +```javascript JavaScript +const connection = await toolset.connectedAccounts.get({ + connectedAccountId: "" +}); +console.log(connection.status); +``` + +Status of the connection can be one of the following: +- `INITIATED`: Connection is initiated but not yet completed +- `ACTIVE`: Connection is active and ready to use +- `FAILED`: Connection failed to be created + + Each App integration has a unique **integration ID**. You can use this ID instead of the **app name** when creating connections. -Get the expected parameters required to create a connection & pass then while initiating a new connection (API Key, Subdomain URL, Username etc.). + + +```bash Python +pip install composio-core +``` +```bash JavaScript +npm install composio-core +``` + + + + +``` python Python +from composio import ComposioToolSet, App +toolset = ComposioToolSet() +``` +``` javascript JavaScript +import { ComposioToolSet } from "composio-core"; +const toolset = new ComposioToolSet(); +``` + + +Get the expected parameters required to create a connection & pass them while initiating a new connection (API Key, Subdomain URL, Username etc.). ```python Python -from composio import ComposioToolSet, App -toolset = ComposioToolSet() - # You can use integration_id instead of app response = toolset.get_expected_params_for_user(app=App.FIRECRAWL) - print(response["expected_params"]) ``` - -```javascript Javascript -import { OpenAIToolSet } from "composio-core"; -const toolset = new OpenAIToolSet(); - -// You can use integration_id instead of app -const expectedInputFields = await toolset.getExpectedParamsForUser({ - app: "firecrawl", -}); - -console.log(expectedInputFields) +```javascript JavaScript +const expectedInputFields = await toolset.integrations.getRequiredParams( + "", //integrationId +); +console.log(expectedInputFields); ``` +Response: +```bash {3} +[ + ExpectedFieldInput( + name='api_key', + type='string', + description='Your FireCrawl API key for authentication. Obtain it from your FireCrawl settings.', + displayName='API Key', + is_secret=False, + required=True, + expected_from_customer=True, + default=None, + get_current_user_endpoint=None) +] +``` +To create a new connection for FireCrawl app, we need the FireCrawl API key - +Below are the accepted parameters for initiating a new connection: +- `integration_id`: ID of the existing integration, use this to create a connection for an existing integration, If no integration exists for the given app, new one is automatically created +- `app`: name of the app to create a connection for +- `labels`: labels to be assigned to the connection, which can later be used to filter connections +- `entity_id`: ID of the user for whom the connection is being created +- `redirect_url`: URL to redirect the user to after the connection is created (for OAuth auth scheme). If not provided, the user will be redirected to Composio's connection success/failer page +- `connected_account_params`/`data`: If auth mode is non-OAuth, this is where parameters need to be passed for creating a connection (API key, shopify store name, etc) +- `auth_scheme`: Type of authentication to be used for the connection (OAUTH2 or API_KEY, etc), OAUTH2 will be defaulted if not provided +- `auth_config`: If auth mode is OAuth, this is where the configuration needs to be provided for creating a connection (client_id, client_secret, etc) + +Let's create a connection for the user **default** for the FireCrawl app. ```python Python -# Unique identifier for the user for whom the connection is being created -entity_id = "Jessica" - -# Add the parameters collected from the user -collected_params = { - "api_key": "" -} +# Store connection parameters +entity_id = "default" +collected_params = {"api_key": ""} +auth_scheme = "API_KEY" # Initiate new connection (You can use integration_id instead of app) -connection_request = toolset.initiate_connection(connected_account_params=collected_params, entity_id=entity_id, app=App.FIRECRAWL) - -# Check the status of the connection (it can be initiated, active, or failed) -print(connection_request.connectionStatus) +connection_request = toolset.initiate_connection( + connected_account_params=collected_params, + entity_id=entity_id, + app=App.FIRECRAWL, + auth_scheme=auth_scheme, +) ``` - -```javascript Javascript -// Unique identifier for the user for whom the connection is being created -const entityId = "Jessica" - -// Add the parameters collected from the user +```javascript JavaScript +// Store connection parameters +const entityId = "default"; const collectedParams = { - "api_key": "" -} - -// Initiate new connection (You can use integration_id instead of app) -const connectionRequest = await toolset.client.connectedAccounts.initiate({ - data: { - ...collectedParams - }, + api_key: "" +}; +const authScheme = "API_KEY"; + +const connection_request = await toolset.connectedAccounts.initiate({ + data: collectedParams, entityId: entityId, appName: "firecrawl", - authMode: "API_KEY", - authConfig: {}, - }); - - -// Check the status of the connection (it can be initiated, active, or failed) -console.log(connectionRequest.connectionStatus); + authMode: authScheme, + authConfig: {} +}) +console.log(connection_request) +``` + +Connection request output: + +```bash Python +connectionStatus='ACTIVE' +connectedAccountId='' +redirectUrl=None +``` +```bash JavaScript +connectionStatus='ACTIVE' +connectedAccountId='' +redirectUrl=None +``` + +- `connectionStatus`: status of the connection +- `connectedAccountId`: ID of the newly created account, you can use this ID to retrieve the connection object +- `redirectUrl`: URL to redirect to perform authentication, since its not an OAuth type auth scheme, redirectUrl will be None + + +Use the connectedAccountId to get the detailed information about the connection, learn more [here](../Auth/using-connections). + +```python Python +connection = toolset.get_connected_account(id="") +print(connection.status) +``` +```javascript JavaScript +const connection = await toolset.connectedAccounts.get({ + connectedAccountId: "" +}); +console.log(connection.status); ``` +Status of the connection can be one of the following: +- `INITIATED`: Connection is initiated but not yet completed +- `ACTIVE`: Connection is active and ready to use +- `FAILED`: Connection failed to be created Each App integration has a unique **integration ID**. You can use this ID instead of the **app name** when creating connections. diff --git a/docs/patterns/Auth/using-connections.mdx b/docs/patterns/Auth/using-connections.mdx index aad28c0c8bf..afbe6f6bb5e 100644 --- a/docs/patterns/Auth/using-connections.mdx +++ b/docs/patterns/Auth/using-connections.mdx @@ -65,7 +65,7 @@ description: "Learn how to use connections" const entity = await toolset.client.getEntity("Jessica") // Filters based on app name - const connectionDetails = await entity.getConnection("github") + const connectionDetails = await entity.getConnection({ appName: "GITHUB" }) if(connectionDetails){ console.log(connectionDetails) diff --git a/docs/patterns/tools/use-tools/action-guide-without-agents.mdx b/docs/patterns/tools/use-tools/action-guide-without-agents.mdx index cf471de28c7..493a7ea13a1 100644 --- a/docs/patterns/tools/use-tools/action-guide-without-agents.mdx +++ b/docs/patterns/tools/use-tools/action-guide-without-agents.mdx @@ -27,13 +27,13 @@ import { OpenAIToolSet } from "composio-core"; const toolset = new OpenAIToolSet(); const entity = toolset.client.getEntity("Jessica"); -const result = await entity.execute( - "GITHUB_STAR_A_REPOSITORY_FOR_THE_AUTHENTICATED_USER", - { - "owner": "composiohq", - "repo": "composio" - } -); +const result = await entity.execute({ + actionName: "GITHUB_STAR_A_REPOSITORY_FOR_THE_AUTHENTICATED_USER", + params: { + owner: "composiohq", + repo: "composio", + }, +}); console.log(result); ``` @@ -52,12 +52,11 @@ tool_set.execute_action( ``` ```javascript JavaScript -const result = await toolset.client.getEntity("Jessica").execute( - 'github_star_a_repository_for_the_authenticated_user', - {}, - // Natural language prompt - "Star the repo composiohq/composio" -) +const result = await toolset.client.getEntity("Jessica").execute({ + actionName: "GITHUB_STAR_A_REPOSITORY_FOR_THE_AUTHENTICATED_USER", + // Natural language prompt + text: "Star the repo composiohq/composio", +}); console.log(result); ``` diff --git a/docs/patterns/tools/use-tools/use-specific-actions.mdx b/docs/patterns/tools/use-tools/use-specific-actions.mdx index ebf6d3a7dca..1d8eb1934af 100644 --- a/docs/patterns/tools/use-tools/use-specific-actions.mdx +++ b/docs/patterns/tools/use-tools/use-specific-actions.mdx @@ -120,7 +120,11 @@ console.log(actionsList); apps: ["github", "gmail"], useCase: "get repo details and send an email to the owner of the repo" }); - console.log(actionsEnums); + console.log("Action enums:", actionsEnums); + + // Fetch the actual actions using the enums + const actions = await toolset.getTools({ actions: actionsEnums }); + console.log("Fetched actions:", actions); })(); ``` diff --git a/docs/patterns/triggers/triggers.mdx b/docs/patterns/triggers/triggers.mdx index 21038770ea6..9859342d5fa 100644 --- a/docs/patterns/triggers/triggers.mdx +++ b/docs/patterns/triggers/triggers.mdx @@ -24,7 +24,7 @@ composio triggers enable GITHUB_STAR_ADDED_EVENT You need to pass the trigger id to disable a trigger. You can get the trigger id from logs (when you enable a trigger) or from the dashboard. ```Bash -composio triggers disable 818bd52e-c527-446b-b2b5-7410db9aa607 +composio triggers disable 818bd52e-c5... ```
@@ -46,7 +46,7 @@ print(trigger_schema.config) ``` Response: -```json +```bash {2,5} properties={ 'owner': TriggerConfigPropertyModel(description='Owner of the repository', title='Owner', @@ -62,6 +62,7 @@ required=[ 'repo' ] ``` +Based on the response, we see that the trigger requires two config parameters: the repository **owner** and **repo** name You need to pass the trigger enum and the config parameters to enable a trigger, and **trigger id** will be returned. @@ -79,7 +80,7 @@ print(response) You need to pass the trigger id to disable a trigger. You can get the trigger id from response (when you enable a trigger) or from the dashboard. ```python -entity.disable_trigger("818bd52e-c527-446b-b2b5-7410db9aa607") +entity.disable_trigger("818bd52e-c5...") ``` @@ -88,38 +89,67 @@ entity.disable_trigger("818bd52e-c527-446b-b2b5-7410db9aa607") ```javascript -import { OpenAIToolSet } from "composio-core"; -const toolset = new OpenAIToolSet(); +import { ComposioToolSet } from "composio-core"; +const toolset = new ComposioToolSet(); ``` -Triggers have a config schema, which can be obtained by calling the `get_trigger` method and passing the trigger enum. -```javascript -coming soon +Triggers have a config schema, which can be obtained by calling the `getTriggerConfig` method & passing the trigger id. +```javascript {2} +const trigger = await toolset.triggers.getTriggerConfig({ + triggerId: "GITHUB_STAR_ADDED_EVENT" +}) +console.log(trigger.config) +``` +Response: +```bash {3,8} +{ + properties: { + owner: { + description: 'Owner of the repository', + title: 'Owner', + type: 'string' + }, + repo: { description: 'Repository name', title: 'Repo', type: 'string' } + }, + required: [ 'owner', 'repo' ], + title: 'WebhookConfigSchema', + type: 'object' +} ``` +Based on the response, we see that the trigger requires two config parameters: the repository **owner** and **repo** name - + You need to pass the trigger enum and the config parameters to enable a trigger, and **trigger id** will be returned. -You can pass entity id to enable trigger for a specific entity. Learn more about entities [here](../auth/connected_account#entities) -```javascript {1} -const entity = toolset.client.getEntity(); - +You need to pass the connected account ID, the trigger name and the config parameters to setup a trigger. +```javascript {3-8} (async () => { - console.log( - "res: ", - await entity.setupTrigger("github", "GITHUB_STAR_ADDED_EVENT", { + console.log(await toolset.triggers.setup({ + connectedAccountId: "b8bceb9d-2b6...", + triggerName: "GITHUB_STAR_ADDED_EVENT", + config: { owner: "composiohq", repo: "composio", - }) - ); + } + })) +})(); +``` +Setting up a trigger automatically enables it. + + +You need to pass the trigger id to enable a trigger. You can get the trigger id from response (when you create a trigger) or from the dashboard. +```javascript {2} +(async () => { + console.log(await toolset.triggers.enable({ triggerId: "" })) })(); ``` -You need to pass the trigger id to disable a trigger. You can get the trigger id from response (when you enable a trigger) or from the dashboard. -```javascript -const res = await entity.disableTrigger("f95b3f90-ea09-4ef2-945c-dce50f9c7eeb") -console.log(res) +You need to pass the trigger id to disable a trigger. You can get the trigger id from response (when you create a trigger) or from the dashboard. +```javascript {2} +(async () => { + console.log(await toolset.triggers.disable({ triggerId: "" })) +})(); ``` @@ -166,8 +196,8 @@ listener.wait_forever()
```javascript -import { Composio } from "composio-core"; -const toolset = new Composio(); +import { ComposioToolSet } from "composio-core"; +const toolset = new ComposioToolSet(); toolset.triggers.subscribe( (data) => { @@ -180,7 +210,7 @@ toolset.triggers.subscribe( ``` -Trigger event payload when the repository composio is starred: +Trigger event payload for GitHub's **GITHUB_STAR_ADDED_EVENT** trigger: ```json payload={ 'action': 'created', @@ -192,4 +222,48 @@ payload={ 'triggerName': 'GITHUB_STAR_ADDED_EVENT' } ``` -To learn how to configure and use your own webhooks for listening to triggers, visit our [Webhooks Guide](/patterns/triggers/webhooks). \ No newline at end of file +To learn how to configure and use your own webhooks for listening to triggers, visit [Webhooks Guide](/patterns/triggers/webhooks). + +## Listing Triggers + + +```python +coming soon +``` + + +Triggers can be listed and filtered by **triggerIds**, **appNames**, **connectedAccountIds**, **integrationIds** and **showEnabledOnly**. +```javascript +import { ComposioToolSet } from "composio-core"; +const toolset = new ComposioToolSet(); + +const triggers = await toolset.triggers.list({ + triggerIds: [""], // array of trigger ids + appNames: [""], // array of app names + connectedAccountIds: [""], // array of connected account ids + integrationIds: [""], // array of integration ids + showEnabledOnly: true // boolean +}); +``` + + + +## Deleting Triggers + + +```python +coming soon +``` + + +You need to pass the trigger ID to delete a trigger. You can get the trigger id from response (when you create a trigger) or from the dashboard. +```javascript +import { ComposioToolSet } from "composio-core"; +const toolset = new ComposioToolSet(); + +(async () => { + console.log(await toolset.triggers.delete({ triggerInstanceId: "" })); +})(); +``` + + \ No newline at end of file diff --git a/docs/sdrkit/ai-scheduling-agent.mdx b/docs/sdrkit/ai-scheduling-agent.mdx index d452c198036..b19cc8ec410 100644 --- a/docs/sdrkit/ai-scheduling-agent.mdx +++ b/docs/sdrkit/ai-scheduling-agent.mdx @@ -260,7 +260,7 @@ const toolset = new VercelAIToolSet({ ```javascript setup the ai agent -await toolset.client.triggers.subscribe(async (data) => { +await toolset.triggers.subscribe(async (data) => { console.log("trigger received", data); const payload = data.payload; const message = payload.messageText; @@ -310,7 +310,7 @@ const toolset = new VercelAIToolSet({ }); // Subscribe to triggers and perform actions -await toolset.client.triggers.subscribe(async (data) => { +await toolset.triggers.subscribe(async (data) => { console.log("trigger received", data); const payload = data.payload; const message = payload.messageText; @@ -348,4 +348,4 @@ await toolset.client.triggers.subscribe(async (data) => { - \ No newline at end of file + diff --git a/js/examples/langchain/slacktrigger_with_exa.mjs b/js/examples/langchain/slacktrigger_with_exa.mjs index 98eb30d4dfb..428943ab2b0 100644 --- a/js/examples/langchain/slacktrigger_with_exa.mjs +++ b/js/examples/langchain/slacktrigger_with_exa.mjs @@ -8,7 +8,7 @@ import { LangchainToolSet } from "composio-core"; const toolset = new LangchainToolSet({ apiKey: process.env.COMPOSIO_API_KEY }); // Subscribe to triggers and execute the agent -toolset.client.triggers.subscribe((data) => { +toolset.triggers.subscribe((data) => { console.log("trigger received", data); executeAgent("default", data.payload.event); }); diff --git a/js/examples/scheduling-agent/demo.mjs b/js/examples/scheduling-agent/demo.mjs index 0abac060ffb..cfa59bc0802 100644 --- a/js/examples/scheduling-agent/demo.mjs +++ b/js/examples/scheduling-agent/demo.mjs @@ -10,7 +10,7 @@ const toolset = new VercelAIToolSet({ }); // Subscribe to triggers and perform actions -await toolset.client.triggers.subscribe(async (data) => { +await toolset.triggers.subscribe(async (data) => { console.log("trigger received", data); const payload = data.payload; const message = payload.messageText; From 79e7b8743b8b625b24779c3d58b4bad5e6becaa7 Mon Sep 17 00:00:00 2001 From: Himanshu Dixit Date: Fri, 3 Jan 2025 17:07:00 +0530 Subject: [PATCH 2/5] feat: add support for zod error (#1146) --- js/src/sdk/index.spec.ts | 14 ++++++++++++-- js/src/sdk/utils/errors/src/formatter.ts | 15 ++++++++++++++- 2 files changed, 26 insertions(+), 3 deletions(-) diff --git a/js/src/sdk/index.spec.ts b/js/src/sdk/index.spec.ts index 4e46a66295a..bc069b9864d 100644 --- a/js/src/sdk/index.spec.ts +++ b/js/src/sdk/index.spec.ts @@ -61,6 +61,15 @@ describe("Basic SDK spec suite", () => { type: "BadRequestError", name: "InvalidRequestError", message: "Invalid request for apps", + details: [ + { + property: "triggerConfig", + children: [], + constraints: { + isObject: "triggerConfig must be an object", + }, + }, + ], }); const client = new Composio({ apiKey: COMPOSIO_API_KEY }); @@ -70,9 +79,10 @@ describe("Basic SDK spec suite", () => { const error = e as ComposioError; const errorCode = COMPOSIO_SDK_ERROR_CODES.BACKEND.BAD_REQUEST; expect(error.errCode).toBe(errorCode); - expect(error.message).toContain("InvalidRequestError "); expect(error.message).toContain("InvalidRequestError"); - expect(error.description).toContain("Invalid request for apps"); + expect(error.description).toContain( + `Validation Errors: {"property":"triggerConfig","children":[],"constraints":{"isObject":"triggerConfig must be an object"}}` + ); } mock.reset(); diff --git a/js/src/sdk/utils/errors/src/formatter.ts b/js/src/sdk/utils/errors/src/formatter.ts index 1771da74b53..bd04a39be35 100644 --- a/js/src/sdk/utils/errors/src/formatter.ts +++ b/js/src/sdk/utils/errors/src/formatter.ts @@ -9,6 +9,7 @@ export interface ErrorResponseData { type: string; name: string; message: string; + details?: Record[] | Record; } interface ErrorDetails { @@ -53,13 +54,25 @@ export const getAPIErrorDetails = ( } switch (errorCode) { + case COMPOSIO_SDK_ERROR_CODES.BACKEND.BAD_REQUEST: + const validationErrors = axiosError.response?.data?.details; + const formattedErrors = Array.isArray(validationErrors) + ? validationErrors.map((err) => JSON.stringify(err)).join(", ") + : JSON.stringify(validationErrors); + + return { + message: genericMessage, + description: `Validation Errors: ${formattedErrors}`, + possibleFix: + "Please check the request parameters and ensure they are correct.", + metadata, + }; case COMPOSIO_SDK_ERROR_CODES.BACKEND.NOT_FOUND: case COMPOSIO_SDK_ERROR_CODES.BACKEND.UNAUTHORIZED: case COMPOSIO_SDK_ERROR_CODES.BACKEND.SERVER_ERROR: case COMPOSIO_SDK_ERROR_CODES.BACKEND.SERVER_UNAVAILABLE: case COMPOSIO_SDK_ERROR_CODES.BACKEND.RATE_LIMIT: case COMPOSIO_SDK_ERROR_CODES.BACKEND.UNKNOWN: - case COMPOSIO_SDK_ERROR_CODES.BACKEND.BAD_REQUEST: return { message: genericMessage, description: errorMessage || (predefinedError.description as string), From b8532ee5ed06a980773510c30bd2bf928305f0d9 Mon Sep 17 00:00:00 2001 From: Himanshu Dixit Date: Fri, 3 Jan 2025 17:09:37 +0530 Subject: [PATCH 3/5] feat: pick active connection only (#1152) --- js/src/sdk/base.toolset.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/js/src/sdk/base.toolset.ts b/js/src/sdk/base.toolset.ts index bd0baa396b3..b7740f6e3bd 100644 --- a/js/src/sdk/base.toolset.ts +++ b/js/src/sdk/base.toolset.ts @@ -236,6 +236,8 @@ export class ComposioToolSet { // fetch connected account id const connectedAccounts = await this.client.connectedAccounts.list({ user_uuid: entityId, + status: "ACTIVE", + showActiveOnly: true, }); accountId = connectedAccounts?.items[0]?.id; } From 4cf51bc84436ad542574576080ef9424d2454637 Mon Sep 17 00:00:00 2001 From: "devin-ai-integration[bot]" <158243242+devin-ai-integration[bot]@users.noreply.github.com> Date: Fri, 3 Jan 2025 17:14:55 +0530 Subject: [PATCH 4/5] docs: standardize entity id and execute method format in documentation (#1101) Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> Co-authored-by: Soham Ganatra Co-authored-by: Abhishek Patil <83769052+abhishekpatil4@users.noreply.github.com> --- .../intro/quickstart-entities.mdx | 40 ++++++++----------- docs/introduction/intro/quickstart-tools.mdx | 12 +++--- .../intro/quickstart-triggers.mdx | 12 +++--- .../intro/quickstart_3_backup.mdx | 10 ++--- docs/patterns/Auth/Integrations.mdx | 10 ++--- docs/patterns/Auth/using-connections.mdx | 10 ++--- .../use-tools/action-guide-without-agents.mdx | 11 ++--- 7 files changed, 50 insertions(+), 55 deletions(-) diff --git a/docs/introduction/intro/quickstart-entities.mdx b/docs/introduction/intro/quickstart-entities.mdx index abb3de0779b..c40c5e4ca72 100644 --- a/docs/introduction/intro/quickstart-entities.mdx +++ b/docs/introduction/intro/quickstart-entities.mdx @@ -40,14 +40,14 @@ Follow these 5 steps to connect your user to Google Calendar and create an event -We'll use Jessica as our example user. There are multiple ways to authenticate an account: +We'll use **`default`** as our example user. There are multiple ways to authenticate an account: - ```python Authenticate Jessica's Google Calendar Account + ```python Authenticate Google Calendar Account from composio import ComposioToolSet, App - toolset = ComposioToolSet(entity_id="Jessica") + toolset = ComposioToolSet(entity_id="default") entity = toolset.get_entity() request = entity.initiate_connection(App.GOOGLECALENDAR) @@ -74,7 +74,7 @@ We'll use Jessica as our example user. There are multiple ways to authenticate a from openai import OpenAI openai_client = OpenAI() - composio_toolset = ComposioToolSet(entity_id="Jessica") + composio_toolset = ComposioToolSet(entity_id="default") ``` @@ -144,24 +144,24 @@ We'll use Jessica as our example user. There are multiple ways to authenticate a -We'll use Jessica as our example user. There are multiple ways to authenticate an account: +We'll use **`default`** as our example user. There are multiple ways to authenticate an account: - ```bash Authenticate Jessica's Google Calendar Account - composio add googlecalendar -e "Jessica" # Launches Google Calendar login + ```bash Authenticate Google Calendar Account + composio add googlecalendar -e "default" # Launches Google Calendar login ``` - ```javascript Authenticate Jessica's Google Calendar Account + ```javascript Authenticate Google Calendar Account import { Composio } from "composio-core"; const client = new Composio({ apiKey: process.env.COMPOSIO_API_KEY }); - const entity = await client.getEntity("Jessica"); - const connection = await entity.initiateConnection({appName: "googlecalendar"}); + const entity = await client.getEntity("default"); + const connection = await entity.initiateConnection('googlecalendar'); console.log(`Open this URL to authenticate: ${connection.redirectUrl}`); ``` @@ -177,17 +177,11 @@ We'll use Jessica as our example user. There are multiple ways to authenticate a - + Set up your development environment: -<<<<<<< HEAD - ```javascript Initialize Composio Toolset and OpenAI -||||||| 0378f58b - ```javascript Initialize Composio and OpenAI -======= - ```javascript Initialize Composio's OpenAI Toolset and OpenAI ->>>>>>> 44f9adb9f45a48b9ce6bd352c62a5a39f9b74a23 + ```javascript Initialize Composio's OpenAIToolset and OpenAI import { OpenAI } from "openai"; import { OpenAIToolSet } from "composio-core"; @@ -197,7 +191,7 @@ We'll use Jessica as our example user. There are multiple ways to authenticate a const composio_toolset = new OpenAIToolSet({ apiKey: process.env.COMPOSIO_API_KEY, - entityId: "Jessica", + entityId: "default", }); ``` @@ -251,10 +245,10 @@ We'll use Jessica as our example user. There are multiple ways to authenticate a -We'll use Jessica as our example user. There are multiple ways to authenticate an account: +We'll use **`default`** as our example user. There are multiple ways to authenticate an account: - ```bash Authenticate Jessica's Google Calendar Account - composio add googlecalendar -e "Jessica" # Launches Google Calendar login + ```bash Authenticate Google Calendar Account + composio add googlecalendar -e "default" # Launches Google Calendar login ``` @@ -287,7 +281,7 @@ We'll use Jessica as our example user. There are multiple ways to authenticate a --header 'X-API-Key: ADD YOUR API KEY HERE' \ --data '{ "appName": "GOOGLECALENDAR", #add your app name here - "entityId": "Jessica", #add your entity id here + "entityId": "default", #add your entity id here "input": { "start_datetime": "11:15 PM, 1 December 2024", "event_duration": "2h" diff --git a/docs/introduction/intro/quickstart-tools.mdx b/docs/introduction/intro/quickstart-tools.mdx index ac2e74307a9..f4de5375de9 100644 --- a/docs/introduction/intro/quickstart-tools.mdx +++ b/docs/introduction/intro/quickstart-tools.mdx @@ -21,16 +21,16 @@ pip install composio_core composio_openai -We'll use **`Jessica`** as the user id [(entity id)](../../patterns/Auth/connected_account#entities). +We'll use **`default`** as the user id [(entity id)](../../patterns/Auth/connected_account#entities). You need to have an active GitHub Integration. Learn how to do this [here](https://youtu.be/LmyWy4LiedQ?si=u5uFArlNL0tew0Wf) ```shell CLI composio login -composio add github -e "Jessica" +composio add github -e "default" ``` ```python Python from composio_openai import ComposioToolSet, App, Trigger -toolset = ComposioToolSet(entity_id="Jessica") +toolset = ComposioToolSet(entity_id="default") request = toolset.initiate_connection(app=App.GITHUB) @@ -49,7 +49,7 @@ from composio_openai import ComposioToolSet, App from openai import OpenAI openai_client = OpenAI() -composio_toolset = ComposioToolSet(entity_id="Jessica") +composio_toolset = ComposioToolSet(entity_id="default") ``` @@ -100,7 +100,7 @@ print(result) - We'll use **`Jessica`** as the user id [(entity id)](../../patterns/Auth/connected_account#entities). + We'll use **`default`** as the user id [(entity id)](../../patterns/Auth/connected_account#entities). You need to have an active GitHub Integration. Learn how to do this [here](https://youtu.be/LmyWy4LiedQ?si=u5uFArlNL0tew0Wf) ```shell CLI @@ -112,7 +112,7 @@ print(result) const client = new Composio({ apiKey: "" }); - const entity = await client.getEntity("Jessica"); + const entity = await client.getEntity("default"); const connection = await entity.initiateConnection({appName: 'github'}); console.log(`Open this URL to authenticate: ${connection.redirectUrl}`); diff --git a/docs/introduction/intro/quickstart-triggers.mdx b/docs/introduction/intro/quickstart-triggers.mdx index 03694cb9481..3a58a650de5 100644 --- a/docs/introduction/intro/quickstart-triggers.mdx +++ b/docs/introduction/intro/quickstart-triggers.mdx @@ -23,11 +23,11 @@ We'll use **`Jessica`** as the user id [(entity id)](../../patterns/Auth/connect ```shell CLI composio login -composio add gmail -e "Jessica" +composio add gmail -e "default" ``` ```python Python from composio_openai import ComposioToolSet, App, Trigger -toolset = ComposioToolSet(entity_id="Jessica") +toolset = ComposioToolSet(entity_id="default") request = toolset.initiate_connection(app=App.GMAIL) @@ -45,7 +45,7 @@ Don't forget to set your `COMPOSIO_API_KEY` and `OPENAI_API_KEY` in your environ composio triggers enable gmail_new_gmail_message ``` ```python Python -entity = toolset.get_entity(id="Jessica") +entity = toolset.get_entity(id="default") entity.enable_trigger( app=App.GMAIL, @@ -121,7 +121,7 @@ We'll use **`Jessica`** as the user id [(entity id)](../../patterns/Auth/connect ```shell CLI composio login -composio add gmail -e "Jessica" +composio add gmail -e "default" ``` ```javascript JavaScript import { OpenAIToolSet, Composio } from "composio-core"; @@ -132,7 +132,7 @@ const openai_client = new OpenAI(); const connectionRequest = await toolset.client.connectedAccounts.initiate({ appName: "gmail", - entityId: "Jessica", + entityId: "default", authMode: "OAUTH2", authConfig: {}, }); @@ -150,7 +150,7 @@ Don't forget to set your `COMPOSIO_API_KEY` and `OPENAI_API_KEY` in your environ composio triggers enable gmail_new_gmail_message ``` ```javascript JavaScript -const entity = toolset.client.getEntity("Jessica"); +const entity = toolset.client.getEntity("default"); const response = await entity.setupTrigger("gmail", "gmail_new_gmail_message", { userId: "me", diff --git a/docs/introduction/intro/quickstart_3_backup.mdx b/docs/introduction/intro/quickstart_3_backup.mdx index 3737856c84b..c9567be296c 100644 --- a/docs/introduction/intro/quickstart_3_backup.mdx +++ b/docs/introduction/intro/quickstart_3_backup.mdx @@ -45,13 +45,13 @@ Follow these 5 steps to list your emails as soon as you receive them: - We'll use **`Jessica`** as our example user. Choose your method: + We'll use **`default`** as our example user. Choose your method: ```bash Authenticate Gmail Account - composio add gmail -e "Jessica" # Launches Gmail login + composio add gmail -e "default" # Launches Gmail login ``` @@ -60,7 +60,7 @@ Follow these 5 steps to list your emails as soon as you receive them: ```python Authenticate Gmail Account from composio import ComposioToolSet, App - toolset = ComposioToolSet(entity_id="Jessica") + toolset = ComposioToolSet(entity_id="default") entity = toolset.get_entity() request = entity.initiate_connection(App.GMAIL) @@ -75,7 +75,7 @@ Follow these 5 steps to list your emails as soon as you receive them: const client = new Composio(process.env.COMPOSIO_API_KEY); - const entity = await client.getEntity("Jessica"); + const entity = await client.getEntity("default"); const connection = await entity.initiateConnection({appName: "gmail"}); console.log(`Open this URL to authenticate: ${connection.redirectUrl}`); @@ -110,7 +110,7 @@ Follow these 5 steps to list your emails as soon as you receive them: from composio import Composio, Action client = Composio() - entity = client.get_entity(id="Jessica") + entity = client.get_entity(id="default") # config is optional, it can be used to pass additional parameters for the trigger entity.enable_trigger(app=App.GMAIL, trigger_name="gmail_new_gmail_message", config={}) # Enable trigger diff --git a/docs/patterns/Auth/Integrations.mdx b/docs/patterns/Auth/Integrations.mdx index 7da87a8a3cd..18710eaa1ae 100644 --- a/docs/patterns/Auth/Integrations.mdx +++ b/docs/patterns/Auth/Integrations.mdx @@ -44,13 +44,13 @@ You can create an integration using the SDK by following the steps below: from composio import ComposioToolSet toolset = ComposioToolSet() -entity = toolset.get_entity("Jessica") +entity = toolset.get_entity("default") ``` ```javascript JavaScript import { Composio } from "composio-core"; const toolset = new Composio(); -const entity = toolset.getEntity("Jessica"); +const entity = toolset.getEntity("default"); ``` @@ -170,7 +170,7 @@ You can follow the same steps as mentioned in [Creating a new connection](/patte ```python Python from composio import ComposioToolSet -toolset = ComposioToolSet(entity_id="Jessica") +toolset = ComposioToolSet(entity_id="default") entity = toolset.get_entity() @@ -194,7 +194,7 @@ const connectionRequest = await toolset.client.connectedAccounts.initiate({ appName: "gmail", redirect_url: "https://yourwebsite.com/connection/success", integrationId: integration.id, - entityId:"Jessica" + entityId:"default" }); console.log(connectionRequest.redirectUrl); @@ -214,4 +214,4 @@ When creating an integration, you can use your own OAuth Developer App instead o When users connect using this integration, they'll see your app's name and logo in the OAuth consent screen instead of Composio's. Checkout the live demo [here](https://whitelabel-eight.vercel.app/) - \ No newline at end of file + diff --git a/docs/patterns/Auth/using-connections.mdx b/docs/patterns/Auth/using-connections.mdx index afbe6f6bb5e..fdb1dd42129 100644 --- a/docs/patterns/Auth/using-connections.mdx +++ b/docs/patterns/Auth/using-connections.mdx @@ -11,7 +11,7 @@ description: "Learn how to use connections" toolset = ComposioToolSet() # Filter based on entity id - entity = toolset.get_entity(id="Jessica") + entity = toolset.get_entity(id="default") try: # Lists all connections of the entity connected_accounts = entity.get_connections() @@ -24,7 +24,7 @@ description: "Learn how to use connections" const toolset = new OpenAIToolSet(); // Filter based on entity id - const entity = await toolset.client.getEntity("Jessica") + const entity = await toolset.client.getEntity("default") // lists all connections of the entity const connected_accounts = await entity.getConnections() @@ -46,7 +46,7 @@ description: "Learn how to use connections" toolset = ComposioToolSet() # Filter based on entity id - entity = toolset.get_entity(id="Jessica") + entity = toolset.get_entity(id="default") try: # Filters based on app name @@ -62,7 +62,7 @@ description: "Learn how to use connections" const toolset = new OpenAIToolSet(); // Filter based on entity id - const entity = await toolset.client.getEntity("Jessica") + const entity = await toolset.client.getEntity("default") // Filters based on app name const connectionDetails = await entity.getConnection({ appName: "GITHUB" }) @@ -152,4 +152,4 @@ Connected account raw auth params { You can fetch connection details after user is redirected back to your app (If redirect was needed) and `connectionStatus` & `connectedAccountId` will be available in the query params. - \ No newline at end of file + diff --git a/docs/patterns/tools/use-tools/action-guide-without-agents.mdx b/docs/patterns/tools/use-tools/action-guide-without-agents.mdx index 493a7ea13a1..c1887a54426 100644 --- a/docs/patterns/tools/use-tools/action-guide-without-agents.mdx +++ b/docs/patterns/tools/use-tools/action-guide-without-agents.mdx @@ -25,7 +25,7 @@ tool_set.execute_action( import { OpenAIToolSet } from "composio-core"; const toolset = new OpenAIToolSet(); -const entity = toolset.client.getEntity("Jessica"); +const entity = toolset.client.getEntity("default"); const result = await entity.execute({ actionName: "GITHUB_STAR_A_REPOSITORY_FOR_THE_AUTHENTICATED_USER", @@ -52,10 +52,11 @@ tool_set.execute_action( ``` ```javascript JavaScript -const result = await toolset.client.getEntity("Jessica").execute({ - actionName: "GITHUB_STAR_A_REPOSITORY_FOR_THE_AUTHENTICATED_USER", - // Natural language prompt - text: "Star the repo composiohq/composio", +const result = await toolset.client.getEntity("default").execute({ + actionName: "GITHUB_STAR_A_REPOSITORY_FOR_THE_AUTHENTICATED_USER", + params: {}, + // Natural language prompt + text: "Star the repo composiohq/composio" }); console.log(result); ``` From ab412aed916f2e85da1c70baa9be33ce4add32d8 Mon Sep 17 00:00:00 2001 From: Daniel <10074684+danieltprice@users.noreply.github.com> Date: Fri, 3 Jan 2025 16:59:40 -0400 Subject: [PATCH 5/5] Update sql-agent-python.mdx (#1153) --- docs/examples/combined/sql-agent-python.mdx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/examples/combined/sql-agent-python.mdx b/docs/examples/combined/sql-agent-python.mdx index b925dbdf8bc..1b66b1ac0f4 100644 --- a/docs/examples/combined/sql-agent-python.mdx +++ b/docs/examples/combined/sql-agent-python.mdx @@ -9,7 +9,7 @@ File operations and plot insightful graphs on the data in the db" This project involves setting up and running a system of agents to conduct SQL queries, write the output to a file, and plot graphs based on the data. We use Composio to set up the tools and OpenAI GPT-4o to power the agents. Follow this guide to set up and run the project. Note: This is a Python only example. JS version coming soon! - + Explore the complete source code for the SQL Agent project. This repository contains all the necessary files and scripts to set up and run the SQL Agent system using Langchain and Composio.