Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/webhook-setup-prompts.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@trigger.dev/core": patch
---

Webhook setup prompts now match each provider's current setup. Stripe webhooks can be set up from the Dashboard by revealing the signing secret there, Discord endpoints verify on the first try because the public key is stored before the Endpoint URL is saved, and Autumn webhooks can be added self-serve without contacting support.
11 changes: 9 additions & 2 deletions apps/webapp/app/v3/webhookSetupPrompt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,12 +120,19 @@ export function renderWebhookSetupPrompt(
}
}

const registerStep = `Register the webhook URL with ${source}, following the ${source} instructions below.`;
// A public key exists before the webhook does, and some key-pair sources send a signed
// verification request as soon as the URL is saved, so store the key first.
const [firstStep, secondStep] = asymmetric
? [`${secretStep(endpoint, asymmetric)} Do this before registering the URL.`, registerStep]
: [registerStep, secretStep(endpoint, asymmetric)];
Comment on lines +126 to +128

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Custom public-key setup blocked by ordering

When a custom provider reveals its public key upon webhook creation, firstStep demands the key before URL registration. Users cannot complete the setup steps in order.

Learn more

The SDK accepts arbitrary asymmetric verifier configs through webhooks.custom, and callers can supply provider-specific setup instructions. Some providers disclose the public key only when their webhook is created with a destination URL. For these providers, forcing key storage before URL registration makes the prompt impossible to follow, while the former URL-first order allowed setup. The Discord preset specifically needs the opposite order because it checks a signed PING when the URL is saved.

Example: A caller uses webhooks.custom for a provider that returns its public key after creating a webhook with https://example.test/ingest. The prompt asks for the key in step one, but the user cannot retrieve it until completing step two.

Recommended fix: Restrict key-first ordering to providers or artifacts that require pre-registration verification, such as Discord, or allow the source-specific setup instructions to select the ordering. Keep URL-first ordering when the key is available only after creation.

Devin Review


Was this helpful? React with 👍 or 👎 to provide feedback.


lines.push(
"",
"## Steps",
"",
`1. Register the webhook URL with ${source}, following the ${source} instructions below.`,
`2. ${secretStep(endpoint, asymmetric)}`,
`1. ${firstStep}`,
`2. ${secondStep}`,
`3. Call \`get_webhook_endpoint_details\` and check that \`secretSet\` is true. If ${source} can send a test event, send one and confirm it shows up on the dashboard page above.`,
"",
"Treat the signing secret as a credential: pass it straight to the tool or API, and never print it, log it, write it to a file or commit it.",
Expand Down
19 changes: 19 additions & 0 deletions apps/webapp/test/webhookSetupPrompt.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,25 @@ describe("renderWebhookSetupPrompt", () => {
expect(prompt).toContain("pass `previousSecretTtlSeconds`");
});

it("stores an asymmetric source's public key before registering the URL", () => {
const discord = renderWebhookSetupPrompt(
Comment on lines +91 to +92

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Missing regression note for new test

The new unit test has no required // Catches: <bug> comment. Its unique regression remains undocumented.

Suggested change
it("stores an asymmetric source's public key before registering the URL", () => {
const discord = renderWebhookSetupPrompt(
// Catches: Discord URL registration before public-key storage rejects the verification PING.
it("stores an asymmetric source's public key before registering the URL", () => {
const discord = renderWebhookSetupPrompt(

Devin Review


Was this helpful? React with 👍 or 👎 to provide feedback.

endpoint({
source: "discord",
setupPrompt: webhookSetupPrompts.discord ?? null,
verifierArtifact: { kind: "preset", preset: "discord", config: discordVerifierConfig() },
}),
context
);
expect(discord).toMatch(
/1\. discord signs deliveries with a key pair\..*before registering the URL\./
);
expect(discord).toContain("2. Register the webhook URL with discord");
Comment on lines +100 to +103

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Key-order test misses key storage

If secretStep stops telling users to store the public key, the new regex still passes. It checks surrounding copy, not that step one contains set_webhook_secret.

Learn more

The test claims to guard key-first setup, but its regex does not inspect the part of step one that tells the agent to call set_webhook_secret. The source could lose that instruction without breaking this test. Repository testing guidance asks new tests to catch a concrete regression and avoid coupling to copy.

Example: Change secretStep to return discord signs deliveries with a key pair. Copy its public key. The prompt no longer tells the agent where to store it, but the new regex still matches discord signs deliveries with a key pair. and the appended before registering the URL..

Recommended fix: Assert that step one contains set_webhook_secret before the step-two registration instruction, without matching the entire natural-language sentence.

Devin Review


Was this helpful? React with 👍 or 👎 to provide feedback.


const stripe = renderWebhookSetupPrompt(endpoint(), context);
expect(stripe).toContain("1. Register the webhook URL with stripe");
expect(stripe).toContain("2. stripe issues the signing secret");
});

it("asks which events to send when nothing subscribes yet", () => {
const prompt = renderWebhookSetupPrompt(endpoint({ routingTargets: [] }), context);

Expand Down
14 changes: 8 additions & 6 deletions packages/core/src/v3/webhooks/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -524,10 +524,11 @@ const svixFamilySetupPrompt = [
*/
export const webhookSetupPrompts: Partial<Record<WebhookPresetId | WebhookProviderId, string>> = {
stripe: [
"Stripe issues the signing secret when a webhook endpoint is created, and returns it only in the create response.",
"Create the endpoint with the Stripe CLI or API, not the Dashboard, so you can read the secret from the response:",
"Stripe issues a signing secret (it starts with whsec_) for each webhook endpoint.",
"Create the endpoint with the Stripe CLI or API to read the secret from the response:",
' stripe webhook_endpoints create -d url="<webhook URL>" -d "enabled_events[]=<event type>"',
"or POST https://api.stripe.com/v1/webhook_endpoints with `url` and `enabled_events[]`. The response's `secret` field is the signing secret.",
"In the Stripe Dashboard, the user can instead open the Webhooks tab in Workbench, choose Create an event destination with the Snapshot payload format and the webhook URL, then choose Reveal secret on the destination's settings page.",
"Choose enabled_events from the subscribers' filters, which compare `event.type`. Use `*` only when a subscriber has no filter.",
"Use a test mode key for dev and staging environments and a live mode key for production.",
].join("\n"),
Expand All @@ -543,8 +544,8 @@ export const webhookSetupPrompts: Partial<Record<WebhookPresetId | WebhookProvid
"standard-webhooks": svixFamilySetupPrompt,
discord: [
"These settings are in the Discord Developer Portal (https://discord.com/developers/applications); tell the user each step.",
"1. Open the application, then its Webhooks page. Set the Endpoint URL to the webhook URL, turn Events on and select the event types the subscribers need. Discord sends a PING that the endpoint answers once it is deployed.",
"2. The public key is on the application's General Information page, under Public Key.",
"1. Open the application. The public key is on its General Information page, under Public Key. Store it on the endpoint first: Discord sends a signed PING when the Endpoint URL is saved, and the endpoint can only answer it once the key is set.",
Comment thread
jackbridger marked this conversation as resolved.
Resolved
"2. Open the application's Webhooks page. Set the Endpoint URL to the webhook URL, turn Events on and select the event types the subscribers need.",
Comment thread
jackbridger marked this conversation as resolved.
Resolved
].join("\n"),
shopify: [
"Shopify signs webhooks with the app's client secret, or for webhooks created in the store admin, with the key shown on that page.",
Expand All @@ -567,8 +568,9 @@ export const webhookSetupPrompts: Partial<Record<WebhookPresetId | WebhookProvid
"Subscribers' filters compare `event.event_type`, for example `note.generated`.",
].join("\n"),
autumn: [
"Autumn's webhooks are in beta, and Autumn support turns them on per account.",
"Once they are on, add the webhook URL as an endpoint in the Autumn dashboard's webhook settings and select the event types the subscribers need. Autumn delivers through Svix, which shows the endpoint's signing secret (it starts with whsec_); store it on Trigger.dev.",
"These settings are in the Autumn dashboard; tell the user each step.",
"Under Developer > Webhooks, choose Add Endpoint, enter the webhook URL and select the event types the subscribers need. Autumn delivers through Svix, which shows the endpoint's signing secret (it starts with whsec_); store it on Trigger.dev.",
"Send Test Event on the endpoint confirms delivery.",
"Subscribers' filters compare `event.type`, for example `billing.updated`.",
].join("\n"),
supabase: [
Expand Down
Loading