Last update: 2025-05-08T12:27:33.000Z
Content:
---
title: "Reliable scheduling with Trigger.dev · Tinybird Docs"
theme-color: "#171612"
description: "Learn how to create complex, reliable scheduling with Trigger.dev"
inkeep:version: "forward"
---




# Reliable scheduling with Trigger.dev [¶](https://www.tinybird.co/docs/forward/work-with-data/publish-data/guides/reliable-scheduling-with-trigger#reliable-scheduling-with-trigger-dev)

Copy as MD [Trigger.dev](https://trigger.dev/) is an open source background job platform. With Trigger.dev you can easily create, schedule, and manage background jobs using code.

Read on to learn how to create complex, reliable scheduling with Trigger.dev.

## Before you start [¶](https://www.tinybird.co/docs/forward/work-with-data/publish-data/guides/reliable-scheduling-with-trigger#before-you-start)

Before you start, ensure:

- You have a[  Trigger.dev account](https://trigger.dev/)  .
- You have a[  Tinybird workspace](https://www.tinybird.co/)  .

## Create your first trigger task [¶](https://www.tinybird.co/docs/forward/work-with-data/publish-data/guides/reliable-scheduling-with-trigger#create-your-first-trigger-task)

The [tinybird-trigger-tasks package](https://www.npmjs.com/package/@sdairs/tinybird-trigger-tasks) implements tasks for Tinybird copy pipes and the Query API. You can [find the source code in the @sdairs/tinybird-trigger repo](https://github.com/sdairs/tinybird-trigger).

1. Create a working directory, and run `npx trigger.dev@latest init`   to connect the project to Trigger.dev.
2. Inside the `trigger`   directory, install the npm package with `npm install @sdairs/tinybird-trigger-tasks`  .
3. Create a new file called `myTask.ts`   and add the following code:

import { task } from "@trigger.dev/sdk/v3";
import { tinybirdCopyTask } from "@sdairs/tinybird-trigger-tasks";

export const exampleExecutor = task({
    id: "example-executor",
    run: async (payload, { ctx }) => {
        console.log("Example executor task is running");

        // Run a copy job
        const copyResult = await tinybirdCopyTask.triggerAndWait({ pipeId: <COPY_PIPE_ID> });
        console.log(copyResult);

    },
});
1. Create a new pipe using the following SQL:

SELECT number + 1 AS value
FROM numbers(100)
1. Name the pipe `my_copy`   and deploy the changes.
2. Update `myTask.ts`   , replacing `<COPY_PIPE_ID>`   with the name of your pipe, `my_copy`   in this case.
3. Create a `.env`   file in your directory root.
4. Go to your Tinybird workspace and copy the Admin Token, then add it to the `.env`   file as follows:

TINYBIRD_TOKEN=p.eyJ...
1. Run `npx trigger.dev@latest dev`   to push the task to Trigger.dev.
2. Go to your Trigger.dev dashboard, and perform a test run to trigger the task and the copy pipe.
3. Go to your Tinybird workspace and check the copy pipe results.

## See also [¶](https://www.tinybird.co/docs/forward/work-with-data/publish-data/guides/reliable-scheduling-with-trigger#see-also)

- [  Trigger.dev quick start](https://trigger.dev/docs/quick-start)
- [  tinybird-trigger repo](https://github.com/sdairs/tinybird-trigger)
- [  YouTube: Using Trigger.dev with Tinybird for code-first background job execution](https://www.youtube.com/watch?v=0TcQfcMrGNw)


