Skip to content

Commit 093d0cd

Browse files
committed
fix(sdk,slack): move the Slack webhook source into @trigger.dev/slack
The generic webhooks.slack() SDK source was auto-generated from the core provider config, which carries only the HMAC verifier. Slack additionally needs the one-time url_verification handshake (before an Event Subscriptions URL can be saved) and form-encoded interactivity parsing, so an endpoint built from webhooks.slack() could never be connected. Drop slack from the generated SDK producers (runtime + type) and export webhookSource() from @trigger.dev/slack, which carries the handshake + formPayload the connector already uses. Users get a plain Slack webhook source from webhookSource(), or the full chat channel from slack(). Core's slack config stays for server-side verification.
1 parent b9797ec commit 093d0cd

2 files changed

Lines changed: 26 additions & 14 deletions

File tree

packages/slack/src/index.ts

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,20 @@ export function mentions(...botUserIds: string[]): string {
132132
return `(${clauses.join(" || ")})`;
133133
}
134134

135+
/**
136+
* A Slack webhook source for `webhook({ source })`: HMAC signature verification, the one-time
137+
* `url_verification` handshake Slack requires before an Event Subscriptions URL can be saved, and
138+
* form-encoded interactivity parsing. Paste your Slack app's Signing Secret as the endpoint secret.
139+
* For a full chat-agent frontend (per-thread sessions, replies, HITL) use `slack()` instead.
140+
*/
141+
export function webhookSource<TEvent = SlackMessageEvent>(): WebhookSource<TEvent> {
142+
return {
143+
provider: "slack",
144+
verifier: { kind: "config", config: SLACK_VERIFIER, handshake: SLACK_HANDSHAKE },
145+
secretProvisioning: "provider",
146+
};
147+
}
148+
135149
/**
136150
* Slack as a chat frontend for an agent. List on `chat.agent({ channels: [slack({...})] })`: verified
137151
* Slack messages in a thread are routed to a durable per-thread session and run as turns, and the reply
@@ -142,11 +156,7 @@ export function slack<TEvent = SlackMessageEvent>(
142156
options: SlackChannelOptions<TEvent>
143157
): ChannelConnector<TEvent> {
144158
const apiBaseUrl = options.apiBaseUrl ?? SLACK_API_BASE_URL;
145-
const source: WebhookSource<TEvent> = {
146-
provider: "slack",
147-
verifier: { kind: "config", config: SLACK_VERIFIER, handshake: SLACK_HANDSHAKE },
148-
secretProvisioning: "provider",
149-
};
159+
const source: WebhookSource<TEvent> = webhookSource<TEvent>();
150160
const messageFilter = options.filter
151161
? `${SELF_MESSAGE_GUARD} && (${options.filter})`
152162
: SELF_MESSAGE_GUARD;

packages/trigger-sdk/src/v3/webhooks.ts

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -189,15 +189,17 @@ export type ProviderProducers = {
189189
};
190190

191191
export const providerProducers = Object.fromEntries(
192-
Object.entries(webhookProviderConfigs).map(([provider, entry]) => [
193-
provider,
194-
() => ({
192+
Object.entries(webhookProviderConfigs)
193+
.filter(([provider]) => provider !== "slack")
194+
.map(([provider, entry]) => [
195195
provider,
196-
verifier: { kind: "config" as const, config: entry.config() },
197-
secretProvisioning: entry.secretProvisioning,
198-
}),
199-
])
200-
) as ProviderProducers;
196+
() => ({
197+
provider,
198+
verifier: { kind: "config" as const, config: entry.config() },
199+
secretProvisioning: entry.secretProvisioning,
200+
}),
201+
])
202+
) as Omit<ProviderProducers, "slack">;
201203

202204
// ── webhook() entry: single-callback IoC, infers event from source ──
203205
export type WebhookOnEventParams<TEvent> = {
@@ -371,7 +373,7 @@ interface Webhooks {
371373
/**
372374
* Webhook utilities for handling incoming webhook requests
373375
*/
374-
export const webhooks: Webhooks & ProviderProducers = {
376+
export const webhooks: Webhooks & Omit<ProviderProducers, "slack"> = {
375377
...providerProducers,
376378
constructEvent,
377379
SIGNATURE_HEADER_NAME,

0 commit comments

Comments
 (0)