In the world of automated systems, events are everywhere. A new customer signs up, a payment is processed, a support ticket is created, a server's CPU spikes. This constant stream of information is the lifeblood of a modern business, but it can also be a firehose of noise. How do you separate the critical signals—the ones that demand immediate action—from the background chatter?
The naive approach is to build a listener that reacts to everything. This leads to bloated code, wasted resources, and complex, brittle logic. True Event-Driven Automation isn't about listening to every event; it's about executing workflows with precision only when specific, important conditions are met. This is the core philosophy behind Triggers.do: LISTEN. FILTER. EXECUTE.
This post dives deep into the most critical step in that chain: Filtering. We'll explore how to move beyond simple Webhooks and use advanced filtering to build robust, efficient, and intelligent automation.
Imagine you're using Stripe and want to run a special fulfillment workflow for high-value orders. A basic webhook setup will notify your application for every single order.created event. Your code then becomes responsible for parsing the event and checking the order amount.
// The "old" way, inside your application code
function handleStripeWebhook(event) {
if (event.type === 'order.created') {
if (event.data.object.amount > 10000) { // amount is in cents
// Finally, run the important logic
startHighValueFulfillment(event.data.object);
} else if (event.data.object.amount > 5000) {
// Run some other logic
}
// ...more else-if statements...
}
// ...and lots of other event types...
}
This pattern has several major drawbacks:
Triggers.do empowers you to define these rules declaratively, right in the trigger itself. The filtering logic is evaluated at the edge, before your workflow is ever invoked. This is a fundamental shift towards true Business Process Automation as code.
Let's look at the Triggers.do approach for the same scenario:
import { Trigger } from 'triggers.do';
const newOrderTrigger = new Trigger({
name: 'New High-Value Order',
description: 'Triggers a fulfillment workflow for new orders over $100.',
event: 'order.created',
source: 'stripe-webhook',
filter: {
condition: 'event.data.amount > 100', // Logic is declared here!
priority: 'high'
},
handler: async (event) => {
// This code only runs if the filter passes
console.log(`Starting workflow for order: ${event.data.orderId}`);
return {
workflow: 'order-processing',
input: event.data
};
}
});
Notice the filter block. The condition event.data.amount > 100 is evaluated by the Triggers.do platform. Your handler code remains clean, focused, and is only executed when it's actually needed. This is how you build scalable and maintainable Workflow Triggers.
Simple comparisons are just the beginning. The real power of Event-Driven Automation is unlocked when you can create highly specific API Triggers based on complex conditions.
You want to trigger a staging deployment, but only when code is merged into the main or develop branches.
// filter from a trigger listening to a GitHub webhook
filter: {
condition: "event.ref == 'refs/heads/main' || event.ref == 'refs/heads/develop'"
}
A new support ticket is created. You need to immediately trigger an escalation workflow if the ticket is marked urgent and comes from an enterprise tier customer.
// filter from a trigger listening to a Zendesk or Intercom webhook
filter: {
condition: "event.ticket.priority == 'urgent' && event.customer.tier == 'enterprise'"
}
This compound conditional ensures your team is never alerted for a low-priority ticket, even if it comes from an enterprise client.
You want to trigger a marketing workflow to offer a first-time-purchase coupon, but only if the user checks out without using a discount code.
// filter from a trigger listening to an `order.completed` event
filter: {
condition: "!event.data.discount_code"
}
Your inventory management system needs to know the moment a specific, high-demand item is included in an order.
// filter from a trigger listening to a 'cart.finalized' event
filter: {
condition: "'SKU-XDR-9000' in event.data.line_items.map(item => item.sku)"
}
This powerful expression checks if the specific SKU exists within the array of items in the order, providing a precise hook for your inventory workflow.
Embracing advanced event filtering isn't just about writing cleaner code. It's a strategic decision that leads to more resilient, cost-effective, and agile systems.
By defining precise filtering conditions directly on your triggers, you:
Stop drowning in the event firehose. Start building with precision.
Ready to build smarter, more responsive systems? Define your first trigger on Triggers.do today and experience the power of advanced event filtering.