Manage incidents, schedules, and more with PagerDuty.

Using the PagerDuty API with Trigger.dev

You can use Trigger.dev with any existing Node SDK or even just using fetch. Using io.runTask makes your PagerDuty 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 PagerDuty

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

    import crypto from "crypto";
    import { TriggerClient } from "@trigger.dev/sdk";
    // Create an HTTP endpoint to listen to PagerDuty webhooks.
    // (This will create the endpoint URL on the `trigger.dev` dashboard)
    // Create a PagerDuty account (if you don't have one).
    // Go to Integrations -> Generic Webhooks and setup the subscription.
    // Copy the secret shown in popup to PAGERDUTY_WEBHOOK_SIGNING_SECRET in the .env file.
    const pagerduty = client.defineHttpEndpoint({
    id: "pagerduty",
    source: "pagerduty.com",
    icon: "pagerduty",
    verify: async (request) => {
    const bodyText = await request.text();
    const signatures = request.headers.get("X-PagerDuty-Signature");
    if (!signatures) {
    return { success: false };
    }
    const signature = crypto
    .createHmac("sha256", process.env.PAGERDUTY_WEBHOOK_SIGNING_SECRET!)
    .update(bodyText)
    .digest("hex");
    const signatureWithVersion = "v1=" + signature;
    const signatureList = signatures.split(",");
    return {
    success: signatureList.indexOf(signatureWithVersion) > -1,
    };
    },
    });
    client.defineJob({
    id: "http-pagerduty",
    name: "HTTP PagerDuty",
    version: "1.0.0",
    enabled: true,
    trigger: pagerduty.onRequest(),
    run: async (request, io, ctx) => {
    const body = await request.json();
    await io.logger.info(`Body`, body);
    },
    });
    ,