Wait for Event
Hold an automation until a specific event arrives, with an optional timeout and filter rule.
A wait for event step holds the automation until a specific event is received. Unlike a delay, which resumes after a fixed time, this step resumes when something happens in your application.
See Using automations for the surrounding workflow.
Common use cases:
- Payment — wait for a payment to succeed before sending a receipt.
- Adoption — wait for a user to complete an action to unlock a feature.
- Verification — wait for the user to verify their email before continuing.
How it works
Add a wait_for_event step to the steps array, naming the event to wait for and an optional timeout.
import { MailBlastr } from 'mailblastr';
const mb = new MailBlastr('mb_xxxxxxxxx');
const { data, error } = await mb.automations.create({
"name": "Verification reminder",
"domain": "yourdomain.com",
"steps": [
{
"key": "start",
"type": "trigger",
"config": { "event_name": "user.created" }
},
{
"key": "verification",
"type": "wait_for_event",
"config": {
"event_name": "email.verified",
"timeout": "1 day"
}
}
],
"connections": [
{ "from": "start", "to": "verification", "type": "default" }
]
});
console.log({ data, error });Timeouts
When you set a timeout, the step stops waiting after that duration, which prevents automations from waiting indefinitely. A wait-for-event step produces two possible connection types so you can branch on whether the event arrived in time:
| Connection type | When it is used |
|---|---|
event_received | The event arrived before the timeout. |
timeout | The timeout elapsed without receiving the event. |
{
"key": "payment",
"type": "wait_for_event",
"config": {
"event_name": "payment.completed",
"timeout": "3 days"
}
}Filter rules
Use filter_rule to match only events that meet specific criteria — useful when the same event name is sent with different payloads. The rule is evaluated against the incoming event's payload. For example, to wait specifically for a successful payment:
{
"key": "payment",
"type": "wait_for_event",
"config": {
"event_name": "payment.completed",
"filter_rule": {
"type": "rule",
"field": "event.status",
"operator": "eq",
"value": "succeeded"
}
}
}The filter rule supports the same rule shapes and operators as condition steps — including and/or groups.
Configuration
config.event_namestringrequiredThe name of the event to wait for.
config.timeoutstringoptionalThe maximum time to wait before timing out (e.g. "3 days", "1 hour"). Maximum: 30 days.
config.filter_ruleobjectoptionalAn optional rule object to filter incoming events. Uses the same shape as a condition rule.