Triggers
Triggers monitor specific events in apps and notify your AI agents via webhooks or websockets. They send in relevant data that your agents can act upon.
Use gpt-4.5
to reply in greentexts to Slack messages.
Make sure you’ve created an integration and a connection to your Slack account.
Learn how to manage integrations and connected accounts.
Managing triggers
Dashboard
CLI
Code
Head to the Slack app in the dashboard and enable the “New Message Recieved” trigger
Some triggers expect certain configuration in order to set the correct events. You can inspect and add these properties while enabling the triggers!
Listeners
Once you have the triggers set up, you can specify listener functions using websockets through the SDK or webhooks.
Specifying Listeners through Websockets
We create a listener and then define a callback function that executes when a listener recieves a payload.
Specifying Listeners through Webhooks
Assuming you’ve already set up a trigger as discussed in previous steps, here’s how you can use webhooks instead to listen in on new events happening in an app.
Configure Webhook URL
To receive trigger events via webhooks, you need to configure a publicly accessible URL where Composio can send the event payloads. This URL should point to an endpoint in your application that can process incoming webhook requests.
Listening on the webhooks
To demonstrate, here’s a FastAPI server to handle incoming webhook requests.
Demo: Roast Slack Messages
Let’s build a fun bot that generates snarky greentext responses to Slack messages using gpt-4.5
.
Implement Response Generation
Create a function to generate snarky responses using gpt-4.5
. We’ll also set up a preprocessor to handle Slack-specific message parameters:
Configure the tools
Set up the tools for sending Slack messages. We attach our preprocessor to automatically handle message threading and formatting:
The preprocessor ensures that every message is automatically configured with the correct thread, channel, and formatting settings, reducing the chance of misconfigured responses.
Run your server locally and use ngrok to expose it:
Remember to update your webhook URL in the Composio dashboard with your ngrok URL.
Troubleshooting
If you encounter issues with triggers or webhook listeners, you can use the Composio dashboard to inspect detailed trigger logs. The dashboard allows you to review event payloads, identify errors, and manually resend events for testing purposes.
Access the trigger logs here