Actions
Actions define what happens when a trigger rule’s conditions are met. The@repo/trigger-rules package supports various action types that can be performed in response to events.
Action Structure
An action has the following structure:Available Action Types
Email Actions
Send emails to users or administrators:Notification Actions
Send notifications to users or teams:Webhook Actions
Send HTTP requests to external services:Function Actions
Execute a JavaScript function:
Functions must be registered before they can be used:
Database Actions
Perform database operations:Event Actions
Trigger another event:Log Actions
Log information for debugging or auditing:Template Variables
Actions support template variables that are replaced with values from the event data or environment:Event Data Variables
Access event data using the{{field.path}} syntax:
Special Variables
Special variables provide access to system values:Internationalization Support
Actions can include internationalization support for messages and content:Custom Action Types
You can extend the rule engine with custom action types by registering them:Action Execution
Actions are executed in the order they are defined in the rule. If an action fails, subsequent actions will still be executed unless you configure the rule to stop on failure. To configure failure behavior:Best Practices
- Keep actions focused - Each action should have a clear, specific purpose
- Use template variables - Make your actions dynamic with template variables
- Handle failures - Consider what should happen if an action fails
- Test thoroughly - Validate your actions with different inputs
- Use internationalization - Support multiple languages where appropriate
Examples
Send Welcome Email and Notify Sales Team
Update User Status and Log Activity
See Also
- Learn about Rule Management techniques
- Explore Testing Rules effectively
- See how to integrate with Trigger.dev