Skip to main content

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:
Each action type has its own set of required and optional properties.

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:
The appropriate message will be selected based on the user’s locale or system default.

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

  1. Keep actions focused - Each action should have a clear, specific purpose
  2. Use template variables - Make your actions dynamic with template variables
  3. Handle failures - Consider what should happen if an action fails
  4. Test thoroughly - Validate your actions with different inputs
  5. Use internationalization - Support multiple languages where appropriate

Examples

Send Welcome Email and Notify Sales Team

Update User Status and Log Activity

See Also