Back to APIs

Automate sending notifications across multiple channels.

Using the Novu API with Trigger.dev

You can use Trigger.dev with any existing Node SDK or even just using fetch. Using io.runTask makes your Novu background job resumable and appear in our dashboard.

Use io.runTask() and the official SDK or fetch.

Use our HTTP endpoint to subscribe to webhooks

Example code using Novu

Below are some working code examples of how you can use Novu with Trigger.dev. These samples are open source and maintained by the community, you can copy and paste them into your own projects.

1
import { TriggerClient, verifyRequestSignature } from "@trigger.dev/sdk";
2
3
// Go to Novu Dashboard > Integrations Store
4
// Click Add > Go with "Push Webhook"
5
// Set the Webhook URL and Hmac Key (say "Test", for example)
6
// Go to Workflows -> Add a workflow
7
// Use the default trigger and add a push webhook call
8
// Enter the subscriberID that'll listen to the channel
9
// Run Trigger / Send Notification to trigger the webhook
10
const novu = client.defineHttpEndpoint({
11
id: "novu",
12
source: "novu.co",
13
icon: "novu",
14
verify: async (request) => {
15
if (!process.env.NOVU_SIGNING_SECRET) {
16
return { success: false, reason: "No Novu Signing Secret present." };
17
}
18
return await verifyRequestSignature({
19
request,
20
algorithm: "sha256",
21
headerName: "x-novu-signature",
22
secret: process.env.NOVU_SIGNING_SECRET,
23
});
24
},
25
});
26
27
client.defineJob({
28
id: "http-novu",
29
name: "HTTP Novu",
30
version: "1.0.0",
31
enabled: true,
32
trigger: novu.onRequest(),
33
run: async (request, io, ctx) => {
34
const body = await request.json();
35
await io.logger.info(`Body`, body);
36
},
37
});