In today's fast-paced digital landscape, the ability to react to events in real-time isn't just a feature—it's a necessity. Waiting for nightly batch jobs or manual interventions is a relic of the past. Modern businesses need to automate at the speed of their operations, and that means embracing event-driven architecture.
This is where Triggers.do shines. We provide a powerful platform to initiate any workflow, from any system, the moment an event occurs. The core of this capability lies in a simple yet profound concept: the API Trigger.
This guide will walk you through exactly what an API trigger is, why it's a cornerstone of modern Business Process Automation, and how you can create your very first one in minutes.
Think of an API trigger as a hyper-aware gatekeeper for your automated processes. It's a predefined condition that listens for specific real-time events. When an event matching its criteria occurs—like a new user signing up, a payment being processed, or a support ticket being logged—the trigger instantly fires, initiating a designated workflow.
Instead of constantly asking your systems "Has anything happened yet?", an event-driven approach lets your systems tell you "Something just happened!" This shift is more efficient, scalable, and unlocks true Event-Driven Automation.
With Triggers.do, you can connect to virtually any event source:
Before we build one, let's look at what makes up a trigger in Triggers.do. It’s a simple, declarative object that’s easy to understand and powerful in practice.
Here’s a code example for a trigger that starts a "HighValueOrderFulfillment" workflow whenever a new order over $500 is placed.
import { Trigger } from 'triggers.do';
// A trigger that starts the 'HighValueOrderFulfillment' workflow
// whenever a new order over $500 is placed.
const highValueOrderTrigger = new Trigger({
event: 'platform.order.created',
filter: 'data.totalAmount > 500',
action: {
workflow: 'HighValueOrderFulfillment',
inputs: {
orderId: '{{data.id}}',
customerEmail: '{{data.customer.email}}'
}
}
});
await highValueOrderTrigger.activate();
Let's break it down:
Now, let's create the trigger from the example above. We'll build a real-world automation that connects your business events to actionable logic.
First, identify the business process you want to automate.
Using the Triggers.do SDK, you can define your trigger declaratively in your codebase. This allows you to manage your automation logic with the same rigor as your application code—including version control, code reviews, and automated testing.
Create a new file and import the Trigger class.
import { Trigger } from 'triggers.do';
Now, create an instance of the Trigger. We'll specify the event name we're listening for and add our crucial filter to only catch orders with a total amount greater than $500.
const highValueOrderTrigger = new Trigger({
event: 'platform.order.created',
filter: 'data.totalAmount > 500',
// ... action to be defined next
});
This precise filtering is key to creating efficient and targeted Workflow Triggers.
Next, tell the trigger what to do. We'll point it to the HighValueOrderFulfillment workflow and map the necessary data from the incoming event payload. Our templating syntax {{...}} makes it easy to access nested data from the event.
const highValueOrderTrigger = new Trigger({
event: 'platform.order.created',
filter: 'data.totalAmount > 500',
action: {
workflow: 'HighValueOrderFulfillment',
inputs: {
orderId: '{{data.id}}',
customerEmail: '{{data.customer.email}}'
}
}
});
The final step is to activate the trigger. This one line of code securely deploys your trigger definition to the Triggers.do platform, where it becomes live and immediately starts listening for matching events.
await highValueOrderTrigger.activate();
That's it! You have achieved Instant Workflow Activation. Your system is now equipped to automatically handle high-value orders in real-time, with no manual intervention required.
The power of Triggers.do doesn't stop with a single trigger. A single event can initiate multiple, independent workflows. For example, you could create another trigger that listens for the same platform.order.created event but has a different filter and action:
This allows for sophisticated, branching logic right at the point of event ingestion, creating a responsive and intelligent automation ecosystem.
API triggers are the fundamental building blocks for creating a reactive, automated, and efficient business. By connecting your systems with API Triggers, you decouple them, improve scalability, and unlock the power to act on information the moment it becomes available.
Ready to connect your business events to actionable logic? Get started with Triggers.do today and create your first trigger in minutes.