Repetitive tasks are the silent productivity killers in any business. Generating daily reports, syncing data between services, sending welcome emails—these small, manual actions add up, consuming valuable time and opening the door for human error. What if you could make them... disappear? Not by ignoring them, but by teaching your systems to handle them automatically.
This is the magic of event-driven automation. It's about turning any business process into an on-demand, automated service. With trigger.do, you can move from manual to magical, and we're going to show you how.
This guide will walk you through the core concepts of event-driven automation and help you build your very first automated workflow using a simple, powerful API. Let's trigger anything and automate everything.
At its core, event-driven automation is a simple but powerful concept:
An event happens, which acts as a trigger to automatically run a pre-defined workflow.
Think of it like a set of digital dominoes. You don't have to knock over each one manually. You just have to tip the first one (the trigger), and the rest of the chain (the workflow) falls into place perfectly, every single time.
With trigger.do, the building blocks are just as simple:
Before you can build a workflow, you need to decide what will start it. trigger.do offers several types of workflow triggers to cover any use case.
Perfect for recurring tasks. Do you need to run a cleanup job every night at midnight? Generate a sales report every Monday at 9 AM? A scheduled trigger uses standard cron syntax to execute workflows on a precise, repeating schedule. This is the cornerstone of reliable, time-based scheduled tasks.
The key to real-time integration. A webhook is a unique URL that listens for incoming HTTP requests. When another service (like Stripe, GitHub, or your own application's backend) sends data to that URL, it instantly triggers your workflow. This is ideal for reacting to events as they happen, such as a new user signup, a completed payment, or a submitted form. This is the power of webhook automation.
Talk is cheap. Let's see the code. We're going to create a classic automated task: a daily sales report that runs every morning at 9:00 AM UTC.
We have an existing workflow named generate-sales-report. This workflow knows how to query our database, compile sales data, and email it to the team. Our goal is to run this workflow automatically every day, without any manual intervention.
Using the @do-sdk/agent, we can define and enable this workflow trigger in just a few lines of TypeScript.
import { Trigger } from '@do-sdk/agent';
// Create a new trigger that runs a workflow every day at 9 AM UTC
const dailyReportTrigger = new Trigger({
name: 'daily-sales-report',
schedule: '0 9 * * *', // Cron expression for 9:00 AM daily
workflow: 'generate-sales-report',
input: {
period: 'daily',
recipients: ['team@example.com']
}
});
await dailyReportTrigger.enable();
console.log(`Trigger '${dailyReportTrigger.name}' is now active.`);
Just like that, you've automated a critical business process. The report will be generated and sent every single day, freeing you up to focus on more important work.
Scheduled tasks are fantastic, but what about reacting to events the moment they happen? That's where webhook automation shines.
Imagine you want to send a personalized welcome email the instant a user signs up for your service.
Security is paramount, which is why webhook triggers can be secured with secret keys to verify signatures, ensuring only authorized services can activate your workflows.
You've seen how a few lines of code can transform a manual, repetitive task into a "fire-and-forget" automated service. By combining powerful workflows with flexible event triggers, you can build more efficient, reliable, and responsive applications.
Ready to turn your manual processes into magical, automated services? Dive into the trigger.do platform and build your first workflow today.
What kinds of events can I use with trigger.do?
You can use a variety of events, including time-based schedules (using cron syntax), incoming webhooks from external services, and internal system events from other .do agents or services.
How do I create a trigger for a webhook?
You can define a new trigger and specify its type as 'webhook'. The platform will provide a unique URL to receive incoming HTTP POST requests, which will then execute your designated workflow.
Can I pass data from the trigger to my workflow?
Yes. For webhooks, the entire request body is passed as input to the workflow. For scheduled triggers, you can define a static JSON object to be used as the input each time the workflow runs.
How does trigger.do handle webhook security?
Security is paramount. Webhook triggers can be secured using secret keys for signature verification, ensuring that only authorized services can initiate your workflows.