Custom Actions are powerful building blocks that enable you to create custom functionality while leveraging existing tool authentication. They can handle everything from simple data processing to complex third-party integrations, either using a pre-configured tool authentication or running independently.

Creating a Custom Action with Authentication

1

Import necessary modules

2

Creating a custom action

Below is an example of creating a custom action called my_custom_action that integrates with the gmail tool. This action demonstrates how to fetch emails from the last 24 hours while utilizing Composio’s built-in Gmail authentication.

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

3

Executing the Custom Action

Executing the custom action without Agents (it can be used with agents too)

Output from executing Custom Action

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.