@devries-cameron20 / composio-1 / commits / 515147540
Fork 0

Composio powers 1000+ toolkits, tool search, context management, authentication, and a sandboxed workbench to help you build AI agents that turn intent into action.

feat(ts): add trigger subscription example

jkomyno committed Jan 29, 2026 at 04:16 UTC 515147540f37cd82244d6741f23367ee456d2822
1 file changed +7 -2
ts/examples/triggers/src/subscribe.ts
+7 -2
@@ -5,14 +5,19 @@ const composio = new Composio({
5 apiKey: process.env.COMPOSIO_API_KEY,
6 });
7
8 +// create a trigger
9 +const { triggerId } = await composio.triggers.create('default','GMAIL_NEW_GMAIL_MESSAGE', {
10 + connectedAccountId: 'ca_uQvmu9uZOhQo',
11 + triggerConfig: {},
12 +});
13 +
14 // Subscribe to triggers with optional filters
9 -// Replace 'ti_ollBPgfhgmMK' with your actual trigger ID
15 const sub = await composio.triggers.subscribe(
16 metadata => {
17 console.log('Received trigger event:');
18 console.dir(metadata, { depth: 3 });
19 },
15 - { triggerId: 'ti_ollBPgfhgmMK' }
20 + { triggerId }
21 );
22
23 console.log('Subscribed to triggers. Waiting for events...');