Triggers let you create actions in your app. Here are some common uses of a trigger:

  • Send a Slack alert to the management team if the severity level is critical.
  • Invite different people to an activity based on a select dropdown.
  • Use a different attribute than conclusion to close an activity.
  • Send emails from your app.
  • Send SMS (mobile text) to any mobile phone.

Sending email and SMS is often used for escalation, and to communicate with people outside your Slack workspace.

Notice about triggers
Triggers are not yet supported in the app builder and require that you use the code editor.

A trigger is associated with an attribute. The trigger can fire when the attribute state changes, for example, when a user selects an option from a select dropdown menu.

Here is an example that invites different people to resolve an incident, based on the location:

{
  "name": "location",
  "type": "select",
  "label": "Office location",
  "options": [
    {
      "name": "uk",
      "label": ":flag-gb: London",
      "trigger": {
        "owner": "@tina",
        "members": "@uk-sre-team",
        "alert": "#incidents-uk"
      }     
    },
    {
      "name": "us",
      "label": ":flag-us: Washington DC",
      "trigger": {
        "owner": "@dave",
        "members": "@us-sre-team",
        "alert": "#incidents-us"
      }     
    }
  ]
}

These members and alert settings will be appended to the app’s member and alert settings (not replace them).

Notice how the triggers are associated with the select options. You can also associate the trigger with an attribute. Whenever someone updates the input attribute, a message will be sent to a Slack channel and a user.

{
  "name": "input",
  "type": "text",
  "label": "Updating this field will send a message",
  "trigger": {
    "message": {
      "to": "#log, @fred",
      "body": "Update from my app:\n${input}"
    }
  }     
}

Here we use macro substitution to insert the attribute’s text value into the message.

Trigger actions

A trigger can either be associated with an attribute or an option in a select menu. It is activated when the attribute changes, or when the select menu is chosen.

These are the possible actions a trigger can perform:

  • owner: Change the owner of the activity.
  • members: Add people to the member list.
  • alert: Add people to the alert list.
  • conclude: Conclude (and close) the activity.
  • set_attribute: Set an attribute value.
  • message: Send a Slack message to anyone on the team, see Slack messages.
  • email: Email an external user, see email.
  • sms: Send SMS (mobile text) to mobile phones, see sms.

In fact, the trigger can perform all of these actions at the same time. Keep in mind that alerts are only sent when an activity is created.

The examples above illustrate the three first actions, so let’s take a look at setting an attribute value and concluding the activity.

Here is a trigger that both sets an attribute value and closes the activity:

{
  "protected": "${superusers}",
  "name": "decision",
  "type": "select",
  "label": "Decision",
  "visible": "edit,conclude",
  "options": [
    {
      "name": "yes",
      "label": ":thumbsup: Yes"
    },
    {
      "name": "no",
      "label": ":thumbsdown: No"
    }
  ],
  "trigger": {
    "conclude": true,
    "set_attribute": {
      "name": "conclusion",
      "value": "The decision was ${decision.label}"
    }
  }
}

The set_attribute action sets an attribute to a specified value. In the example above, the conclusion will be set to “The decision was 👍 Yes” or “The decision was 👎 No”, based on the decision.

This is a convenient pattern when you want to use a different attribute to conclude an activity. In this case we use the select dropdown (decision) conclude the activity.

Here we also set protected to restrict who can make a decision. Define superusers to authorize certain team members to make decisions.

Cascading set-attribute triggers will not work:
What if you have a chain of set-attribute triggers in a loop, so that a => b => c => a. Would an infinite loop of triggers cause the melt-down of a Google datacenter? Cascading triggers may lead to bad outcomes, which is why Conclude detects and stops them.

Button-based triggers

Button triggers are convenient for implementing single-click actions. Here’s a useful pattern that sets the conclusion and closes the activity when the user clicks the Yes or No button.

{
  "attributes": [
    {
      "name": "approve",
      "type": "button",
      "label": "Yes",
      "style": "primary",
      "visible": "edit,conclude",
      "trigger": {
        "conclude": true,
        "set_attribute": {
          "name": "conclusion",
          "value": "Approved"
        }
      }
    },
    {
      "name": "decline",
      "type": "button",
      "label": "No",
      "style": "danger",
      "visible": "edit,conclude",
      "trigger": {
        "conclude": true,
        "set_attribute": {
          "name": "conclusion",
          "value": "Denied"
        }
      }
    }
  ]
}

Conditional triggers

You can specify a couple of conditions:

  • if_match: Activate a trigger if a regular expression matches the attribute value.
  • if_not_match: Activate a trigger if the expression does not match the value.

Conclude uses golang-style regular expressions.

If both conditions are specified, the trigger will fire if both conditions are satisfied (not just one of them).

{
  "name": "incident",
  "type": "text",
  "label": "Describe the incident",
  "trigger": {
    "if_match": "(?i)critical",
    "alert": {
      "to": "@incident-management",
      "body": "Urgent update about incident in ${channel}"
    }
  }
}

This code will send a Slack message to a user group if somebody creates an activity where the incident description contains the “critical”. The special code (?i) creates a case-insensitive regular expression, and will match “critical” and “CRITical”.

Supercharge your team!

Bridge the collaboration gap with Conclude apps.

Quickstart