Appearance
Use cases
Example workflow setups. For a feature overview, see Workflow; for step details, see Steps; and for variable syntax, see Template variables.
Notifying Slack
An example that prepares a saved query counting accounts created within the last day, and notifies Slack only when new accounts were registered. The overall setup is as follows.
- Trigger: Schedule (daily at 10:00)
- Step 1: Run Query (fetches accounts from the last day)
- Step 2: Slack (notifies only if there's at least one result)
1. Prepare a saved query
Prepare a saved query with SQL that returns accounts created within the last day, based on their creation timestamp.
sql
SELECT *
FROM `codatum-example.example.accounts`
WHERE created_at >= TIMESTAMP_SUB(CURRENT_TIMESTAMP(), INTERVAL 1 DAY)
ORDER BY created_at DESC2. Create the workflow and set the trigger
Create a workflow and set the following under Trigger > Schedule.
- Repeat every:
day - Start time:
10:00(for example, using Japan Standard Time as the time zone)
TIP
If you create it from the right sidebar > Workflows on the query detail, it opens with step 1 already set to Run Query for that query.
3. Configure Run Query for step 1
If you created the workflow from the Workflow screen, select the saved query you prepared. If you created it from the query detail, it's already selected.
4. Configure Slack for step 2
Create a Slack integration beforehand, and add the app to the destination channel.
| Item | Example setting |
|---|---|
| Channel | The notification destination (for example, notification_codatum). Channels with the app already added appear in the list |
| Message Text | See the message text example below |
| Thread (optional) | If you have multiple Slack steps, specifying an earlier step's message timestamp replies in that thread |
| Include Link to Codatum | Adds a link back to the workflow. Viewing the link requires owner permission |
| Execute if | See the execute-if example below |
Message text example
You can choose Row count, First Row, and Rows from Insert variable.
TIP
- Choosing
account_nameunder First Row inserts{{ query.rows[0].account_name }}. - Choosing Rows inserts a loop over rows. Each iteration references
row(for example,{{ row.account_name }}).
An example that includes the count and up to the first 5 rows.
liquid
Accounts created in the last day: {{ query.rowCount }}
Recently created accounts (up to 5 shown)
{% for row in query.rows limit:5 %}
Account name: {{ row.account_name }}
Created at: {{ row.created_at }}
{% endfor -%}Execute-if example
To send to Slack only when step 1's query has results, set the following expression as Execute if. If the condition isn't met, this step doesn't run. See also Execute-if condition.
liquid
{{ query.rowCount }} > 0You can enter this by choosing Row count in Insert variable. query holds step 1's Run Query output. If you have multiple Run Query steps, it becomes query_1 and so on. See Template variables for details.
5. Save and activate
Save, then Activate. Scheduled runs begin.