In the world of business automation, not all events are created equal. A single, critical event—like a new user signing up or a high-value order being placed—often needs to kick off several distinct business processes across different departments. The marketing team needs to send a welcome email, the analytics team needs to track an acquisition, and the sales team might need to be notified.
The traditional approach involves building a massive, monolithic workflow with complex if/else branches and nested logic. This quickly becomes brittle, difficult to debug, and a nightmare to maintain. When you need to add a new process, you risk breaking the entire thing.
There’s a better way: the fan-out pattern. This elegant approach allows a single event to trigger multiple, independent workflows, and it’s a core design principle of Triggers.do.
The fan-out pattern is a design where a single message or event is broadcast to multiple destinations or consumers simultaneously. Think of it like a central dispatcher receiving a single piece of information and routing it to several specialized departments at once.
In the context of workflow automation, this means one incoming event (from a webhook, API call, or message queue) can act as the starting point for numerous, decoupled workflows. Each workflow handles its own specific piece of logic, completely unaware of the others.
This isn't just a theoretical concept; it's a practical strategy for building robust, scalable, and maintainable automation.
Adopting a fan-out approach fundamentally changes how you build and manage automation. Here are the key benefits:
Triggers.do is architected to make the fan-out pattern intuitive and powerful. The key is to understand that you can create multiple triggers that listen for the exact same event, each with its own unique filter and action.
Let's walk through a common scenario: a new user signs up for your service. The event is auth.user.created.
The event payload might look like this:
{
"id": "usr_12345",
"email": "jane.doe@example.com",
"name": "Jane Doe",
"plan": {
"id": "plan_ent_monthly",
"type": "enterprise"
},
"createdAt": "2023-10-27T10:00:00Z"
}
Now, let's create three separate triggers to "fan-out" our logic from this single event.
This workflow is for the marketing team. It should run for every new user.
// Trigger for the general onboarding workflow
const welcomeTrigger = new Trigger({
event: 'auth.user.created',
// No filter needed, we want this to run for everyone.
action: {
workflow: 'SendWelcomeEmail',
inputs: {
userEmail: '{{data.email}}',
userName: '{{data.name}}'
}
}
});
await welcomeTrigger.activate();
Result: Every new user immediately gets a welcome email. Simple and reliable.
This workflow is for the sales team. They only care about high-value enterprise customers. Here's where Triggers.do's filtering engine shines.
// Trigger to notify the sales team about new enterprise users
const salesNotifyTrigger = new Trigger({
event: 'auth.user.created',
// The magic is in the filter!
filter: "data.plan.type === 'enterprise'",
action: {
workflow: 'NotifySalesSlackChannel',
inputs: {
message: 'New Enterprise signup: {{data.name}} ({{data.email}})'
}
}
});
await salesNotifyTrigger.activate();
Result: The sales team gets a Slack notification, but only when a user on an enterprise plan signs up. Other signups are ignored by this trigger.
This workflow is for the product and data teams. It ensures every new user is tracked for cohort analysis.
// Trigger to send new user data to the analytics platform
const analyticsSyncTrigger = new Trigger({
event: 'auth.user.created',
action: {
workflow: 'SyncUserToAnalytics',
inputs: {
userId: '{{data.id}}',
planType: '{{data.plan.type}}',
signupDate: '{{data.createdAt}}'
}
}
});
await analyticsSyncTrigger.activate();
Result: Every new user event is also sent to a workflow that syncs the data to your analytics warehouse.
With these three simple, independent triggers, you've created a sophisticated, multi-part response to a single business event. You've successfully fanned out your logic.
Stop building brittle, monolithic automation. Start thinking in terms of events and decoupled workflows. By leveraging the fan-out pattern with Triggers.do, you can build systems that are more resilient, easier to scale, and faster to adapt to the changing needs of your business.
Ready to automate at the speed of your business? Explore Triggers.do and discover the power of event-driven automation today.