Prerequisites

  1. Get the trigger name and required config from the UI: This step is common across all users.
  2. Set the webhook URL: This should be done once for a Composio account.
  3. Enable the trigger for the user: This is done for each user.

Step 1: Set Up the Composio Client

First, initialize the Composio client using your API key.

Step 2: Define User and Trigger Information

Specify the user and trigger details. Replace entity_id and selected_app with the relevant user ID and app.

Step 3: Retrieve User Entity and Connection

Get the user entity and check the connection to the specified app.

Step 4: Retrieve and Verify Trigger

Fetch the trigger using its name and verify if it exists.

Step 5: Check for Active Triggers

Check if the trigger is already enabled for the user.

Step 6: Enable the Trigger

Enable the trigger for the user with the specified configuration.

Ensuring the User is Connected to the App

If the user is not connected to the app, the connection must be established. The following script helps to ensure the user is connected.

Conclusion

By following these steps, you can efficiently enable a specific trigger for a user in Composio, ensuring that the necessary app connections are established and maintained. This guide provides a structured approach to managing triggers and connections, enhancing the capabilities of your Composio setup.