Skip to content

Commit db4fb9e

Browse files
authored
docs: Add Hookdeck example (#3005)
Add documentation for integrating Hookdeck with Trigger.dev to receive webhooks and forward them to Trigger.dev tasks. <!-- devin-review-badge-begin --> --- <a href="https://app.devin.ai/review/triggerdotdev/trigger.dev/pull/3005"> <picture> <source media="(prefers-color-scheme: dark)" srcset="https://static.devin.ai/assets/gh-open-in-devin-review-dark.svg?v=1"> <img src="https://static.devin.ai/assets/gh-open-in-devin-review-light.svg?v=1" alt="Open with Devin"> </picture> </a> <!-- devin-review-badge-end -->
1 parent c059570 commit db4fb9e

File tree

4 files changed

+78
-1
lines changed

4 files changed

+78
-1
lines changed

docs/docs.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -352,7 +352,8 @@
352352
"guides/frameworks/webhooks-guides-overview",
353353
"guides/frameworks/nextjs-webhooks",
354354
"guides/frameworks/remix-webhooks",
355-
"guides/examples/stripe-webhook"
355+
"guides/examples/stripe-webhook",
356+
"guides/examples/hookdeck-webhook"
356357
]
357358
}
358359
]
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
---
2+
title: "Trigger tasks from Hookdeck webhooks"
3+
sidebarTitle: "Hookdeck webhooks"
4+
description: "This example demonstrates how to use Hookdeck to receive webhooks and trigger Trigger.dev tasks."
5+
---
6+
7+
## Overview
8+
9+
This example shows how to use [Hookdeck](https://hookdeck.com) 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.
10+
11+
## Key features
12+
13+
- Use Hookdeck as your webhook endpoint for external services
14+
- Hookdeck forwards webhooks directly to Trigger.dev tasks via the API
15+
- All webhooks are logged and replayable in Hookdeck
16+
17+
## Setting up Hookdeck
18+
19+
You'll configure everything in the [Hookdeck dashboard](https://dashboard.hookdeck.com). No code changes needed in your app.
20+
21+
### 1. Create a destination
22+
23+
In Hookdeck, create a new [destination](https://hookdeck.com/docs/destinations) with the following settings:
24+
25+
- **URL**: `https://api.trigger.dev/api/v1/tasks/<task-id>/trigger` (replace `<task-id>` with your task ID)
26+
- **Method**: POST
27+
- **Authentication**: Bearer token (use your `TRIGGER_SECRET_KEY` from Trigger.dev)
28+
29+
### 2. Add a transformation
30+
31+
Create a [transformation](https://hookdeck.com/docs/transformations) to wrap the webhook body in the `payload` field that Trigger.dev expects:
32+
33+
```javascript
34+
addHandler("transform", (request, context) => {
35+
request.body = { payload: { ...request.body } };
36+
return request;
37+
});
38+
```
39+
40+
### 3. Create a connection
41+
42+
Create a [connection](https://hookdeck.com/docs/connections) that links your source (where webhooks come from) to the destination and transformation you created above.
43+
44+
## Task code
45+
46+
This task will be triggered when Hookdeck forwards a webhook to the Trigger.dev API.
47+
48+
```ts trigger/webhook-handler.ts
49+
import { task } from "@trigger.dev/sdk";
50+
51+
export const webhookHandler = task({
52+
id: "webhook-handler",
53+
run: async (payload: Record<string, unknown>) => {
54+
// The payload contains the original webhook data from the external service
55+
console.log("Received webhook:", payload);
56+
57+
// Add your custom logic here
58+
},
59+
});
60+
```
61+
62+
## Testing your setup
63+
64+
To test everything is working:
65+
66+
1. Set up your destination, transformation, and connection in [Hookdeck](https://dashboard.hookdeck.com)
67+
2. Send a test webhook to your Hookdeck source URL (use the Hookdeck Console or cURL)
68+
3. Check the Hookdeck dashboard to verify the webhook was received and forwarded
69+
4. Check the [Trigger.dev dashboard](https://cloud.trigger.dev) to see the successful run of your task
70+
71+
For more information on setting up Hookdeck, refer to the [Hookdeck Documentation](https://hookdeck.com/docs).

docs/guides/frameworks/webhooks-guides-overview.mdx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,10 @@ A webhook handler is code that executes in response to an event. They can be end
3131
How to create a Stripe webhook handler and trigger a task when a 'checkout session completed'
3232
event is received.
3333
</Card>
34+
<Card title="Hookdeck webhooks" icon="webhook" href="/guides/examples/hookdeck-webhook">
35+
Use Hookdeck to receive webhooks and forward them to Trigger.dev tasks with logging and replay
36+
capabilities.
37+
</Card>
3438
<Card
3539
title="Supabase database webhooks guide"
3640
icon="webhook"

docs/guides/introduction.mdx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ Get set up fast using our detailed walk-through guides.
3737
| [Python web crawler](/guides/python/python-crawl4ai) | Use Python, Crawl4AI and Playwright to create a headless web crawler |
3838
| [Sequin database triggers](/guides/frameworks/sequin) | Trigger tasks from database changes using Sequin |
3939
| [Stripe webhooks](/guides/examples/stripe-webhook) | Trigger tasks from incoming Stripe webhook events |
40+
| [Hookdeck webhooks](/guides/examples/hookdeck-webhook) | Use Hookdeck to receive webhooks and forward them to Trigger.dev tasks |
4041
| [Supabase database webhooks](/guides/frameworks/supabase-edge-functions-database-webhooks) | Trigger tasks using Supabase database webhooks |
4142
| [Supabase edge function hello world](/guides/frameworks/supabase-edge-functions-basic) | Trigger tasks from Supabase edge function |
4243
| [Using webhooks in Next.js](/guides/frameworks/nextjs-webhooks) | Trigger tasks from a webhook in Next.js |

0 commit comments

Comments
 (0)