Triggers

Connect events to actions

Simply defining a action in your config won't actually do anything. You need to trigger it somehow. The most common way is using a trigger, which connects events to actions.

Trigger Config

Triggers are defined in your config file. A top level triggers object contains an namedTriggers map/object, with subitems for each trigger.

Each trigger object contains:

  • eventName [string, required]: the event name which triggers this trigger

  • actionName [string, required]: the name of the action to perform when that event occurs

  • condition [string, optional]: a condition string to evaluate when the event occurs. The action will only be fired if it evaluates to true.

Example Config

"triggers": {
    "namedTriggers": {
        "suggestWatchAppTrigger": {
            "eventName": "app_start",
            "actionName": "showSuggestWatchAppDialog",
            "condition": "hasWatch && eventCount('shown_suggest_watch_dialog') == 0"
        },
        "congratsMessageTrigger": {
            "eventName": "completed_list_item",
            "actionName": "showCongratsModal"
        }
    }
}

Last updated