Automations can be triggered from themes, widgets, other automations, or plugins by enabling manual triggering. In situations where an artificial or custom event without API integration is required to trigger an automation, a manual trigger can be used.
Enabling Manual Triggering
Manual triggering allows an automation to be triggered programmatically from other scripted customizations or plugins. To enable manual triggering,
- On the automation's Overview, locate Triggers, and check Manual Execution.
- Take note of the inline documentation used to trigger the automation. This includes the identifier used to uniquely identify this automation in the APIs used to initiate a manual trigger.
Triggering an Automation Manually
Any scripted customization (theme, widget, automation) or plugin can trigger a manually triggerable automation using one of the APIs identified in the inline documentation for a manually triggerable automation in Automation Studio.
When triggering an automation manually, the relevant API accepts:
- The Automation's Identifier. This identifies which automation should be triggered.
- Parameters. Custom parameters that should be provided to the automation from the caller. Any string-based key/value pairs can be provided.
If there are enabled instances of the requested automation, they will be executed with the provided arguments and the response from the automation(s) will be returned to the caller for review. The response is always a string.
Using Manual Triggers in Automation Implementations
When an automation is triggered manually, details about the manual execution are made available through the context_v2_automationTrigger
API which provides the following members:
- Entity. For manual triggers, the Entity is always "Manual"
- Event. For manual triggers, the Event is always "Trigger"
- Arguments. For manual triggers, Arguments is an object with two properties:
- Parameters. The key / value parameters, if provided, by the caller.
- Response. The string response to return to the caller.
See the inline documentation for context_v2_automationTrigger
for more details about manual trigger arguments.
Manual Trigger Notes
- Manual execution enablement is provided on an automation, however, the automation is not enabled until an instance is created in Administration > Automations > Automations. Until at least one instance of the automation is enabled, the manual execution will always return an empty response.
- Automations support multiple instances, but only one response can be provided to the caller. For automations that can be triggered manually, if there are multiple enabled instances defined in Administration > Automations > Automations, the automation will be executed multiple times (once for each instance) when a manual trigger is executed.