Advanced Features
Multi-Trigger Steps
Build Steps that respond to multiple trigger types — HTTP, queue, cron, state, and stream — in a single file
A single Step can respond to multiple trigger types. This is useful when the same business logic should be accessible from different entry points — for example, an order processor that can be triggered manually via HTTP, automatically from a queue, and on a schedule via cron.
Basic Example
When to Use Multi-Trigger Steps
- Manual + Automatic — An HTTP trigger for manual execution and a queue trigger for automated processing
- Scheduled + On-Demand — A cron trigger for periodic runs and an HTTP trigger for ad-hoc execution
- Multiple Queue Sources — Listen to several topics when the processing logic is identical
Handling Different Trigger Types
Using ctx.match()
The match() method routes execution based on which trigger activated the handler:
Using ctx.is
For simpler branching, use the is type guards:
Using ctx.getData()
When you do not care about the trigger type and just need the data payload:
Best Practices
- Keep multi-trigger Steps focused on a single responsibility — the trigger variety is about how the Step is activated, not what it does
- Use
ctx.match()when different triggers need different response handling (e.g., HTTP needs a response object, queue does not) - Use
ctx.getData()when the processing logic is identical regardless of trigger type - HTTP triggers must return a response object; queue and cron triggers do not