@trigger.dev/sdk 4.7.4 → 4.8.0-webhooks.20261020092920
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/commonjs/v3/ai.d.ts +626 -8
- package/dist/commonjs/v3/ai.js +2343 -185
- package/dist/commonjs/v3/ai.js.map +1 -1
- package/dist/commonjs/v3/chat.d.ts +23 -0
- package/dist/commonjs/v3/chat.js.map +1 -1
- package/dist/commonjs/v3/index.d.ts +2 -0
- package/dist/commonjs/v3/index.js +23 -17
- package/dist/commonjs/v3/index.js.map +1 -1
- package/dist/commonjs/v3/modelFileDownload.d.ts +10 -0
- package/dist/commonjs/v3/modelFileDownload.js +164 -0
- package/dist/commonjs/v3/modelFileDownload.js.map +1 -0
- package/dist/commonjs/v3/query.d.ts +434 -1
- package/dist/commonjs/v3/query.js +115 -0
- package/dist/commonjs/v3/query.js.map +1 -1
- package/dist/commonjs/v3/test/index.d.ts +2 -1
- package/dist/commonjs/v3/test/index.js +4 -1
- package/dist/commonjs/v3/test/index.js.map +1 -1
- package/dist/commonjs/v3/test/mock-channel-connector.d.ts +172 -0
- package/dist/commonjs/v3/test/mock-channel-connector.js +173 -0
- package/dist/commonjs/v3/test/mock-channel-connector.js.map +1 -0
- package/dist/commonjs/v3/test/mock-chat-agent.d.ts +81 -1
- package/dist/commonjs/v3/test/mock-chat-agent.js +137 -10
- package/dist/commonjs/v3/test/mock-chat-agent.js.map +1 -1
- package/dist/commonjs/v3/transcriptStorage.d.ts +44 -1
- package/dist/commonjs/v3/transcriptStorage.js +24 -0
- package/dist/commonjs/v3/transcriptStorage.js.map +1 -1
- package/dist/commonjs/v3/webhookWaiters.d.ts +80 -0
- package/dist/commonjs/v3/webhookWaiters.js +156 -0
- package/dist/commonjs/v3/webhookWaiters.js.map +1 -0
- package/dist/commonjs/v3/webhooks.d.ts +184 -2
- package/dist/commonjs/v3/webhooks.js +323 -1
- package/dist/commonjs/v3/webhooks.js.map +1 -1
- package/dist/commonjs/version.js +1 -1
- package/dist/esm/v3/ai.d.ts +626 -8
- package/dist/esm/v3/ai.js +2336 -184
- package/dist/esm/v3/ai.js.map +1 -1
- package/dist/esm/v3/chat.d.ts +23 -0
- package/dist/esm/v3/chat.js.map +1 -1
- package/dist/esm/v3/index.d.ts +2 -0
- package/dist/esm/v3/index.js +1 -0
- package/dist/esm/v3/index.js.map +1 -1
- package/dist/esm/v3/modelFileDownload.d.ts +10 -0
- package/dist/esm/v3/modelFileDownload.js +161 -0
- package/dist/esm/v3/modelFileDownload.js.map +1 -0
- package/dist/esm/v3/query.d.ts +434 -1
- package/dist/esm/v3/query.js +115 -0
- package/dist/esm/v3/query.js.map +1 -1
- package/dist/esm/v3/test/index.d.ts +2 -1
- package/dist/esm/v3/test/index.js +2 -1
- package/dist/esm/v3/test/index.js.map +1 -1
- package/dist/esm/v3/test/mock-channel-connector.d.ts +172 -0
- package/dist/esm/v3/test/mock-channel-connector.js +170 -0
- package/dist/esm/v3/test/mock-channel-connector.js.map +1 -0
- package/dist/esm/v3/test/mock-chat-agent.d.ts +81 -1
- package/dist/esm/v3/test/mock-chat-agent.js +137 -11
- package/dist/esm/v3/test/mock-chat-agent.js.map +1 -1
- package/dist/esm/v3/transcriptStorage.d.ts +44 -1
- package/dist/esm/v3/transcriptStorage.js +24 -0
- package/dist/esm/v3/transcriptStorage.js.map +1 -1
- package/dist/esm/v3/webhookWaiters.d.ts +80 -0
- package/dist/esm/v3/webhookWaiters.js +149 -0
- package/dist/esm/v3/webhookWaiters.js.map +1 -0
- package/dist/esm/v3/webhooks.d.ts +184 -2
- package/dist/esm/v3/webhooks.js +319 -1
- package/dist/esm/v3/webhooks.js.map +1 -1
- package/dist/esm/version.js +1 -1
- package/docs/ai-chat/actions.mdx +6 -1
- package/docs/ai-chat/backend.mdx +40 -0
- package/docs/ai-chat/patterns/redacting-telemetry.mdx +117 -0
- package/docs/ai-chat/pending-messages.mdx +2 -0
- package/docs/ai-chat/reference.mdx +53 -2
- package/docs/ai-chat/transcript-storage.mdx +1 -1
- package/docs/apikeys.mdx +6 -4
- package/docs/cli-runs-commands.mdx +2 -2
- package/docs/cli-tasks-commands.mdx +95 -0
- package/docs/config/config-file.mdx +58 -0
- package/docs/config/extensions/prismaExtension.mdx +4 -4
- package/docs/deploy-environment-variables.mdx +4 -0
- package/docs/deployment/atomic-deployment.mdx +3 -3
- package/docs/deployment/overview.mdx +1 -1
- package/docs/deployment/preview-branches.mdx +1 -1
- package/docs/github-actions.mdx +3 -3
- package/docs/limits.mdx +6 -0
- package/docs/manual-setup.mdx +1 -1
- package/docs/mcp-tools.mdx +99 -3
- package/docs/observability/dashboards.mdx +62 -0
- package/docs/runs/max-duration.mdx +4 -0
- package/docs/self-hosting/env/supervisor.mdx +1 -0
- package/docs/webhooks/channels.mdx +132 -0
- package/docs/webhooks/connect.mdx +84 -0
- package/docs/webhooks/deliveries.mdx +96 -0
- package/docs/webhooks/filters.mdx +142 -0
- package/docs/webhooks/human-in-the-loop.mdx +155 -0
- package/docs/webhooks/linear.mdx +189 -0
- package/docs/webhooks/overview.mdx +103 -0
- package/docs/webhooks/session-routing.mdx +138 -0
- package/docs/webhooks/slack.mdx +368 -0
- package/docs/webhooks/sources.mdx +221 -0
- package/docs/webhooks/waiters.mdx +194 -0
- package/package.json +4 -2
|
@@ -1,4 +1,8 @@
|
|
|
1
1
|
import { Webhook } from "@trigger.dev/core/v3";
|
|
2
|
+
import type { WebhookSource, InferWebhookEvent, AnyWebhookSource, ValidateWebhookFilter, NarrowWebhookEvent, ChatEvent, ValidatedWebhookKey, WebhookResponseConfig, WebhookUrlSecretConfig, WebhookVerifierConfig, StripeWebhookEvent, GitHubWebhookEvent, TaskRunContext, AnyWebhookEndpoint, InferWebhookEndpointEvent, WebhookEndpoint, WebhookEndpointContext, TaskOptions } from "@trigger.dev/core/v3";
|
|
3
|
+
import { cancelWebhookWaiter, createWebhookWaiter, waitForWebhookWaiter } from "./webhookWaiters.js";
|
|
4
|
+
import { type Task } from "./shared.js";
|
|
5
|
+
import { type WebhookProviderId } from "@trigger.dev/core/webhooks";
|
|
2
6
|
/**
|
|
3
7
|
* The type of error thrown when a webhook fails to parse or verify
|
|
4
8
|
*/
|
|
@@ -14,6 +18,159 @@ type ConstructEventOptions = {
|
|
|
14
18
|
/** Signature header as string, Buffer, or string array */
|
|
15
19
|
header: string | Buffer | Array<string>;
|
|
16
20
|
};
|
|
21
|
+
/**
|
|
22
|
+
* The verifier configs a hosted endpoint can enforce. A `url-secret` placed in the path is excluded:
|
|
23
|
+
* the hosted ingress URL is fixed per endpoint, so there is no path segment for the caller to choose,
|
|
24
|
+
* and the server refuses such a declaration at deploy time. Use `placement: "query"` instead.
|
|
25
|
+
*/
|
|
26
|
+
export type HostedWebhookVerifierConfig = Exclude<WebhookVerifierConfig, WebhookUrlSecretConfig> | (Omit<WebhookUrlSecretConfig, "placement"> & {
|
|
27
|
+
placement: "query";
|
|
28
|
+
});
|
|
29
|
+
export declare const webhookSources: {
|
|
30
|
+
readonly custom: <T = unknown>(config: HostedWebhookVerifierConfig, options?: {
|
|
31
|
+
/** Instructions for an AI agent registering an endpoint on this source with the provider. */
|
|
32
|
+
setupPrompt?: string;
|
|
33
|
+
/**
|
|
34
|
+
* How the endpoint answers the provider. `{ acceptedBody: "empty" }` acknowledges with an empty
|
|
35
|
+
* 200, for providers that show the response to a user (Slack slash commands).
|
|
36
|
+
*/
|
|
37
|
+
response?: WebhookResponseConfig;
|
|
38
|
+
}) => WebhookSource<T>;
|
|
39
|
+
readonly stripe: <TEvent = StripeWebhookEvent>(opts?: {
|
|
40
|
+
toleranceSeconds?: number;
|
|
41
|
+
}) => WebhookSource<TEvent>;
|
|
42
|
+
readonly github: <TEvent = GitHubWebhookEvent>() => WebhookSource<TEvent>;
|
|
43
|
+
readonly svix: <T = unknown>() => WebhookSource<T>;
|
|
44
|
+
readonly standardWebhooks: <T = unknown>() => WebhookSource<T>;
|
|
45
|
+
readonly square: <T = unknown>() => WebhookSource<T>;
|
|
46
|
+
/**
|
|
47
|
+
* Discord: asymmetric Ed25519 over `{timestamp}{body}`. The "secret" stored on the endpoint is the
|
|
48
|
+
* application PUBLIC KEY (hex by default); there is no shared secret. Discord's response contract
|
|
49
|
+
* is declared as data on the artifact: the `{ type: 0 }` PING sent when the URL is saved is answered
|
|
50
|
+
* with a bodiless 204 and never recorded, accepted events are acknowledged with 204, and a bad
|
|
51
|
+
* signature gets 401.
|
|
52
|
+
*/
|
|
53
|
+
readonly discord: <T = unknown>(opts?: {
|
|
54
|
+
publicKeyEncoding?: "raw-hex" | "pem";
|
|
55
|
+
}) => WebhookSource<T>;
|
|
56
|
+
/**
|
|
57
|
+
* Per-provider producers over shared presets. Each is a thin wrapper: same verifier config as the
|
|
58
|
+
* preset it references, differing only in `provider` (routing + picker identity) and who provisions
|
|
59
|
+
* the secret. Pass the provider's own published type for full typing, e.g. clerk<WebhookEvent>().
|
|
60
|
+
*/
|
|
61
|
+
readonly clerk: <T = unknown>() => WebhookSource<T>;
|
|
62
|
+
readonly resend: <T = unknown>() => WebhookSource<T>;
|
|
63
|
+
readonly openai: <T = unknown>() => WebhookSource<T>;
|
|
64
|
+
readonly replicate: <T = unknown>() => WebhookSource<T>;
|
|
65
|
+
readonly recallai: <T = unknown>() => WebhookSource<T>;
|
|
66
|
+
readonly brex: <T = unknown>() => WebhookSource<T>;
|
|
67
|
+
readonly composio: <T = unknown>() => WebhookSource<T>;
|
|
68
|
+
readonly gitlab: <T = unknown>() => WebhookSource<T>;
|
|
69
|
+
/**
|
|
70
|
+
* WhatsApp Cloud API (Meta): `X-Hub-Signature-256` HMAC over the raw body, keyed by the App Secret,
|
|
71
|
+
* which Meta issues and you paste in as the endpoint's signing secret (it cannot be generated here).
|
|
72
|
+
* Meta verifies the callback URL with a GET carrying `hub.mode`, `hub.verify_token` and
|
|
73
|
+
* `hub.challenge`; the endpoint answers it when the token equals the verify token generated in
|
|
74
|
+
* the endpoint's Connect panel, which you paste into Meta's Verify Token field.
|
|
75
|
+
*/
|
|
76
|
+
readonly whatsapp: <T = unknown>() => WebhookSource<T>;
|
|
77
|
+
};
|
|
78
|
+
type CamelCase<S extends string> = S extends `${infer Head}-${infer Tail}` ? `${Head}${Capitalize<CamelCase<Tail>>}` : S;
|
|
79
|
+
/**
|
|
80
|
+
* Per-provider producers generated from the core config table (kind "config"). Each carries the
|
|
81
|
+
* provider's own HMAC verifier config and stays in lockstep with the round-trip-tested configs.
|
|
82
|
+
* The method is the provider id in camel case (`cal-com` is `webhooks.calCom()`); the emitted
|
|
83
|
+
* `provider` keeps the id itself.
|
|
84
|
+
*/
|
|
85
|
+
export type ProviderProducers = {
|
|
86
|
+
[K in Exclude<WebhookProviderId, "zoom"> as CamelCase<K>]: <TEvent = unknown>() => WebhookSource<TEvent>;
|
|
87
|
+
};
|
|
88
|
+
export declare const providerProducers: Omit<ProviderProducers, "slack">;
|
|
89
|
+
export type WebhookEndpointOptions<TIdentifier extends string, TSource extends AnyWebhookSource> = {
|
|
90
|
+
/** The endpoint id. Subscribers reference the endpoint, and it names the endpoint's URL. */
|
|
91
|
+
id: TIdentifier;
|
|
92
|
+
/** The provider source: how deliveries are verified and who issues the signing secret. */
|
|
93
|
+
source: TSource;
|
|
94
|
+
description?: string;
|
|
95
|
+
/** Arbitrary metadata, passed to every subscriber and waiter as `endpoint.metadata`. */
|
|
96
|
+
metadata?: Record<string, unknown>;
|
|
97
|
+
};
|
|
98
|
+
/**
|
|
99
|
+
* Declare a webhook endpoint: one URL you register with the provider. Subscribe to it with
|
|
100
|
+
* `webhook({ endpoint })`, `chat.event({ endpoint })` or a channel connector, and wait on it with
|
|
101
|
+
* `webhooks.waiter.create(endpoint, ...)`. An endpoint with no subscribers still gets a URL.
|
|
102
|
+
*/
|
|
103
|
+
export declare function defineWebhookEndpoint<TIdentifier extends string, TSource extends AnyWebhookSource>(options: WebhookEndpointOptions<TIdentifier, TSource>): WebhookEndpoint<InferWebhookEvent<TSource>> & {
|
|
104
|
+
id: TIdentifier;
|
|
105
|
+
};
|
|
106
|
+
export type WebhookOnEventParams<TEvent> = {
|
|
107
|
+
/** The verified event body, typed by the endpoint's source. */
|
|
108
|
+
event: TEvent;
|
|
109
|
+
/** The inbound request headers (case-insensitive, Web `Headers`). e.g. headers.get("x-github-event"). */
|
|
110
|
+
headers: Headers;
|
|
111
|
+
/** The endpoint the delivery arrived on. Unset when the task is triggered by hand without one. */
|
|
112
|
+
endpoint?: WebhookEndpointContext;
|
|
113
|
+
ctx: TaskRunContext;
|
|
114
|
+
};
|
|
115
|
+
/**
|
|
116
|
+
* The `task()` options a webhook task also takes: `queue`, `concurrency`, `machine`, `retry`,
|
|
117
|
+
* `maxDuration`, `ttl` and the lifecycle hooks. e.g. `queue: { concurrencyLimit: 1 }` handles one
|
|
118
|
+
* delivery at a time.
|
|
119
|
+
*/
|
|
120
|
+
export type WebhookTaskOptions<TIdentifier extends string, TEvent> = Omit<TaskOptions<TIdentifier, WebhookTaskPayload<TEvent>, void>, "id" | "run" | "jsonSchema" | "triggerSource" | "agentConfig">;
|
|
121
|
+
export type WebhookOptions<TIdentifier extends string, TEndpoint extends AnyWebhookEndpoint, TEvent = InferWebhookEndpointEvent<TEndpoint>> = WebhookTaskOptions<TIdentifier, TEvent> & {
|
|
122
|
+
id: TIdentifier;
|
|
123
|
+
/** The endpoint this task subscribes to. */
|
|
124
|
+
endpoint: TEndpoint;
|
|
125
|
+
/**
|
|
126
|
+
* Optional server-side filter (a type-safe string DSL checked against the event shape). A delivery
|
|
127
|
+
* this subscriber's filter rejects is still recorded, and other subscribers on the endpoint still
|
|
128
|
+
* get it. e.g. `"event.action == 'created' && event.repository.private == false"`.
|
|
129
|
+
*/
|
|
130
|
+
filter?: string;
|
|
131
|
+
/** Gets the event narrowed by the filter's `event.<field> == '<value>'` clauses. */
|
|
132
|
+
onEvent: (params: WebhookOnEventParams<TEvent>) => Promise<void> | void;
|
|
133
|
+
};
|
|
134
|
+
/**
|
|
135
|
+
* What a webhook task runs on: the verified event, the delivery headers and the endpoint. The hosted
|
|
136
|
+
* ingress sends it for every delivery; triggering the handle by hand (`myWebhook.trigger({ event })`,
|
|
137
|
+
* a replay, a test) sends the same shape, so `onEvent` sees the event either way.
|
|
138
|
+
*/
|
|
139
|
+
export type WebhookTaskPayload<TEvent> = {
|
|
140
|
+
event: TEvent;
|
|
141
|
+
headers?: Record<string, string>;
|
|
142
|
+
endpoint?: WebhookEndpointContext;
|
|
143
|
+
};
|
|
144
|
+
export type WebhookHandle<TIdentifier extends string, TEvent> = Task<TIdentifier, WebhookTaskPayload<TEvent>, void>;
|
|
145
|
+
export declare function webhook<TIdentifier extends string, TEndpoint extends AnyWebhookEndpoint, const TFilter extends string = string>(options: WebhookOptions<TIdentifier, TEndpoint, NarrowWebhookEvent<InferWebhookEndpointEvent<TEndpoint>, TFilter>> & {
|
|
146
|
+
filter?: ValidateWebhookFilter<InferWebhookEndpointEvent<TEndpoint>, TFilter>;
|
|
147
|
+
}): WebhookHandle<TIdentifier, NarrowWebhookEvent<InferWebhookEndpointEvent<TEndpoint>, TFilter>>;
|
|
148
|
+
export declare function chatEvent<TEndpoint extends AnyWebhookEndpoint, const TId extends string = string, const TKey extends string = string, const TType extends string = TId, const TFilter extends string = string>(options: {
|
|
149
|
+
id: TId;
|
|
150
|
+
/** The endpoint this event subscribes to. */
|
|
151
|
+
endpoint: TEndpoint;
|
|
152
|
+
/**
|
|
153
|
+
* The session each delivery goes to, as a template: `{event.x}` reads the event, `{header.x}` a
|
|
154
|
+
* header and `{webhook.x}` the endpoint, and `{a || b}` falls back to `b` when `a` is empty. e.g.
|
|
155
|
+
* `"{webhook.externalRef}:{event.data.object.customer}"`.
|
|
156
|
+
*/
|
|
157
|
+
key: ValidatedWebhookKey<NarrowWebhookEvent<InferWebhookEndpointEvent<TEndpoint>, TFilter>, TKey>;
|
|
158
|
+
/** The `action.type` the handler reads. Optional; defaults to `id`. */
|
|
159
|
+
type?: TType;
|
|
160
|
+
/**
|
|
161
|
+
* Optional server-side filter (same type-safe DSL as `webhook()`); a non-match is recorded FILTERED
|
|
162
|
+
* and not routed. Narrows the action's `event` like `webhook()`'s `onEvent`.
|
|
163
|
+
*/
|
|
164
|
+
filter?: ValidateWebhookFilter<InferWebhookEndpointEvent<TEndpoint>, TFilter>;
|
|
165
|
+
}): ChatEvent<TType, NarrowWebhookEvent<InferWebhookEndpointEvent<TEndpoint>, TFilter>>;
|
|
166
|
+
export type { ChatEvent, AnyChatEvent, ChatEventAction, ChatEventActions, WebhookKeyMeta, } from "@trigger.dev/core/v3";
|
|
167
|
+
/**
|
|
168
|
+
* Compiles a key template to its stored form. Each placeholder names its namespace the way a filter
|
|
169
|
+
* path does: `{event.x}` reads the event body (stored as `{body.x}`), `{header.x}` a header and
|
|
170
|
+
* `{webhook.x}` the endpoint. A placeholder without one of those namespaces throws.
|
|
171
|
+
*/
|
|
172
|
+
export declare function normalizeKeyString(key: string): string;
|
|
173
|
+
export type { CreateWebhookEndpointParams } from "@trigger.dev/core/v3";
|
|
17
174
|
/**
|
|
18
175
|
* Interface describing the webhook utilities
|
|
19
176
|
*/
|
|
@@ -39,9 +196,34 @@ interface Webhooks {
|
|
|
39
196
|
constructEvent(request: ConstructEventOptions | Request, secret: string): Promise<Webhook>;
|
|
40
197
|
/** Header name used for webhook signatures */
|
|
41
198
|
SIGNATURE_HEADER_NAME: string;
|
|
199
|
+
custom: typeof webhookSources.custom;
|
|
200
|
+
stripe: typeof webhookSources.stripe;
|
|
201
|
+
github: typeof webhookSources.github;
|
|
202
|
+
svix: typeof webhookSources.svix;
|
|
203
|
+
standardWebhooks: typeof webhookSources.standardWebhooks;
|
|
204
|
+
square: typeof webhookSources.square;
|
|
205
|
+
discord: typeof webhookSources.discord;
|
|
206
|
+
clerk: typeof webhookSources.clerk;
|
|
207
|
+
resend: typeof webhookSources.resend;
|
|
208
|
+
openai: typeof webhookSources.openai;
|
|
209
|
+
replicate: typeof webhookSources.replicate;
|
|
210
|
+
recallai: typeof webhookSources.recallai;
|
|
211
|
+
brex: typeof webhookSources.brex;
|
|
212
|
+
composio: typeof webhookSources.composio;
|
|
213
|
+
gitlab: typeof webhookSources.gitlab;
|
|
214
|
+
whatsapp: typeof webhookSources.whatsapp;
|
|
215
|
+
/** Declare the URLs providers deliver to. */
|
|
216
|
+
endpoint: {
|
|
217
|
+
define: typeof defineWebhookEndpoint;
|
|
218
|
+
};
|
|
219
|
+
/** Suspend a run until a matching webhook arrives. */
|
|
220
|
+
waiter: {
|
|
221
|
+
create: typeof createWebhookWaiter;
|
|
222
|
+
wait: typeof waitForWebhookWaiter;
|
|
223
|
+
cancel: typeof cancelWebhookWaiter;
|
|
224
|
+
};
|
|
42
225
|
}
|
|
43
226
|
/**
|
|
44
227
|
* Webhook utilities for handling incoming webhook requests
|
|
45
228
|
*/
|
|
46
|
-
export declare const webhooks: Webhooks
|
|
47
|
-
export {};
|
|
229
|
+
export declare const webhooks: Webhooks & Omit<ProviderProducers, "slack">;
|
package/dist/esm/v3/webhooks.js
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
|
-
import { Webhook } from "@trigger.dev/core/v3";
|
|
1
|
+
import { Webhook, resourceCatalog } from "@trigger.dev/core/v3";
|
|
2
2
|
import { subtle } from "../imports/uncrypto.js";
|
|
3
|
+
import { cancelWebhookWaiter, createWebhookWaiter, waitForWebhookWaiter, } from "./webhookWaiters.js";
|
|
4
|
+
import { createTask } from "./shared.js";
|
|
5
|
+
import { discordVerifierConfig, githubVerifierConfig, squareVerifierConfig, standardWebhooksVerifierConfig, stripeVerifierConfig, svixVerifierConfig, webhookProviderConfigs, webhookSetupPrompts, } from "@trigger.dev/core/webhooks";
|
|
3
6
|
/**
|
|
4
7
|
* The type of error thrown when a webhook fails to parse or verify
|
|
5
8
|
*/
|
|
@@ -11,12 +14,327 @@ export class WebhookError extends Error {
|
|
|
11
14
|
}
|
|
12
15
|
/** Header name used for webhook signatures */
|
|
13
16
|
const SIGNATURE_HEADER_NAME = "x-trigger-signature-hmacsha256";
|
|
17
|
+
// ── Source producers (presets carry the event type) ──
|
|
18
|
+
export const webhookSources = {
|
|
19
|
+
custom(config, options) {
|
|
20
|
+
if (config.scheme === "url-secret" && config.placement === "path") {
|
|
21
|
+
throw new Error('webhooks.custom(): url-secret verification cannot use placement "path" on the hosted ingress URL. Use placement "query" or a header-based scheme.');
|
|
22
|
+
}
|
|
23
|
+
// Roll-your-own webhooks: you control both ends, so offer paste AND generate.
|
|
24
|
+
return {
|
|
25
|
+
provider: "custom",
|
|
26
|
+
verifier: {
|
|
27
|
+
kind: "config",
|
|
28
|
+
config,
|
|
29
|
+
...(options?.response ? { response: options.response } : {}),
|
|
30
|
+
},
|
|
31
|
+
secretProvisioning: "either",
|
|
32
|
+
...(options?.setupPrompt ? { setupPrompt: options.setupPrompt } : {}),
|
|
33
|
+
};
|
|
34
|
+
},
|
|
35
|
+
// Stripe: `Stripe-Signature: t=…,v1=…` (comma-kv), signed `{t}.{body}`, hex.
|
|
36
|
+
// Defaults to a minimal event shape; pass the official type for full typing: stripe<Stripe.Event>().
|
|
37
|
+
stripe(opts) {
|
|
38
|
+
return {
|
|
39
|
+
provider: "stripe",
|
|
40
|
+
verifier: { kind: "preset", preset: "stripe", config: stripeVerifierConfig(opts) },
|
|
41
|
+
secretProvisioning: "provider",
|
|
42
|
+
};
|
|
43
|
+
},
|
|
44
|
+
// GitHub: `X-Hub-Signature-256: sha256=<hex>` (prefixed), signed raw body.
|
|
45
|
+
// Defaults to an open shape; pass your event type for full typing: github<MyPushEvent>().
|
|
46
|
+
github() {
|
|
47
|
+
return {
|
|
48
|
+
provider: "github",
|
|
49
|
+
verifier: { kind: "preset", preset: "github", config: githubVerifierConfig() },
|
|
50
|
+
secretProvisioning: "integrator",
|
|
51
|
+
};
|
|
52
|
+
},
|
|
53
|
+
// Svix family (Svix, Clerk, Resend): `svix-signature: v1,<b64> v1,<b64>` (space-list),
|
|
54
|
+
// signed `{id}.{timestamp}.{body}`, base64; the `whsec_` secret is base64-decoded. Providers that
|
|
55
|
+
// send the spec's `webhook-*` header names instead use `standardWebhooks()`.
|
|
56
|
+
svix() {
|
|
57
|
+
return {
|
|
58
|
+
provider: "svix",
|
|
59
|
+
verifier: { kind: "preset", preset: "svix", config: svixVerifierConfig() },
|
|
60
|
+
secretProvisioning: "provider",
|
|
61
|
+
};
|
|
62
|
+
},
|
|
63
|
+
// Standard Webhooks (Composio, and any provider implementing the spec directly): the Svix scheme under
|
|
64
|
+
// the spec's `webhook-id` / `webhook-timestamp` / `webhook-signature` header names.
|
|
65
|
+
standardWebhooks() {
|
|
66
|
+
return {
|
|
67
|
+
provider: "standard-webhooks",
|
|
68
|
+
verifier: {
|
|
69
|
+
kind: "preset",
|
|
70
|
+
preset: "standard-webhooks",
|
|
71
|
+
config: standardWebhooksVerifierConfig(),
|
|
72
|
+
},
|
|
73
|
+
secretProvisioning: "provider",
|
|
74
|
+
};
|
|
75
|
+
},
|
|
76
|
+
// Square: bare base64 signature over `{notificationURL}{body}` (URL template var, no separator).
|
|
77
|
+
square() {
|
|
78
|
+
return {
|
|
79
|
+
provider: "square",
|
|
80
|
+
verifier: { kind: "preset", preset: "square", config: squareVerifierConfig() },
|
|
81
|
+
secretProvisioning: "provider",
|
|
82
|
+
};
|
|
83
|
+
},
|
|
84
|
+
/**
|
|
85
|
+
* Discord: asymmetric Ed25519 over `{timestamp}{body}`. The "secret" stored on the endpoint is the
|
|
86
|
+
* application PUBLIC KEY (hex by default); there is no shared secret. Discord's response contract
|
|
87
|
+
* is declared as data on the artifact: the `{ type: 0 }` PING sent when the URL is saved is answered
|
|
88
|
+
* with a bodiless 204 and never recorded, accepted events are acknowledged with 204, and a bad
|
|
89
|
+
* signature gets 401.
|
|
90
|
+
*/
|
|
91
|
+
discord(opts = {}) {
|
|
92
|
+
return {
|
|
93
|
+
provider: "discord",
|
|
94
|
+
verifier: {
|
|
95
|
+
kind: "preset",
|
|
96
|
+
preset: "discord",
|
|
97
|
+
config: discordVerifierConfig(opts),
|
|
98
|
+
handshake: { matchPath: "type", matchValue: "0", respondStatus: 204 },
|
|
99
|
+
response: { acceptedStatus: 204, rejectedStatus: 401 },
|
|
100
|
+
},
|
|
101
|
+
secretProvisioning: "provider",
|
|
102
|
+
};
|
|
103
|
+
},
|
|
104
|
+
/**
|
|
105
|
+
* Per-provider producers over shared presets. Each is a thin wrapper: same verifier config as the
|
|
106
|
+
* preset it references, differing only in `provider` (routing + picker identity) and who provisions
|
|
107
|
+
* the secret. Pass the provider's own published type for full typing, e.g. clerk<WebhookEvent>().
|
|
108
|
+
*/
|
|
109
|
+
clerk() {
|
|
110
|
+
return {
|
|
111
|
+
provider: "clerk",
|
|
112
|
+
verifier: { kind: "preset", preset: "svix", config: svixVerifierConfig() },
|
|
113
|
+
secretProvisioning: "provider",
|
|
114
|
+
};
|
|
115
|
+
},
|
|
116
|
+
resend() {
|
|
117
|
+
return {
|
|
118
|
+
provider: "resend",
|
|
119
|
+
verifier: { kind: "preset", preset: "svix", config: svixVerifierConfig() },
|
|
120
|
+
secretProvisioning: "provider",
|
|
121
|
+
};
|
|
122
|
+
},
|
|
123
|
+
openai() {
|
|
124
|
+
return {
|
|
125
|
+
provider: "openai",
|
|
126
|
+
verifier: {
|
|
127
|
+
kind: "preset",
|
|
128
|
+
preset: "standard-webhooks",
|
|
129
|
+
config: standardWebhooksVerifierConfig(),
|
|
130
|
+
},
|
|
131
|
+
secretProvisioning: "provider",
|
|
132
|
+
};
|
|
133
|
+
},
|
|
134
|
+
replicate() {
|
|
135
|
+
return {
|
|
136
|
+
provider: "replicate",
|
|
137
|
+
verifier: {
|
|
138
|
+
kind: "preset",
|
|
139
|
+
preset: "standard-webhooks",
|
|
140
|
+
config: standardWebhooksVerifierConfig(),
|
|
141
|
+
},
|
|
142
|
+
secretProvisioning: "provider",
|
|
143
|
+
};
|
|
144
|
+
},
|
|
145
|
+
recallai() {
|
|
146
|
+
return {
|
|
147
|
+
provider: "recall-ai",
|
|
148
|
+
verifier: {
|
|
149
|
+
kind: "preset",
|
|
150
|
+
preset: "standard-webhooks",
|
|
151
|
+
config: standardWebhooksVerifierConfig(),
|
|
152
|
+
},
|
|
153
|
+
secretProvisioning: "provider",
|
|
154
|
+
};
|
|
155
|
+
},
|
|
156
|
+
brex() {
|
|
157
|
+
return {
|
|
158
|
+
provider: "brex",
|
|
159
|
+
verifier: { kind: "preset", preset: "svix", config: svixVerifierConfig() },
|
|
160
|
+
secretProvisioning: "provider",
|
|
161
|
+
};
|
|
162
|
+
},
|
|
163
|
+
composio() {
|
|
164
|
+
return {
|
|
165
|
+
provider: "composio",
|
|
166
|
+
verifier: {
|
|
167
|
+
kind: "preset",
|
|
168
|
+
preset: "standard-webhooks",
|
|
169
|
+
config: standardWebhooksVerifierConfig(),
|
|
170
|
+
},
|
|
171
|
+
secretProvisioning: "provider",
|
|
172
|
+
};
|
|
173
|
+
},
|
|
174
|
+
gitlab() {
|
|
175
|
+
return {
|
|
176
|
+
provider: "gitlab",
|
|
177
|
+
verifier: {
|
|
178
|
+
kind: "config",
|
|
179
|
+
config: { scheme: "shared-secret", placement: "header", fieldName: "x-gitlab-token" },
|
|
180
|
+
},
|
|
181
|
+
secretProvisioning: "integrator",
|
|
182
|
+
};
|
|
183
|
+
},
|
|
184
|
+
/**
|
|
185
|
+
* WhatsApp Cloud API (Meta): `X-Hub-Signature-256` HMAC over the raw body, keyed by the App Secret,
|
|
186
|
+
* which Meta issues and you paste in as the endpoint's signing secret (it cannot be generated here).
|
|
187
|
+
* Meta verifies the callback URL with a GET carrying `hub.mode`, `hub.verify_token` and
|
|
188
|
+
* `hub.challenge`; the endpoint answers it when the token equals the verify token generated in
|
|
189
|
+
* the endpoint's Connect panel, which you paste into Meta's Verify Token field.
|
|
190
|
+
*/
|
|
191
|
+
whatsapp() {
|
|
192
|
+
return {
|
|
193
|
+
provider: "whatsapp",
|
|
194
|
+
verifier: {
|
|
195
|
+
kind: "preset",
|
|
196
|
+
preset: "github",
|
|
197
|
+
config: githubVerifierConfig(),
|
|
198
|
+
getHandshake: {
|
|
199
|
+
matchParam: "hub.mode",
|
|
200
|
+
matchValue: "subscribe",
|
|
201
|
+
tokenParam: "hub.verify_token",
|
|
202
|
+
challengeParam: "hub.challenge",
|
|
203
|
+
},
|
|
204
|
+
},
|
|
205
|
+
secretProvisioning: "provider",
|
|
206
|
+
};
|
|
207
|
+
},
|
|
208
|
+
};
|
|
209
|
+
function producerName(provider) {
|
|
210
|
+
return provider.replace(/-([a-z0-9])/g, (_, c) => c.toUpperCase());
|
|
211
|
+
}
|
|
212
|
+
export const providerProducers = Object.fromEntries(Object.entries(webhookProviderConfigs)
|
|
213
|
+
// Zoom needs a computed URL-validation response that the hosted ingress does not support yet.
|
|
214
|
+
.filter(([provider]) => provider !== "slack" && provider !== "zoom")
|
|
215
|
+
.map(([provider, entry]) => [
|
|
216
|
+
producerName(provider),
|
|
217
|
+
() => {
|
|
218
|
+
const setupPrompt = webhookSetupPrompts[provider];
|
|
219
|
+
return {
|
|
220
|
+
provider,
|
|
221
|
+
verifier: { kind: "config", config: entry.config() },
|
|
222
|
+
secretProvisioning: entry.secretProvisioning,
|
|
223
|
+
...(setupPrompt ? { setupPrompt } : {}),
|
|
224
|
+
};
|
|
225
|
+
},
|
|
226
|
+
]));
|
|
227
|
+
/**
|
|
228
|
+
* Declare a webhook endpoint: one URL you register with the provider. Subscribe to it with
|
|
229
|
+
* `webhook({ endpoint })`, `chat.event({ endpoint })` or a channel connector, and wait on it with
|
|
230
|
+
* `webhooks.waiter.create(endpoint, ...)`. An endpoint with no subscribers still gets a URL.
|
|
231
|
+
*/
|
|
232
|
+
export function defineWebhookEndpoint(options) {
|
|
233
|
+
const { id, source, description, metadata } = options;
|
|
234
|
+
if (id.startsWith("wh_")) {
|
|
235
|
+
throw new Error(`webhooks.endpoint.define("${id}"): an endpoint id can't start with "wh_"; that prefix is reserved for generated endpoint ids.`);
|
|
236
|
+
}
|
|
237
|
+
const setupPrompt = source.setupPrompt ??
|
|
238
|
+
(source.verifier.kind === "preset"
|
|
239
|
+
? webhookSetupPrompts[source.verifier.preset]
|
|
240
|
+
: undefined);
|
|
241
|
+
resourceCatalog.registerWebhookEndpointMetadata({
|
|
242
|
+
id,
|
|
243
|
+
source: source.provider,
|
|
244
|
+
verifierArtifact: source.verifier,
|
|
245
|
+
...(description ? { description } : {}),
|
|
246
|
+
...(source.secretProvisioning ? { secretProvisioning: source.secretProvisioning } : {}),
|
|
247
|
+
...(setupPrompt ? { setupPrompt } : {}),
|
|
248
|
+
...(metadata ? { metadata } : {}),
|
|
249
|
+
});
|
|
250
|
+
return { id, source: source.provider };
|
|
251
|
+
}
|
|
252
|
+
export function webhook(options) {
|
|
253
|
+
const { id, endpoint, onEvent, filter, ...taskOptions } = options;
|
|
254
|
+
if (!endpoint?.id) {
|
|
255
|
+
throw new Error(`webhook("${id}"): an endpoint is required. Declare one with webhooks.endpoint.define() and pass it as { endpoint }.`);
|
|
256
|
+
}
|
|
257
|
+
const task = createTask({
|
|
258
|
+
...taskOptions,
|
|
259
|
+
id,
|
|
260
|
+
triggerSource: "webhook",
|
|
261
|
+
run: async (payload, runOptions) => {
|
|
262
|
+
await onEvent({
|
|
263
|
+
event: payload.event,
|
|
264
|
+
headers: new Headers(payload.headers ?? {}),
|
|
265
|
+
endpoint: payload.endpoint,
|
|
266
|
+
ctx: runOptions.ctx,
|
|
267
|
+
});
|
|
268
|
+
},
|
|
269
|
+
});
|
|
270
|
+
resourceCatalog.registerWebhookSubscriber({
|
|
271
|
+
endpointId: endpoint.id,
|
|
272
|
+
target: { type: "task", id, taskId: id, ...(filter ? { filter } : {}) },
|
|
273
|
+
});
|
|
274
|
+
return task;
|
|
275
|
+
}
|
|
276
|
+
// ── chat.event(): a session subscriber an agent claims via chat.agent({ events }). No handler. ──
|
|
277
|
+
// Carries the endpoint, a validated string `key`, and a `type` discriminant. The `key` validates
|
|
278
|
+
// against the event/header/webhook namespaces, like a filter path, and compiles to the stored
|
|
279
|
+
// {body.x} wire template.
|
|
280
|
+
export function chatEvent(options) {
|
|
281
|
+
const { id, endpoint, key, type, filter } = options;
|
|
282
|
+
if (!endpoint?.id) {
|
|
283
|
+
throw new Error(`chat.event("${id}"): an endpoint is required. Declare one with webhooks.endpoint.define() and pass it as { endpoint }.`);
|
|
284
|
+
}
|
|
285
|
+
// Record the descriptor as declared so the indexer can flag it if no agent ever claims it.
|
|
286
|
+
resourceCatalog.registerDeclaredSessionWebhook(id);
|
|
287
|
+
return {
|
|
288
|
+
id,
|
|
289
|
+
type: type ?? id,
|
|
290
|
+
key: normalizeKeyString(key),
|
|
291
|
+
endpointId: endpoint.id,
|
|
292
|
+
source: endpoint.source,
|
|
293
|
+
filter,
|
|
294
|
+
};
|
|
295
|
+
}
|
|
296
|
+
/**
|
|
297
|
+
* Compiles a key template to its stored form. Each placeholder names its namespace the way a filter
|
|
298
|
+
* path does: `{event.x}` reads the event body (stored as `{body.x}`), `{header.x}` a header and
|
|
299
|
+
* `{webhook.x}` the endpoint. A placeholder without one of those namespaces throws.
|
|
300
|
+
*/
|
|
301
|
+
export function normalizeKeyString(key) {
|
|
302
|
+
const namespaceAlternative = (alternative) => {
|
|
303
|
+
const trimmed = alternative.trim();
|
|
304
|
+
if (trimmed.startsWith("event."))
|
|
305
|
+
return `body.${trimmed.slice("event.".length)}`;
|
|
306
|
+
if (trimmed.startsWith("webhook.") || trimmed.startsWith("header."))
|
|
307
|
+
return trimmed;
|
|
308
|
+
const path = trimmed.startsWith("body.") ? trimmed.slice("body.".length) : trimmed;
|
|
309
|
+
throw new Error(`Invalid key "${key}": "{${trimmed}}" needs a namespace. Use {event.${path}} for the event body, {header.<name>} or {webhook.<field>}.`);
|
|
310
|
+
};
|
|
311
|
+
return key.replace(/\{([^{}]+)\}/g, (_match, path) => `{${path.split("||").map(namespaceAlternative).join(" || ")}}`);
|
|
312
|
+
}
|
|
14
313
|
/**
|
|
15
314
|
* Webhook utilities for handling incoming webhook requests
|
|
16
315
|
*/
|
|
17
316
|
export const webhooks = {
|
|
317
|
+
...providerProducers,
|
|
18
318
|
constructEvent,
|
|
19
319
|
SIGNATURE_HEADER_NAME,
|
|
320
|
+
custom: webhookSources.custom,
|
|
321
|
+
stripe: webhookSources.stripe,
|
|
322
|
+
github: webhookSources.github,
|
|
323
|
+
svix: webhookSources.svix,
|
|
324
|
+
standardWebhooks: webhookSources.standardWebhooks,
|
|
325
|
+
square: webhookSources.square,
|
|
326
|
+
discord: webhookSources.discord,
|
|
327
|
+
clerk: webhookSources.clerk,
|
|
328
|
+
resend: webhookSources.resend,
|
|
329
|
+
openai: webhookSources.openai,
|
|
330
|
+
replicate: webhookSources.replicate,
|
|
331
|
+
recallai: webhookSources.recallai,
|
|
332
|
+
brex: webhookSources.brex,
|
|
333
|
+
composio: webhookSources.composio,
|
|
334
|
+
gitlab: webhookSources.gitlab,
|
|
335
|
+
whatsapp: webhookSources.whatsapp,
|
|
336
|
+
endpoint: { define: defineWebhookEndpoint },
|
|
337
|
+
waiter: { create: createWebhookWaiter, wait: waitForWebhookWaiter, cancel: cancelWebhookWaiter },
|
|
20
338
|
};
|
|
21
339
|
async function constructEvent(request, secret) {
|
|
22
340
|
let payload;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"webhooks.js","sourceRoot":"","sources":["../../../src/v3/webhooks.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAC/C,OAAO,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAC;AAEhD;;GAEG;AACH,MAAM,OAAO,YAAa,SAAQ,KAAK;IACrC,YAAY,OAAe;QACzB,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,cAAc,CAAC;IAC7B,CAAC;CACF;AAED,8CAA8C;AAC9C,MAAM,qBAAqB,GAAG,gCAAgC,CAAC;AAwC/D;;GAEG;AACH,MAAM,CAAC,MAAM,QAAQ,GAAa;IAChC,cAAc;IACd,qBAAqB;CACtB,CAAC;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U,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC;IAC9C,CAAC;IACD,OAAO,MAAM,KAAK,CAAC,CAAC;AACtB,CAAC"}
|
package/dist/esm/version.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export const VERSION = "4.
|
|
1
|
+
export const VERSION = "4.8.0-webhooks.20261020092920";
|
|
2
2
|
//# sourceMappingURL=version.js.map
|
package/docs/ai-chat/actions.mdx
CHANGED
|
@@ -73,11 +73,16 @@ onAction: async ({ action }) => {
|
|
|
73
73
|
chat.history.slice(0, -1);
|
|
74
74
|
chat.inject([{ role: "system", content: "Answer formally this time." }]);
|
|
75
75
|
return chat.turn(); // with a one-shot instruction
|
|
76
|
+
|
|
77
|
+
case "ask":
|
|
78
|
+
return chat.turn(action.question); // answer a new user message
|
|
76
79
|
}
|
|
77
80
|
}
|
|
78
81
|
```
|
|
79
82
|
|
|
80
|
-
`
|
|
83
|
+
`chat.turn(message)` appends `message` (a string, or a `UIMessage`) to the history as a user message after the edit, and the turn answers it. That is how a button click becomes a question, such as a follow-up suggestion in [Slack](/webhooks/slack#buttons-that-send-the-agent-an-action).
|
|
84
|
+
|
|
85
|
+
Without a message, `run()` receives the edited history with no incoming user message, the same shape as a `regenerate-message` turn, and its `trigger` is `"action-turn"`, so a `run()` that returns early on `"action"` (the pre-May behaviour, when actions invoked `run()` directly) still answers. Returning anything other than `chat.turn()` or nothing is an error; a response can no longer be returned from `onAction` directly.
|
|
81
86
|
|
|
82
87
|
### Actions and persistence
|
|
83
88
|
|
package/docs/ai-chat/backend.mdx
CHANGED
|
@@ -4,6 +4,8 @@ sidebarTitle: "Backend"
|
|
|
4
4
|
description: "Three approaches to building your chat backend — chat.agent(), session iterator, or raw task primitives."
|
|
5
5
|
---
|
|
6
6
|
|
|
7
|
+
import WebhooksBetaNote from "/snippets/webhooks-beta-note.mdx";
|
|
8
|
+
|
|
7
9
|
There are three abstraction levels for a chat backend. All three speak the same wire protocol, so the [frontend transport](/ai-chat/frontend) works unchanged whichever you pick.
|
|
8
10
|
|
|
9
11
|
| Capability | `chat.agent()` | `chat.createSession()` | Raw primitives |
|
|
@@ -497,6 +499,44 @@ Custom actions let the frontend send structured commands (undo, rollback, edit,
|
|
|
497
499
|
|
|
498
500
|
See [Actions](/ai-chat/actions).
|
|
499
501
|
|
|
502
|
+
### Webhook events and channels
|
|
503
|
+
|
|
504
|
+
<WebhooksBetaNote />
|
|
505
|
+
|
|
506
|
+
Two `chat.agent()` options wire an agent to verified inbound webhooks. `events` claims [`chat.event(...)`](/webhooks/session-routing) descriptors: each verified delivery is routed to this agent's session and arrives at `onAction` as an action (not a turn), so [session routing](/webhooks/session-routing) decides which conversation it lands on. `channels` claims channel connectors that turn an external chat surface into a frontend for the agent: an inbound message runs as a turn through `run()` and the reply is posted back. `slack()` ships in `@trigger.dev/slack`, and `chat.channels.custom(...)` builds a connector for any endpoint without a preset.
|
|
507
|
+
|
|
508
|
+
```ts
|
|
509
|
+
import { webhooks } from "@trigger.dev/sdk";
|
|
510
|
+
import { chat } from "@trigger.dev/sdk/ai";
|
|
511
|
+
import { slack, webhookSource } from "@trigger.dev/slack";
|
|
512
|
+
|
|
513
|
+
const slackEvents = webhooks.endpoint.define({ id: "slack", source: webhookSource() });
|
|
514
|
+
const stripe = webhooks.endpoint.define({ id: "stripe", source: webhooks.stripe() });
|
|
515
|
+
|
|
516
|
+
export const orderEvents = chat.event({
|
|
517
|
+
id: "order-events",
|
|
518
|
+
endpoint: stripe,
|
|
519
|
+
key: "{event.data.object.customer}",
|
|
520
|
+
// invoices always carry a customer; events without one would have no session to go to
|
|
521
|
+
filter: "event.type startsWith 'invoice.'",
|
|
522
|
+
type: "order.event",
|
|
523
|
+
});
|
|
524
|
+
|
|
525
|
+
export const myChat = chat.agent({
|
|
526
|
+
id: "my-chat",
|
|
527
|
+
events: [orderEvents],
|
|
528
|
+
channels: [slack({ id: "support-slack", endpoint: slackEvents, token: process.env.SLACK_BOT_TOKEN! })],
|
|
529
|
+
onAction: async ({ action }) => {
|
|
530
|
+
// A verified order-events delivery arrives here as an action.
|
|
531
|
+
},
|
|
532
|
+
run: async (payload) => {
|
|
533
|
+
// Inbound Slack messages run here as normal turns.
|
|
534
|
+
},
|
|
535
|
+
});
|
|
536
|
+
```
|
|
537
|
+
|
|
538
|
+
See [session routing](/webhooks/session-routing) and [channels](/webhooks/channels). For the interactive approvals layer, where a turn pauses on a human decision (buttons in the thread) and resumes on the click, see [human-in-the-loop](/webhooks/human-in-the-loop).
|
|
539
|
+
|
|
500
540
|
### Chat history
|
|
501
541
|
|
|
502
542
|
Imperative API for reading and modifying the accumulated message history. Works from any hook (`onAction`, `onTurnStart`, `onBeforeTurnComplete`, `onTurnComplete`, `hydrateMessages`) or from `run()` and AI SDK tools.
|