docs/guides/examples/hookdeck-webhook.mdx
This example shows how to use Hookdeck as your webhook infrastructure to trigger Trigger.dev tasks. Hookdeck receives webhooks from external services, and forwards them directly to the Trigger.dev API. This gives you the best of both worlds: Hookdeck's webhook management, logging, and replay capabilities, combined with Trigger.dev's reliable task execution.
You'll configure everything in the Hookdeck dashboard. No code changes needed in your app.
In Hookdeck, create a new destination with the following settings:
https://api.trigger.dev/api/v1/tasks/<task-id>/trigger (replace <task-id> with your task ID)TRIGGER_SECRET_KEY from Trigger.dev)Create a transformation to wrap the webhook body in the payload field that Trigger.dev expects:
addHandler("transform", (request, context) => {
request.body = { payload: { ...request.body } };
return request;
});
Create a connection that links your source (where webhooks come from) to the destination and transformation you created above.
This task will be triggered when Hookdeck forwards a webhook to the Trigger.dev API.
import { task } from "@trigger.dev/sdk";
export const webhookHandler = task({
id: "webhook-handler",
run: async (payload: Record<string, unknown>) => {
// The payload contains the original webhook data from the external service
console.log("Received webhook:", payload);
// Add your custom logic here
},
});
To test everything is working:
For more information on setting up Hookdeck, refer to the Hookdeck Documentation.