In the world of workflow automation, "one size fits all" is a recipe for inefficiency. A static workflow that does the same thing every single time is useful, but its power is limited. What if your automation could adapt to the specific context of why it was triggered? What if you could run the same core business logic, but have it behave differently for a new premium customer versus a free user?
This is the power of dynamic workflows, and the key to unlocking them is the payload.
At trigger.do, we believe in "Business-as-Code"—defining your logic once and triggering it from anywhere. Payloads are what make this principle truly powerful, transforming your generic processes into intelligent, context-aware agentic workflows. Let's explore how you can use payloads to customize your automation.
Think of a trigger as the command to start a task. For example, "Onboard the new user." A static workflow would always execute this command in the exact same way.
A payload is the crucial data you send along with the trigger. It's a simple JSON object that provides the specific context your workflow needs to execute intelligently.
Instead of just "Onboard the new user," you can now say:
"Onboard the new user with this ID, this email address, and who signed up for the premium plan."
This context, passed in the payload, allows your single "new user onboarding" workflow to perform a variety of actions:
You don't need three different workflows; you need one smart, dynamic workflow that reads its instructions from the payload.
Using payloads is incredibly straightforward with the trigger.do SDK. You simply pass a payload object when you call the trigger method.
Let's look at a practical code example for triggering a new user onboarding workflow.
import { Do } from '@do-sdk/client';
const client = new Do({ apiKey: process.env.DO_API_KEY });
// Trigger a new user onboarding workflow. Run your business as code.
async function onboardNewUser(user: { id: string; email: string; }) {
try {
const { workflowRunId } = await client.trigger('new-user-onboarding', {
payload: {
userId: user.id,
email: user.email,
plan: 'premium',
},
});
console.log(`Workflow ${workflowRunId} triggered successfully.`);
return { success: true, workflowRunId };
} catch (error) {
console.error('Failed to trigger workflow:', error);
return { success: false, error };
}
}
// Example: Trigger the workflow for a new user signup
onboardNewUser({ id: 'usr_abc123', email: 'jane.doe@example.com' });
With this simple API trigger, the same workflow can now handle onboarding for free, standard, and premium users, all by changing the value of the plan field in the payload.
The possibilities are endless once you start thinking in terms of dynamic, event-driven triggers. Here are a few ideas to get you started:
A common question is: "How do I secure my trigger endpoints?" With trigger.do, security is built-in. All API endpoints are secured using API keys, which you can manage, rotate, and monitor directly from your dashboard. This ensures that only your authorized services can initiate workflows, giving you complete control over your business automation.
By passing data within a secure payload, you create a robust system that is both flexible and safe.
Static automation can only get you so far. The true potential of business automation is realized when your workflows can adapt to real-time context. By passing dynamic payloads with your event-driven triggers, you can build powerful, efficient, and highly reusable systems.
Ready to move beyond static automation? Sign up for trigger.do and start building dynamic, payload-driven workflows in minutes.