@devries-cameron20 / composio Mirror · read-only
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.

Mirrored from https://github.com/Camo67/composio.git

Synced Nov 21, 06:00 UTC

next
md 80 lines 2 KB
Rendered Raw
1 # Triggers Example
2
3 This example demonstrates how to use Composio SDK for triggers.
4
5 ## Setup
6
7 1. **Install dependencies:**
8 ```bash
9 pnpm install
10 ```
11
12 2. **Configure environment:**
13 ```bash
14 cp .env.example .env
15 ```
16
17 Then edit `.env` and add your API keys:
18 - `COMPOSIO_API_KEY`: Get it from [Composio Dashboard](https://app.composio.dev)
19 - `COMPOSIO_WEBHOOK_SECRET`: Get it from your webhook configuration in Composio Dashboard
20
21 ## Running the Examples
22
23 ### Trigger Subscription (WebSocket)
24
25 ```bash
26 # Run the subscription example
27 pnpm start
28
29 # Run in development mode (with file watching)
30 pnpm dev
31 ```
32
33 ### Webhook Server (HTTP)
34
35 ```bash
36 # Start the webhook verification server
37 pnpm webhook:server
38
39 # Then expose it with telebit (https://telebit.cloud/)
40 telebit http 3000
41 ```
42
43 ## What This Example Does
44
45 ### `src/index.ts` - Trigger Subscription
46 - Initializes Composio SDK
47 - Subscribes to triggers via WebSocket
48 - Receives real-time trigger events
49
50 ### `src/webhook-server.ts` - Webhook Verification
51 - Starts a Bun HTTP server on port 3000
52 - Verifies incoming webhook signatures using the new `verifyWebhook` API
53 - Supports V1, V2, and V3 webhook payload formats
54 - Returns normalized trigger events
55
56 ## Webhook Headers
57
58 When receiving webhooks, the following headers are used:
59 - `webhook-id`: Unique message ID (format: `msg_xxx`)
60 - `webhook-timestamp`: Unix timestamp in seconds
61 - `webhook-signature`: Signature in format `v1,base64EncodedSignature`
62
63 ## Customization
64
65 Edit `src/index.ts` or `src/webhook-server.ts` to:
66 - Add specific apps you want to integrate with
67 - Implement your business logic
68 - Add error handling and logging
69
70 ## Related Examples
71
72 - [OpenAI Example](../openai) - Shows integration with OpenAI
73 - [LangChain Example](../langchain) - Shows integration with LangChain
74 - [More Examples](../) - Browse all available examples
75
76 ## Support
77
78 - [Documentation](https://docs.composio.dev)
79 - [Discord Community](https://discord.gg/composio)
80 - [GitHub Issues](https://github.com/ComposioHQ/composio/issues)