Teddarific / trigger.dev

✨ Trigger.dev is an open-source platform that makes it easy for developers to create event-driven background tasks directly in their code.

Home Page:https://trigger.dev

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

✨ Trigger.dev

The developer-first open source Zapier alternative.

Trigger.dev is an open source platform that makes it easy for developers to create event-driven background tasks directly in their code. Build, test and run workflows locally using our SDK. Subscribe to webhooks, schedule jobs, run background jobs and add long delays easily and reliably. In our web app you get full visibility of every run your workflow has ever made making it easier to monitor and debug.

 

⭐️ Features:

  • 👂 Easily subscribe to webhooks — they work locally without tunnelling.
  • 🔥 Fire your own custom events—a single event can trigger multiple workflows.
  • 📆 Schedule workflows—easily repeat tasks or use CRON syntax for advanced cases.
  • 🚦 Add long delays inside workflows (up to a year) and they will pick up where they left off.
  • 🤝 When your server goes down it’s not a problem, workflows will reconnect and continue.
  • 🪧 View every step of every run, with data, previews and errors.
  • 👋 Connect to and authenticate with APIs using our custom integrations.
  • 🚗 If you have a custom use case, we support Fetch for calling any HTTP endpoint or webhooks for subscribing to events from APIs.
  • 📡 All API calls are automatically retried with exponential back off.
  • 😀 TypeScript SDK, so whether you’re using JavaScript or TypeScript you will have a great experience.

 

🌱 Documentation:

 

🔬 Anatomy of a workflow

  • You create workflows in code on your server using our SDK
  • Each API integration is a separate package, e.g. @trigger.dev/slack
  • Each workflow has an event that triggers it, e.g. github.events.newStarEvent, scheduleEvent, customEvent
  • Each workflow has a run function that is called when the event is triggered
  • If we don't have an integration for the API you want to use, you can use fetch to call any HTTP endpoint and webhookEvent to subscribe to webhooks

Example workflows

Post to Slack when a GitHub issue is created or modified

Integrations required: Slack, GitHub

import { Trigger } from "@trigger.dev/sdk";
import * as github from "@trigger.dev/github";
import * as slack from "@trigger.dev/slack";

new Trigger({
  id: "new-github-star-to-slack",
  name: "New GitHub Star: triggerdotdev/trigger.dev",
  apiKey: "<my_api_key>",
  on: github.events.newStarEvent({
    repo: "triggerdotdev/trigger.dev",
  }),
  run: async (event) => {
    await slack.postMessage("github-stars", {
      channelName: "github-stars",
      text: `New GitHub star from \n<${event.sender.html_url}|${event.sender.login}>`,
    });
  },
}).listen();
Welcome email drip campaign

Integrations required: Slack, Resend

import { customEvent, Trigger, sendEvent } from "@trigger.dev/sdk";
import * as resend from "@trigger.dev/resend";
import * as slack from "@trigger.dev/slack";
import React from "react";
import { z } from "zod";
import { getUser } from "../db";
import { InactiveEmail, TipsEmail, WelcomeEmail } from "./email-templates";

new Trigger({
  id: "welcome-email-campaign",
  name: "Welcome email drip campaign",
  apiKey: "<my_api_key>",
  on: customEvent({
    name: "user.created",
    schema: z.object({
      userId: z.string(),
    }),
  }),
  async run(event, context) {
    //get the user data from the database
    const user = await getUser(event.userId);

    await slack.postMessage("send-to-slack", {
      channelName: "new-users",
      text: `New user signed up: ${user.name} (${user.email})`,
    });

    //Send the first email
    const welcomeResponse = await resend.sendEmail("welcome-email", {
      from: "Trigger.dev <james@email.trigger.dev>",
      replyTo: "James <james@trigger.dev>",
      to: user.email,
      subject: "Welcome to Trigger.dev",
      react: <WelcomeEmail name={user.name} />,
    });
    await context.logger.debug(
      `Sent welcome email to ${welcomeResponse.to} with id ${welcomeResponse.id}`
    );

    //wait 1 day, check if the user has created a workflow and send the appropriate email
    await context.waitFor("wait-a-while", { days: 1 });
    const updatedUser = await getUser(event.userId);

    if (updatedUser.hasOnboarded) {
      await resend.sendEmail("onboarding-complete", {
        from: "Trigger.dev <james@email.trigger.dev>",
        replyTo: "James <james@trigger.dev>",
        to: updatedUser.email,
        subject: "Pro tips for workflows",
        react: <TipsEmail name={updatedUser.name} />,
      });
    } else {
      await resend.sendEmail("onboarding-incomplete", {
        from: "Trigger.dev <james@email.trigger.dev>",
        replyTo: "James <james@trigger.dev>",
        to: updatedUser.email,
        subject: "Help with your first workflow",
        react: <InactiveEmail name={updatedUser.name} />,
      });
    }
  },
}).listen();

More examples here

 

👀 Viewing runs:

One of the most powerful features of Trigger.dev is the runs page. All of the steps in a workflow, including the initial event, can be viewed in detail. See the status / output of each step, the logs, rich previews, errors and much more.

Viewing runs

 

🏠 Running Trigger.dev locally:

To run Trigger.dev locally, follow these steps.

 

👏 Contributing:

We are open source and love contributions!

 

🧘‍♂️ Self-hosting guide:

Please subscribe to the GitHub issue to be notified when it's live.

 

📧 Support & contact:

About

✨ Trigger.dev is an open-source platform that makes it easy for developers to create event-driven background tasks directly in their code.

https://trigger.dev

License:Other


Languages

Language:TypeScript 98.4%Language:JavaScript 0.6%Language:CSS 0.3%Language:Dockerfile 0.3%Language:PLpgSQL 0.2%Language:Shell 0.2%