Post messages to Slack when events occur.

Using our official Slack integration

  • Create any tasks possible with the Slack API.

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

  • Example code using Slack

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

    import { TriggerClient } from "@trigger.dev/sdk";
    import { Github, events } from "@trigger.dev/github";
    import { Slack } from "@trigger.dev/slack";
    const github = new Github({ id: "github" });
    const slack = new Slack({ id: "slack" });
    // This Job will run when a star is added or removed from the triggerdotdev/trigger.dev repo
    client.defineJob({
    id: "github-new-star-to-slack",
    name: "GitHub: new star to slack",
    version: "1.0.0",
    trigger: github.triggers.repo({
    event: events.onStar,
    owner: "<your-org-name>",
    repo: "<your-repo-name>",
    }),
    integrations: {
    slack,
    },
    run: async (payload, io, ctx) => {
    await io.slack.postMessage("post message", {
    channel: process.env.SLACK_CHANNEL_ID!,
    text: `New GitHub star from ${payload.sender.html_url}, ${payload.sender.name}. Your new GitHub star count is ${payload.repository.stargazers_count}.`,
    });
    },
    });

    Full-stack Slack example projects

    ,