Composio powers 1000+ toolkits, tool search, context management, authentication, and a sandboxed workbench to help you build AI agents that turn intent into action.
Mirrored from https://github.com/Camo67/composio.git
Synced Nov 22, 23:15 UTC
docs: update migration guide and add new trigger snippets
balyan.sid@gmail.com committed
Jun 25, 2025 at 21:07 UTC
b5eb33426b3147d670eabbe0fe17ad5b7c9cf5d8
4 files changed
+104
-24
fern/pages/src/migration-guide.mdx
+32
-22
@@ -478,24 +478,19 @@ Composio continues to support listening to application events using triggers thr
478
479
The process for creating triggers and specifying their configuration has been redesigned for improved clarity and intuitiveness.
480
481
-Some triggers require configuration, such as repository names for GitHub triggers or channel names for Slack triggers. You can view the configuration for a trigger as follows:
481
+Some triggers require configuration, such as repository names for GitHub triggers or channel names for Slack triggers. The process usually follows the pattern of fetching the trigger type and then creating the trigger with the appropriate configuration.
482
483
<CodeGroup>
484
<SnippetCode
485
- src="fern/snippets/typescript/triggers.ts"
485
+ src="fern/snippets/migration/new_triggers.py"
486
startLine={1}
487
- endLine={27}
488
- title="TypeScript (current)"
487
+ endLine={33}
488
+ title="Python (current)"
489
/>
490
-</CodeGroup>
491
-
492
-You can then create the trigger with the appropriate configuration:
493
-
494
-<CodeGroup>
490
<SnippetCode
496
- src="fern/snippets/typescript/triggers.ts"
497
- startLine={28}
498
- endLine={40}
491
+ src="fern/snippets/migration/new_triggers.ts"
492
+ startLine={1}
493
+ endLine={35}
494
title="TypeScript (current)"
495
/>
496
</CodeGroup>
@@ -507,12 +502,27 @@ You can enable or disable triggers through either the SDK or the dashboard. The
502
Managing triggers with the SDK:
503
504
<CodeGroup>
510
-<SnippetCode
511
- src="fern/snippets/typescript/triggers.ts"
512
- startLine={55}
513
- endLine={56}
514
- title="TypeScript (current)"
515
-/>
505
+ ```python Python maxLines=60 wordWrap
506
+ # Disable a trigger instance
507
+ disabled_instance = composio.triggers.disable(trigger_id="ti_abcd123")
508
+ print(disabled_instance)
509
+ ```
510
+ ```typescript TypeScript maxLines=60 wordWrap
511
+ await composio.triggers.disable("ti_abcd123");
512
+ ```
513
+</CodeGroup>
514
+
515
+If needed, the trigger can be enabled again.
516
+
517
+<CodeGroup>
518
+ ```python Python maxLines=60 wordWrap
519
+ # Enable a trigger instance
520
+ enabled_instance = composio.triggers.enable(trigger_id="ti_abcd123")
521
+ print(enabled_instance)
522
+ ```
523
+ ```typescript TypeScript maxLines=60 wordWrap
524
+ await composio.triggers.enable("ti_abcd123");
525
+ ```
526
</CodeGroup>
527
528
#### Listening to triggers
@@ -523,12 +533,12 @@ For development, you can also [listen to triggers through the SDK](/docs/using-t
533
534
<CodeGroup>
535
<SnippetCode
526
- src="fern/snippets/typescript/trigger-webhook.ts"
527
- title="app/api/webhook/route.ts (Next.js)"
536
+ src="fern/snippets/triggers/python/trigger-webhook.py"
537
+ title="app/route.py (FastAPI)"
538
/>
539
<SnippetCode
530
- src="fern/snippets/python/trigger-webhook.py"
531
- title="app/route.py (FastAPI)"
540
+ src="fern/snippets/triggers/typescript/trigger-webhook.ts"
541
+ title="app/api/webhook/route.ts (Next.js)"
542
/>
543
</CodeGroup>
544
fern/snippets/migration/new_triggers.py
new
+36
@@ -0,0 +1,36 @@
1
+from composio import Composio
2
+
3
+composio = Composio()
4
+
5
+user_id = "user@example.com"
6
+trigger_config = composio.triggers.get_type("GITHUB_COMMIT_EVENT")
7
+print(trigger_config.config)
8
+### Trigger Config
9
+# {
10
+# "properties": {
11
+# "owner": {
12
+# "description": "Owner of the repository",
13
+# "title": "Owner",
14
+# "type": "string"
15
+# },
16
+# "repo": {
17
+# "description": "Repository name",
18
+# "title": "Repo",
19
+# "type": "string"
20
+# }
21
+# },
22
+# "required": ["owner", "repo"],
23
+# "title": "WebhookConfigSchema",
24
+# "type": "object"
25
+
26
+trigger = composio.triggers.create(
27
+ slug="GITHUB_COMMIT_EVENT",
28
+ user_id=user_id,
29
+ trigger_config={"repo": "composiohq", "owner": "composio"},
30
+)
31
+print(trigger)
32
+
33
+
34
+# Managing triggers
35
+
36
+composio.triggers.enable(id="ti_abcd123")
\ No newline at end of file
fern/snippets/migration/new_triggers.ts
new
+35
@@ -0,0 +1,35 @@
1
+import { Composio } from '@composio/core';
2
+
3
+const composio = new Composio();
4
+
5
+const userId = 'user@acme.com';
6
+// Fetch the trigger details
7
+const triggerType = await composio.triggers.getType('GITHUB_COMMIT_EVENT');
8
+console.log(JSON.stringify(triggerType.config, null, 2));
9
+/*--- Trigger config ---
10
+{
11
+ "properties": {
12
+ "owner": {
13
+ "description": "Owner of the repository",
14
+ "title": "Owner",
15
+ "type": "string"
16
+ },
17
+ "repo": {
18
+ "description": "Repository name",
19
+ "title": "Repo",
20
+ "type": "string"
21
+ }
22
+ },
23
+ "required": ["owner", "repo"],
24
+ "title": "WebhookConfigSchema",
25
+ "type": "object"
26
+}
27
+*/
28
+
29
+const createResponse = await composio.triggers.create(userId, 'GITHUB_COMMIT_EVENT', {
30
+ triggerConfig: {
31
+ owner: 'composiohq',
32
+ repo: 'composio',
33
+ },
34
+});
35
+console.log(createResponse);
\ No newline at end of file
fern/snippets/triggers/python/triggers.py
+1
-2
@@ -29,5 +29,4 @@ print(trigger_config.config)
29
# },
30
# "required": ["owner", "repo"],
31
# "title": "WebhookConfigSchema",
32
-# "type": "object"
33
-# }
\ No newline at end of file
32
+# "type": "object"
\ No newline at end of file