diff --git a/.changeset/webhook-setup-prompts.md b/.changeset/webhook-setup-prompts.md new file mode 100644 index 00000000000..94b34f4da76 --- /dev/null +++ b/.changeset/webhook-setup-prompts.md @@ -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. diff --git a/apps/webapp/app/v3/webhookSetupPrompt.ts b/apps/webapp/app/v3/webhookSetupPrompt.ts index a9363f05785..892190a0bbb 100644 --- a/apps/webapp/app/v3/webhookSetupPrompt.ts +++ b/apps/webapp/app/v3/webhookSetupPrompt.ts @@ -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)]; + 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.", diff --git a/apps/webapp/test/webhookSetupPrompt.test.ts b/apps/webapp/test/webhookSetupPrompt.test.ts index 8108dadc1ae..88b12ea952a 100644 --- a/apps/webapp/test/webhookSetupPrompt.test.ts +++ b/apps/webapp/test/webhookSetupPrompt.test.ts @@ -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( + 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"); + + 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); diff --git a/packages/core/src/v3/webhooks/index.ts b/packages/core/src/v3/webhooks/index.ts index 0731e111304..0e8c3a360a2 100644 --- a/packages/core/src/v3/webhooks/index.ts +++ b/packages/core/src/v3/webhooks/index.ts @@ -524,10 +524,11 @@ const svixFamilySetupPrompt = [ */ export const webhookSetupPrompts: Partial> = { 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="" -d "enabled_events[]="', "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"), @@ -543,8 +544,8 @@ export const webhookSetupPrompts: Partial 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: [