Custom Actions are powerful building blocks that enable you to create custom functionality while leveraging existing tool authentication.

Creating a Custom Action with Authentication

1

Install Dependencies

2

Import necessary modules & initialize them

3

Creating a custom action

Below are examples of creating a custom action called list_repositories (Python) & star_repo (JavaScript) that integrates with the github tool.

You need to add the action, input parameters & return content description, this is what the LLM will use to understand the action.

The execute_request/executeRequest method is used to make API calls, it accepts the following arguments:

  • endpoint: Endpoint URL. The base URL of the API will be prepended to this. You can find it in your connection’s Connection Info section
  • method: HTTP method to use
  • body: Request body to pass to the API
  • parameters: Custom Authentication Parameters
  • connection_id: ID of the connected account

Since github is a registered tool in Composio, the authentication credentials are automatically injected into your custom action!

4

Executing the Custom Action

Executing the custom action using LLM. Learn how to execute the custom action without LLM here.

How to Use Connection Parameters of an Account?

Connection Parameters of an account are available in the connected_account parameter of the custom action

Below is an example of the connection parameters for a GitHub account:

Why Use Custom Actions?

Custom Actions provide several advantages:

  • Data privacy: Execution happens on the user’s machine, ensuring sensitive data doesn’t leave the local environment.
  • Flexibility: Users can create and customize as many tools and actions as needed.
  • Compatibility: Custom actions can be integrated seamlessly across various Composio-supported platforms.