@composio/core 0.11.0 → 0.13.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/BaseProvider-BBnsv9kS.d.mts +29425 -0
- package/dist/{BaseProvider-CVbQxTNa.d.cts → BaseProvider-Brb3o86-.d.mts} +91 -44
- package/dist/CustomTool-D9qwyMrv.mjs +468 -0
- package/dist/{CustomTool-C-IUByoU.d.cts → CustomTool-Dmi6ti3I.d.mts} +2 -4
- package/dist/{CustomTool-CChQSp44.d.mts → CustomTool-DrJpOhY2.d.mts} +2 -4
- package/dist/{FileModifierErrors-C7z16Dfi.mjs → FileModifierErrors-3fSwIWoa.mjs} +35 -36
- package/dist/{Telemetry-DQax33Gh.mjs → Telemetry-DhGI_J4G.mjs} +15 -15
- package/dist/{composio-pcA13w87.d.cts → composio-DHIKRdeG.d.mts} +641 -380
- package/dist/{composio-BlASKqjQ.d.mts → composio-vMwhASRc.d.mts} +1390 -1129
- package/dist/{customTool.types-QtkAZQma.d.cts → customTool.types-CKH2R2ia.d.mts} +487 -189
- package/dist/{customTool.types-DLIORcYN.d.mts → customTool.types-DXin7Cfc.d.mts} +924 -626
- package/dist/docs/error-consistency.md +97 -0
- package/dist/docs/reference/sdk-reference/typescript/auth-configs.mdx +306 -0
- package/dist/docs/reference/sdk-reference/typescript/composio.mdx +205 -0
- package/dist/docs/reference/sdk-reference/typescript/connected-accounts.mdx +488 -0
- package/dist/docs/reference/sdk-reference/typescript/experimental.mdx +94 -0
- package/dist/docs/reference/sdk-reference/typescript/index.mdx +67 -0
- package/dist/docs/reference/sdk-reference/typescript/mcp.mdx +304 -0
- package/dist/docs/reference/sdk-reference/typescript/meta.json +17 -0
- package/dist/docs/reference/sdk-reference/typescript/remote-file.mdx +107 -0
- package/dist/docs/reference/sdk-reference/typescript/session-files.mdx +163 -0
- package/dist/docs/reference/sdk-reference/typescript/session.mdx +229 -0
- package/dist/docs/reference/sdk-reference/typescript/sessions.mdx +131 -0
- package/dist/docs/reference/sdk-reference/typescript/toolkits.mdx +169 -0
- package/dist/docs/reference/sdk-reference/typescript/tools.mdx +453 -0
- package/dist/docs/reference/sdk-reference/typescript/triggers.mdx +434 -0
- package/dist/{CustomTool-D5s-aADw.mjs → errors-DSIlYfl5.mjs} +72 -459
- package/dist/experimental/index.d.mts +2 -3
- package/dist/experimental/index.mjs +1 -3
- package/dist/{fileUtils.node-Dq7ebZPC.mjs → fileUtils.node-BiO1JQsJ.mjs} +26 -25
- package/dist/index.d.mts +1708 -2400
- package/dist/index.mjs +2632 -2006
- package/dist/jsonSchema-CFKdONpP.mjs +251 -0
- package/dist/models/Files.node.d.mts +1 -2
- package/dist/models/Files.node.mjs +3 -4
- package/dist/models/Files.workerd.d.mts +0 -1
- package/dist/platform/node.d.mts +1 -2
- package/dist/platform/workerd.d.mts +1 -2
- package/dist/{chunk-CWQeghP5.mjs → rolldown-runtime-w6R9maHv.mjs} +3 -5
- package/dist/{types-J2KCXP8R.d.mts → types-D4Id3wXA.d.mts} +2 -3
- package/dist/{types-DRG5qLxI.d.cts → types-qTbYYBJw.d.mts} +2 -3
- package/dist/utils/config-defaults/ConfigDefaults.node.d.mts +1 -4
- package/dist/utils/config-defaults/ConfigDefaults.workerd.d.mts +1 -4
- package/dist/utils/config-defaults/ConfigDefaults.workerd.mjs +3 -0
- package/dist/utils/json-schema.d.mts +2 -0
- package/dist/utils/json-schema.mjs +3 -0
- package/dist/utils/modifiers/FileToolModifier.node.d.mts +3 -1
- package/dist/utils/modifiers/FileToolModifier.node.mjs +44 -24
- package/dist/utils/modifiers/FileToolModifier.workerd.d.mts +3 -1
- package/dist/utils/modifiers/FileToolModifier.workerd.mjs +1 -1
- package/docs/error-consistency.md +97 -0
- package/package.json +40 -88
- package/src/composio.ts +509 -0
- package/src/errors/AuthConfigErrors.ts +23 -0
- package/src/errors/ComposioError.ts +408 -0
- package/src/errors/ConnectedAccountsErrors.ts +158 -0
- package/src/errors/ConnectionRequestErrors.ts +32 -0
- package/src/errors/FileModifierErrors.ts +100 -0
- package/src/errors/PusherErrors.ts +28 -0
- package/src/errors/RemoteFileErrors.ts +62 -0
- package/src/errors/SDKErrors.ts +92 -0
- package/src/errors/ToolErrors.ts +244 -0
- package/src/errors/ToolkitErrors.ts +39 -0
- package/src/errors/TriggerErrors.ts +120 -0
- package/src/errors/ValidationErrors.ts +99 -0
- package/src/errors/index.ts +41 -0
- package/src/experimental/index.ts +28 -0
- package/src/index.ts +64 -0
- package/src/lib/toolRouterConstants.ts +1 -0
- package/src/lib/toolRouterParams.ts +306 -0
- package/src/models/AuthConfigs.ts +398 -0
- package/src/models/AuthScheme.ts +206 -0
- package/src/models/ConnectedAccounts.ts +735 -0
- package/src/models/ConnectionRequest.ts +150 -0
- package/src/models/CustomTool.ts +676 -0
- package/src/models/Experimental.ts +202 -0
- package/src/models/Files.node.ts +93 -0
- package/src/models/Files.workerd.ts +49 -0
- package/src/models/MCP.ts +478 -0
- package/src/models/RemoteFile.ts +172 -0
- package/src/models/SessionContext.ts +147 -0
- package/src/models/Sessions.ts +21 -0
- package/src/models/ToolRouter.ts +391 -0
- package/src/models/ToolRouterSession.ts +827 -0
- package/src/models/ToolRouterSessionFileMount.ts +389 -0
- package/src/models/Toolkits.ts +412 -0
- package/src/models/Tools.ts +1260 -0
- package/src/models/Triggers.ts +1381 -0
- package/src/models/customToolExecution.ts +118 -0
- package/src/models/inlineCustomToolsPayload.ts +17 -0
- package/src/models/proxyParamsTransform.ts +26 -0
- package/src/provider/BaseProvider.ts +138 -0
- package/src/provider/ComposioProvider.ts +29 -0
- package/src/provider/OpenAIProvider.ts +547 -0
- package/src/services/internal/InternalService.ts +50 -0
- package/src/services/internal/InternalService.types.ts +14 -0
- package/src/services/pusher/Pusher.ts +230 -0
- package/src/services/telemetry/TelemetryService.ts +48 -0
- package/src/services/telemetry/TelemetryService.types.ts +67 -0
- package/src/telemetry/BatchProcessor.ts +77 -0
- package/src/telemetry/README.md +123 -0
- package/src/telemetry/Telemetry.ts +356 -0
- package/src/types/ToolRouterSessionFilesMount.types.ts +96 -0
- package/src/types/authConfigs.types.ts +174 -0
- package/src/types/composio.types.ts +1 -0
- package/src/types/connectedAccountAuthStates.types.ts +852 -0
- package/src/types/connectedAccounts.types.ts +395 -0
- package/src/types/connectionRequest.types.ts +16 -0
- package/src/types/customTool.types.ts +261 -0
- package/{dist/files.types-lo4zZd87.d.cts → src/types/files.types.ts} +3 -5
- package/src/types/mcp.experimental.types.ts +163 -0
- package/src/types/mcp.types.ts +362 -0
- package/src/types/modifiers.types.ts +663 -0
- package/src/types/org.types.ts +0 -0
- package/src/types/provider.types.ts +41 -0
- package/src/types/pusher.types.ts +18 -0
- package/src/types/requestOptions.types.ts +62 -0
- package/src/types/telemetry.types.ts +89 -0
- package/src/types/tool.types.ts +408 -0
- package/src/types/toolRouter.types.ts +761 -0
- package/src/types/toolkit.types.ts +130 -0
- package/src/types/triggers.types.ts +401 -0
- package/src/types/webhookEvents.types.ts +219 -0
- package/src/utils/buffer.ts +30 -0
- package/src/utils/cancellation.ts +22 -0
- package/src/utils/config-defaults/ConfigDefaults.node.ts +7 -0
- package/src/utils/config-defaults/ConfigDefaults.workerd.ts +10 -0
- package/src/utils/config-defaults/index.ts +1 -0
- package/src/utils/config-defaults/types.ts +14 -0
- package/src/utils/constants.ts +22 -0
- package/src/utils/crypto.ts +34 -0
- package/src/utils/env.ts +34 -0
- package/src/utils/fileDirs.ts +81 -0
- package/src/utils/fileUtils.node.ts +458 -0
- package/src/utils/json-schema.ts +1 -0
- package/src/utils/jsonSchema.ts +355 -0
- package/src/utils/logger.ts +99 -0
- package/src/utils/mime.ts +75 -0
- package/src/utils/modifiers/FileToolModifier.node.ts +477 -0
- package/src/utils/modifiers/FileToolModifier.utils.neutral.ts +132 -0
- package/src/utils/modifiers/FileToolModifier.workerd.ts +51 -0
- package/src/utils/pagination.ts +73 -0
- package/src/utils/pusher.ts +286 -0
- package/src/utils/schemaPropertyKeys.ts +433 -0
- package/src/utils/sdk.ts +110 -0
- package/src/utils/sensitiveFileUploadPaths.node.ts +105 -0
- package/src/utils/session.ts +114 -0
- package/src/utils/toolArguments.ts +73 -0
- package/src/utils/toolkitVersion.ts +26 -0
- package/src/utils/transform.ts +42 -0
- package/src/utils/transformers/authConfigs.ts +107 -0
- package/src/utils/transformers/connectedAccounts.ts +119 -0
- package/src/utils/transformers/mcp.ts +164 -0
- package/src/utils/transformers/toolRouterResponseTransform.ts +160 -0
- package/src/utils/transformers/toolkits.ts +100 -0
- package/src/utils/transformers/triggers.ts +118 -0
- package/src/utils/uploadDirAllowlist.node.ts +178 -0
- package/src/utils/uuid.ts +7 -0
- package/src/utils/version.ts +58 -0
- package/src/utils/zodSchema.ts +90 -0
- package/dist/BaseProvider-BvHvJLXc.d.mts +0 -29378
- package/dist/CustomTool-D3-NreIm.cjs +0 -1341
- package/dist/FileModifierErrors-BYJBHiay.cjs +0 -554
- package/dist/FileToolModifier.utils.neutral-DSBQs9-i.cjs +0 -96
- package/dist/Telemetry-BQ_pl5AK.cjs +0 -360
- package/dist/buffer-BjWptbNH.cjs +0 -63
- package/dist/chunk-CQwRTUmo.cjs +0 -53
- package/dist/experimental/index.cjs +0 -5
- package/dist/experimental/index.d.cts +0 -3
- package/dist/fileUtils.node-DtnSRMWa.cjs +0 -462
- package/dist/index.cjs +0 -8523
- package/dist/index.d.cts +0 -6065
- package/dist/models/Files.node.cjs +0 -55
- package/dist/models/Files.node.d.cts +0 -56
- package/dist/models/Files.workerd.cjs +0 -29
- package/dist/models/Files.workerd.d.cts +0 -13
- package/dist/platform/node.cjs +0 -55
- package/dist/platform/node.d.cts +0 -11
- package/dist/platform/workerd.cjs +0 -42
- package/dist/platform/workerd.d.cts +0 -12
- package/dist/types-pDNm1lYs.d.cts +0 -69
- package/dist/utils/config-defaults/ConfigDefaults.node.cjs +0 -10
- package/dist/utils/config-defaults/ConfigDefaults.node.d.cts +0 -7
- package/dist/utils/config-defaults/ConfigDefaults.workerd.cjs +0 -10
- package/dist/utils/config-defaults/ConfigDefaults.workerd.d.cts +0 -7
- package/dist/utils/modifiers/FileToolModifier.node.cjs +0 -224
- package/dist/utils/modifiers/FileToolModifier.node.d.cts +0 -22
- package/dist/utils/modifiers/FileToolModifier.workerd.cjs +0 -27
- package/dist/utils/modifiers/FileToolModifier.workerd.d.cts +0 -20
- /package/dist/{FileToolModifier.utils.neutral-BpSceNK8.mjs → FileToolModifier.utils.neutral-B5rT711M.mjs} +0 -0
- /package/dist/{buffer-yOtEsT4J.mjs → buffer-PcbMMsgm.mjs} +0 -0
- /package/dist/{files.types-BXDWA_zS.d.mts → files.types-DeMC_mAW.d.mts} +0 -0
- /package/dist/{types-HpJQ8K9l.d.mts → types-DdoCRzLj.d.mts} +0 -0
|
@@ -0,0 +1,434 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: "Triggers"
|
|
3
|
+
description: "Trigger (Instance) class"
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
## Usage
|
|
7
|
+
|
|
8
|
+
Access this class through the `composio.triggers` property:
|
|
9
|
+
|
|
10
|
+
```typescript
|
|
11
|
+
const composio = new Composio({ apiKey: 'your-api-key' });
|
|
12
|
+
const result = await composio.triggers.list();
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## Methods
|
|
16
|
+
|
|
17
|
+
### create()
|
|
18
|
+
|
|
19
|
+
Create a new trigger instance for a user
|
|
20
|
+
If the connected account id is not provided, the first connected account for the user and toolkit will be used
|
|
21
|
+
|
|
22
|
+
```typescript
|
|
23
|
+
async create(userId: string, slug: string, body?: TriggerInstanceUpsertParams, requestOptions?: ComposioRequestOptions): Promise<TriggerInstanceUpsertResponse>
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
**Parameters**
|
|
27
|
+
|
|
28
|
+
| Name | Type | Description |
|
|
29
|
+
|------|------|-------------|
|
|
30
|
+
| `userId` | `string` | The user id of the trigger instance |
|
|
31
|
+
| `slug` | `string` | The slug of the trigger instance |
|
|
32
|
+
| `body?` | `TriggerInstanceUpsertParams` | The parameters to create the trigger instance |
|
|
33
|
+
| `requestOptions?` | `ComposioRequestOptions` | |
|
|
34
|
+
|
|
35
|
+
**Returns**
|
|
36
|
+
|
|
37
|
+
`Promise<TriggerInstanceUpsertResponse>` — The created trigger instance
|
|
38
|
+
|
|
39
|
+
---
|
|
40
|
+
|
|
41
|
+
### delete()
|
|
42
|
+
|
|
43
|
+
Delete a trigger instance
|
|
44
|
+
|
|
45
|
+
```typescript
|
|
46
|
+
async delete(triggerId: string, requestOptions?: ComposioRequestOptions): Promise<TriggerInstanceManageDeleteResponse>
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
**Parameters**
|
|
50
|
+
|
|
51
|
+
| Name | Type | Description |
|
|
52
|
+
|------|------|-------------|
|
|
53
|
+
| `triggerId` | `string` | The slug of the trigger instance |
|
|
54
|
+
| `requestOptions?` | `ComposioRequestOptions` | |
|
|
55
|
+
|
|
56
|
+
**Returns**
|
|
57
|
+
|
|
58
|
+
`Promise<TriggerInstanceManageDeleteResponse>`
|
|
59
|
+
|
|
60
|
+
---
|
|
61
|
+
|
|
62
|
+
### disable()
|
|
63
|
+
|
|
64
|
+
Disable a trigger instance
|
|
65
|
+
|
|
66
|
+
```typescript
|
|
67
|
+
async disable(triggerId: string, requestOptions?: ComposioRequestOptions): Promise<ManageUpdateResponse>
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
**Parameters**
|
|
71
|
+
|
|
72
|
+
| Name | Type | Description |
|
|
73
|
+
|------|------|-------------|
|
|
74
|
+
| `triggerId` | `string` | The id of the trigger instance |
|
|
75
|
+
| `requestOptions?` | `ComposioRequestOptions` | |
|
|
76
|
+
|
|
77
|
+
**Returns**
|
|
78
|
+
|
|
79
|
+
`Promise<ManageUpdateResponse>` — The updated trigger instance
|
|
80
|
+
|
|
81
|
+
---
|
|
82
|
+
|
|
83
|
+
### enable()
|
|
84
|
+
|
|
85
|
+
Enable a trigger instance
|
|
86
|
+
|
|
87
|
+
```typescript
|
|
88
|
+
async enable(triggerId: string, requestOptions?: ComposioRequestOptions): Promise<ManageUpdateResponse>
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
**Parameters**
|
|
92
|
+
|
|
93
|
+
| Name | Type | Description |
|
|
94
|
+
|------|------|-------------|
|
|
95
|
+
| `triggerId` | `string` | The id of the trigger instance |
|
|
96
|
+
| `requestOptions?` | `ComposioRequestOptions` | |
|
|
97
|
+
|
|
98
|
+
**Returns**
|
|
99
|
+
|
|
100
|
+
`Promise<ManageUpdateResponse>` — The updated trigger instance
|
|
101
|
+
|
|
102
|
+
---
|
|
103
|
+
|
|
104
|
+
### getType()
|
|
105
|
+
|
|
106
|
+
Retrieve a trigger type by its slug for the provided version of the app
|
|
107
|
+
Use the global toolkit versions param when initializing composio to pass a toolkitversion
|
|
108
|
+
|
|
109
|
+
```typescript
|
|
110
|
+
async getType(slug: string, requestOptions?: ComposioRequestOptions): Promise<TriggersTypeRetrieveResponse>
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
**Parameters**
|
|
114
|
+
|
|
115
|
+
| Name | Type | Description |
|
|
116
|
+
|------|------|-------------|
|
|
117
|
+
| `slug` | `string` | The slug of the trigger type |
|
|
118
|
+
| `requestOptions?` | `ComposioRequestOptions` | |
|
|
119
|
+
|
|
120
|
+
**Returns**
|
|
121
|
+
|
|
122
|
+
`Promise<TriggersTypeRetrieveResponse>` — The trigger type object
|
|
123
|
+
|
|
124
|
+
---
|
|
125
|
+
|
|
126
|
+
### listActive()
|
|
127
|
+
|
|
128
|
+
Fetch list of all the active triggers
|
|
129
|
+
|
|
130
|
+
```typescript
|
|
131
|
+
async listActive(query?: TriggerInstanceListActiveParams, requestOptions?: ComposioRequestOptions): Promise<TriggerInstanceListActiveResponse>
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
**Parameters**
|
|
135
|
+
|
|
136
|
+
| Name | Type | Description |
|
|
137
|
+
|------|------|-------------|
|
|
138
|
+
| `query?` | `TriggerInstanceListActiveParams` | The query parameters to filter the trigger instances |
|
|
139
|
+
| `requestOptions?` | `ComposioRequestOptions` | |
|
|
140
|
+
|
|
141
|
+
**Returns**
|
|
142
|
+
|
|
143
|
+
`Promise<TriggerInstanceListActiveResponse>` — List of trigger instances
|
|
144
|
+
|
|
145
|
+
**Example**
|
|
146
|
+
|
|
147
|
+
```typescript
|
|
148
|
+
const triggers = await triggers.listActive({
|
|
149
|
+
authConfigIds: ['123'],
|
|
150
|
+
connectedAccountIds: ['456'],
|
|
151
|
+
});
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
---
|
|
155
|
+
|
|
156
|
+
### listEnum()
|
|
157
|
+
|
|
158
|
+
Fetches the list of all the available trigger enums
|
|
159
|
+
|
|
160
|
+
This method is used by the CLI where filters are not required.
|
|
161
|
+
|
|
162
|
+
```typescript
|
|
163
|
+
async listEnum(requestOptions?: ComposioRequestOptions): Promise<TriggersTypeRetrieveEnumResponse>
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
**Parameters**
|
|
167
|
+
|
|
168
|
+
| Name | Type |
|
|
169
|
+
|------|------|
|
|
170
|
+
| `requestOptions?` | `ComposioRequestOptions` |
|
|
171
|
+
|
|
172
|
+
**Returns**
|
|
173
|
+
|
|
174
|
+
`Promise<TriggersTypeRetrieveEnumResponse>`
|
|
175
|
+
|
|
176
|
+
---
|
|
177
|
+
|
|
178
|
+
### listTypes()
|
|
179
|
+
|
|
180
|
+
List all the trigger types
|
|
181
|
+
|
|
182
|
+
```typescript
|
|
183
|
+
async listTypes(query?: TriggersTypeListParams, requestOptions?: ComposioRequestOptions): Promise<TriggersTypeListResponse>
|
|
184
|
+
```
|
|
185
|
+
|
|
186
|
+
**Parameters**
|
|
187
|
+
|
|
188
|
+
| Name | Type | Description |
|
|
189
|
+
|------|------|-------------|
|
|
190
|
+
| `query?` | `TriggersTypeListParams` | The query parameters to filter the trigger types |
|
|
191
|
+
| `requestOptions?` | `ComposioRequestOptions` | |
|
|
192
|
+
|
|
193
|
+
**Returns**
|
|
194
|
+
|
|
195
|
+
`Promise<TriggersTypeListResponse>` — The list of trigger types
|
|
196
|
+
|
|
197
|
+
---
|
|
198
|
+
|
|
199
|
+
### parse()
|
|
200
|
+
|
|
201
|
+
Parse an incoming webhook HTTP request into a typed, normalized trigger payload.
|
|
202
|
+
|
|
203
|
+
Dump the incoming request in and get back the parsed Composio trigger event.
|
|
204
|
+
When `verifySecret` is provided, the request signature is verified before the
|
|
205
|
+
payload is returned (delegating to verifyWebhook); without it, the body
|
|
206
|
+
is parsed without verification.
|
|
207
|
+
|
|
208
|
+
The `request` may be either a Fetch API `Request` (Next.js App Router, Hono,
|
|
209
|
+
Remix) or a plain `{ body, headers }` object (Express with `express.raw`,
|
|
210
|
+
Next.js Pages Router `req`). The signature headers (`webhook-id`,
|
|
211
|
+
`webhook-timestamp`, `webhook-signature`) are read case-insensitively.
|
|
212
|
+
|
|
213
|
+
```typescript
|
|
214
|
+
async parse(request: WebhookRequestLike, options?: ParseWebhookOptions): Promise<VerifyWebhookResult>
|
|
215
|
+
```
|
|
216
|
+
|
|
217
|
+
**Parameters**
|
|
218
|
+
|
|
219
|
+
| Name | Type | Description |
|
|
220
|
+
|------|------|-------------|
|
|
221
|
+
| `request` | `WebhookRequestLike` | The incoming webhook HTTP request |
|
|
222
|
+
| `options?` | `ParseWebhookOptions` | Parse options |
|
|
223
|
+
|
|
224
|
+
**Returns**
|
|
225
|
+
|
|
226
|
+
`Promise<VerifyWebhookResult>` — The parsed (and optionally verified) webhook payload
|
|
227
|
+
|
|
228
|
+
**Example**
|
|
229
|
+
|
|
230
|
+
```typescript
|
|
231
|
+
// Express with express.raw (verify the signature)
|
|
232
|
+
app.post('/webhooks/composio', express.raw({ type: 'application/json' }), async (req, res) => {
|
|
233
|
+
try {
|
|
234
|
+
const result = await composio.triggers.parse(req, {
|
|
235
|
+
verifySecret: process.env.COMPOSIO_WEBHOOK_SECRET,
|
|
236
|
+
});
|
|
237
|
+
console.log('Trigger:', result.payload.triggerSlug);
|
|
238
|
+
console.log('Event data:', result.payload.payload);
|
|
239
|
+
res.sendStatus(200);
|
|
240
|
+
} catch (error) {
|
|
241
|
+
res.sendStatus(401);
|
|
242
|
+
}
|
|
243
|
+
});
|
|
244
|
+
|
|
245
|
+
// Express without verifying (parse only)
|
|
246
|
+
app.post('/webhooks/composio', express.raw({ type: 'application/json' }), async (req, res) => {
|
|
247
|
+
const result = await composio.triggers.parse(req);
|
|
248
|
+
console.log('Trigger:', result.payload.triggerSlug);
|
|
249
|
+
res.sendStatus(200);
|
|
250
|
+
});
|
|
251
|
+
```
|
|
252
|
+
|
|
253
|
+
```typescript
|
|
254
|
+
// Next.js App Router (Request) — verify the signature
|
|
255
|
+
export async function POST(request: Request) {
|
|
256
|
+
try {
|
|
257
|
+
const result = await composio.triggers.parse(request, {
|
|
258
|
+
verifySecret: process.env.COMPOSIO_WEBHOOK_SECRET,
|
|
259
|
+
});
|
|
260
|
+
console.log('Trigger:', result.payload.triggerSlug);
|
|
261
|
+
console.log('Event data:', result.payload.payload);
|
|
262
|
+
return new Response('OK', { status: 200 });
|
|
263
|
+
} catch (error) {
|
|
264
|
+
return new Response('Unauthorized', { status: 401 });
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
// Next.js App Router — parse only (no verification)
|
|
269
|
+
export async function POST(request: Request) {
|
|
270
|
+
const result = await composio.triggers.parse(request);
|
|
271
|
+
console.log('Trigger:', result.payload.triggerSlug);
|
|
272
|
+
return new Response('OK', { status: 200 });
|
|
273
|
+
}
|
|
274
|
+
```
|
|
275
|
+
|
|
276
|
+
---
|
|
277
|
+
|
|
278
|
+
### setWebhookSubscription()
|
|
279
|
+
|
|
280
|
+
Create or update the project webhook subscription used for webhook delivery.
|
|
281
|
+
|
|
282
|
+
If a subscription already exists, the first subscription is updated. Otherwise a new
|
|
283
|
+
subscription is created. By default this subscribes to V3 trigger message events.
|
|
284
|
+
|
|
285
|
+
```typescript
|
|
286
|
+
async setWebhookSubscription(params: SetWebhookSubscriptionParams): Promise<WebhookSubscription>
|
|
287
|
+
```
|
|
288
|
+
|
|
289
|
+
**Parameters**
|
|
290
|
+
|
|
291
|
+
| Name | Type |
|
|
292
|
+
|------|------|
|
|
293
|
+
| `params` | `SetWebhookSubscriptionParams` |
|
|
294
|
+
|
|
295
|
+
**Returns**
|
|
296
|
+
|
|
297
|
+
`Promise<WebhookSubscription>`
|
|
298
|
+
|
|
299
|
+
**Example**
|
|
300
|
+
|
|
301
|
+
```typescript
|
|
302
|
+
await composio.triggers.setWebhookSubscription({
|
|
303
|
+
webhookUrl: `${APP_URL}/webhooks/composio`,
|
|
304
|
+
});
|
|
305
|
+
```
|
|
306
|
+
|
|
307
|
+
---
|
|
308
|
+
|
|
309
|
+
### subscribe()
|
|
310
|
+
|
|
311
|
+
Subscribe to all the triggers
|
|
312
|
+
|
|
313
|
+
```typescript
|
|
314
|
+
async subscribe(fn: (_data: IncomingTriggerPayload) => void, filters: TriggerSubscribeParams): Promise<void>
|
|
315
|
+
```
|
|
316
|
+
|
|
317
|
+
**Parameters**
|
|
318
|
+
|
|
319
|
+
| Name | Type | Description |
|
|
320
|
+
|------|------|-------------|
|
|
321
|
+
| `fn` | `(_data: IncomingTriggerPayload) => void` | The function to call when a trigger is received |
|
|
322
|
+
| `filters` | `TriggerSubscribeParams` | The filters to apply to the triggers |
|
|
323
|
+
|
|
324
|
+
**Returns**
|
|
325
|
+
|
|
326
|
+
`Promise<void>`
|
|
327
|
+
|
|
328
|
+
**Example**
|
|
329
|
+
|
|
330
|
+
```typescript
|
|
331
|
+
triggers.subscribe((data) => {
|
|
332
|
+
console.log(data);
|
|
333
|
+
}, );
|
|
334
|
+
```
|
|
335
|
+
|
|
336
|
+
---
|
|
337
|
+
|
|
338
|
+
### unsubscribe()
|
|
339
|
+
|
|
340
|
+
Unsubscribe from all the triggers
|
|
341
|
+
|
|
342
|
+
```typescript
|
|
343
|
+
async unsubscribe(): Promise<void>
|
|
344
|
+
```
|
|
345
|
+
|
|
346
|
+
**Returns**
|
|
347
|
+
|
|
348
|
+
`Promise<void>`
|
|
349
|
+
|
|
350
|
+
**Example**
|
|
351
|
+
|
|
352
|
+
```typescript
|
|
353
|
+
composio.trigger.subscribe((data) => {
|
|
354
|
+
console.log(data);
|
|
355
|
+
});
|
|
356
|
+
|
|
357
|
+
await triggers.unsubscribe();
|
|
358
|
+
```
|
|
359
|
+
|
|
360
|
+
---
|
|
361
|
+
|
|
362
|
+
### update()
|
|
363
|
+
|
|
364
|
+
Update an existing trigger instance
|
|
365
|
+
|
|
366
|
+
```typescript
|
|
367
|
+
async update(triggerId: string, body: TriggerInstanceManageUpdateParams, requestOptions?: ComposioRequestOptions): Promise<TriggerInstanceManageUpdateResponse>
|
|
368
|
+
```
|
|
369
|
+
|
|
370
|
+
**Parameters**
|
|
371
|
+
|
|
372
|
+
| Name | Type | Description |
|
|
373
|
+
|------|------|-------------|
|
|
374
|
+
| `triggerId` | `string` | The Id of the trigger instance |
|
|
375
|
+
| `body` | `TriggerInstanceManageUpdateParams` | The parameters to update the trigger instance |
|
|
376
|
+
| `requestOptions?` | `ComposioRequestOptions` | |
|
|
377
|
+
|
|
378
|
+
**Returns**
|
|
379
|
+
|
|
380
|
+
`Promise<TriggerInstanceManageUpdateResponse>` — The updated trigger instance response
|
|
381
|
+
|
|
382
|
+
---
|
|
383
|
+
|
|
384
|
+
### verifyWebhook()
|
|
385
|
+
|
|
386
|
+
Verify an incoming webhook payload and signature.
|
|
387
|
+
|
|
388
|
+
This method validates that the webhook request is authentic by:
|
|
389
|
+
1. Verifying the HMAC-SHA256 signature matches the payload using the correct signing format
|
|
390
|
+
2. Optionally checking that the webhook timestamp is within the tolerance window
|
|
391
|
+
|
|
392
|
+
The signature is computed as: `HMAC-SHA256(${webhookId}.${webhookTimestamp}.${payload}, secret)`
|
|
393
|
+
and is expected in the format: `v1,base64EncodedSignature`
|
|
394
|
+
|
|
395
|
+
```typescript
|
|
396
|
+
async verifyWebhook(params: VerifyWebhookParams): Promise<VerifyWebhookResult>
|
|
397
|
+
```
|
|
398
|
+
|
|
399
|
+
**Parameters**
|
|
400
|
+
|
|
401
|
+
| Name | Type | Description |
|
|
402
|
+
|------|------|-------------|
|
|
403
|
+
| `params` | `VerifyWebhookParams` | The verification parameters |
|
|
404
|
+
|
|
405
|
+
**Returns**
|
|
406
|
+
|
|
407
|
+
`Promise<VerifyWebhookResult>` — The verified and parsed webhook payload with version information
|
|
408
|
+
|
|
409
|
+
**Example**
|
|
410
|
+
|
|
411
|
+
```typescript
|
|
412
|
+
// In an Express.js webhook handler
|
|
413
|
+
app.post('/webhook', express.raw({ type: 'application/json' }), async (req, res) => {
|
|
414
|
+
try {
|
|
415
|
+
const result = await composio.triggers.verifyWebhook({
|
|
416
|
+
payload: req.body.toString(),
|
|
417
|
+
signature: req.headers['webhook-signature'] as string,
|
|
418
|
+
webhookId: req.headers['webhook-id'] as string,
|
|
419
|
+
webhookTimestamp: req.headers['webhook-timestamp'] as string,
|
|
420
|
+
secret: process.env.COMPOSIO_WEBHOOK_SECRET!,
|
|
421
|
+
});
|
|
422
|
+
|
|
423
|
+
// Process the verified payload
|
|
424
|
+
console.log('Webhook version:', result.version);
|
|
425
|
+
console.log('Received trigger:', result.payload.triggerSlug);
|
|
426
|
+
res.status(200).send('OK');
|
|
427
|
+
} catch (error) {
|
|
428
|
+
console.error('Webhook verification failed:', error);
|
|
429
|
+
res.status(401).send('Unauthorized');
|
|
430
|
+
}
|
|
431
|
+
});
|
|
432
|
+
```
|
|
433
|
+
|
|
434
|
+
---
|