Install and connect Gmail
Use Python 3.12 or Node.js 24 and a disposable Composio project. The setup script registers a project-wide webhook URL; if a subscription already exists, it updates that subscription.- Python
- TypeScript
8000. Use one of the local webhook forwarding options to get a public HTTPS URL that forwards to that port. Keep the forwarding process running and set the full endpoint URL:
- Python
- TypeScript
- API
setup.py
- Python
- TypeScript
- API
composio.triggers.get_type("GMAIL_NEW_GMAIL_MESSAGE") before creating it, as described in creating triggers.
Verify the event and run the agent
Save the handler asserver.py or server.ts. Both versions process one request at a time and acknowledge the webhook after storing the summary. Keep the database file between restarts to preserve completed event IDs. Signature verification and the OpenAI agent loop run in your application, not through a Composio REST endpoint.
- Python
- TypeScript
server.py
- Python
- TypeScript
id. The normalized event["id"] (Python) or event.id (TypeScript) identifies the trigger instance, which is shared by many emails and must not be used to deduplicate messages.
Test delivery
First, send an unsigned request. It should return401 without running the agent:
Saved summary for event ....
Inspect the stored summary from a second terminal:
- Python
- TypeScript
8000, and the server uses the secret from the same project subscription. See receiving events.
Stop the demo and prepare for production
Delete the trigger when you finish testing:- Python
- TypeScript
- API
2xx, then run the agent in a worker. This local server waits for the model and can exceed the webhook delivery timeout. Its SQLite deduplication prevents repeat runs after a completed write, but a crash between model execution and that write can run the model again.
For multiple users, resolve the signed event’s account ID through your stored account-to-user mapping. Keep the same session account pinning and tool restriction. See consumer agent architecture for the ownership model.