diff --git a/docs/introduction/foundations/components/integrations/custom-integration.mdx b/docs/introduction/foundations/components/integrations/custom-integration.mdx index 069897396df..8fd59097f7f 100644 --- a/docs/introduction/foundations/components/integrations/custom-integration.mdx +++ b/docs/introduction/foundations/components/integrations/custom-integration.mdx @@ -1,8 +1,8 @@ --- -title: "🔧 Crafting Custom Tools" -sidebarTitle: "Custom Tools" +title: "🔧 Custom Tools Using OpenAPI Spec" +sidebarTitle: "OpenAPI Tools" icon: "puzzle-piece" -description: "Explore the process of creating custom integrations with external Apps" +description: "Explore the process of creating custom tools with external Apps using OpenAPI Spec" --- Creating custom tools on Composio is straightforward and can be done via an [OpenAPI Spec](https://swagger.io/specification/). Here's a quick video on how you can add a custom integration to Composio using OpenAPI Spec. @@ -302,8 +302,4 @@ Navigate back to the tools catalogue page on Composio. Search for the tool you j - - -If you face any issues or found any bugs, join our Discord to chat with the team or write to us at tech@composio.dev. - -You can also add the actions to your custom tools. Click on the next article to read on how to create actions for your custom tool. + \ No newline at end of file diff --git a/docs/introduction/foundations/components/integrations/integration-guide.mdx b/docs/introduction/foundations/components/integrations/integration-guide.mdx index b1bd4530cf5..b7dfdefb271 100644 --- a/docs/introduction/foundations/components/integrations/integration-guide.mdx +++ b/docs/introduction/foundations/components/integrations/integration-guide.mdx @@ -7,10 +7,73 @@ description: "Allow your users to connect with any Apps." ## Overview of Integrations -Integrations allow users to link their accounts with external apps, enabling agents to take actions on their behalf. You can view all active integrations and monitor live connections or users by visiting the [Dashboard](https://app.composio.dev/your_apps). +Integrations allow users to link their accounts with external apps, enabling agents to take actions on their behalf. -Integrations are tool configurations (eg. Permissions to ask for when connecting an account, ClientID/Secret in the case of OAuth) that will be used to connect your users account to Composio. You can use your own configuration or use Composio's default integrations. +You can view all active integrations and monitor live connections or users by visiting the [Dashboard](https://app.composio.dev/your_apps). -Once an integration is established, it can be utilized by an **unlimited number of users** to connect their accounts. So ideally you will only build **one integration per tool or application** and **allow all your users to connect using it**. +Integrations are tool configurations (eg. Permissions to ask for when connecting an account, ClientID/Secret in the case of OAuth) that will be used to connect your users account to Composio. -To authenticate users with a specific tool, create a new integration by selecting the desired tool on the [Tools Page](https://app.composio.dev/apps). Integrations can be established using either default credentials or by registering a new developer application and setting the necessary authentication and permission scopes. \ No newline at end of file +You can use your own configuration or use Composio's default integrations. + +Once an integration is established, it can be utilized by an **unlimited number of users** to connect their accounts. + +So ideally you will only build **one integration per tool or application** and **allow all your users to connect using it**. + + +## Using Integration ID to Connect an Account for a user + + + +```python Connect a User's account using Integration ID +from composio import ComposioToolSet, App +from composio.client.exceptions import NoItemsFound + +toolset = ComposioToolSet() + +entity_id = "Jessica" # change this with your user_id +integration_id = "integration_id" + +entity = toolset.get_entity(id=entity_id) + +integration = toolset.client.integrations.get_by_id(integration_id=integration_id) + + +try: + connection = entity.get_connection(app=App.GITHUB) + # Connection Already exist with Github. + # Now we can check if it's using the correct integration + + if connection: + connection_integration_id = connection.integrationId + if connection_integration_id == integration_id: + # Connection is already active with the correct integration + print(f"User is already authenticated with GitHub") + else: + # Connection is active with a different integration + # TODO: Choose between the following options: + # 1. Create a new connection with the correct integration + # 2. Ignore as it's fine + print(f"User is already authenticated with GitHub but with a different integration") + + print(f"User is already authenticated with GitHub") + +except NoItemsFound as e: + # Create a request to initiate connection + request = entity.initiate_connection(App.GITHUB,integration=integration) + + print( + f"Please authenticate {App.GITHUB} in the browser and come back here. URL: {request.redirectUrl}" + ) + + # Poll until the connection is active + connected_account = request.wait_until_active(client=toolset.client, timeout=100) +``` + + + +coming soon! + + +coming soon! + + \ No newline at end of file diff --git a/docs/mint.json b/docs/mint.json index 0d37ce16b6a..95bf413c593 100644 --- a/docs/mint.json +++ b/docs/mint.json @@ -90,14 +90,13 @@ "introduction/foundations/components/actions/action-guide", "introduction/foundations/components/triggers/trigger-guide", "introduction/foundations/components/local_tools", + "introduction/foundations/components/integrations/custom-integration", { "group": "Advanced", "pages": [ - "introduction/foundations/components/actions/processing", "introduction/foundations/components/integrations/integration-guide", - "introduction/foundations/components/workspace", - "introduction/foundations/components/integrations/custom-integration" - + "introduction/foundations/components/actions/processing", + "introduction/foundations/components/workspace" ] } ]