Skip to content
English
  • There are no suggestions because the search field is empty.

Template cookbook

Copy-paste snippets for the most common things workflow authors do inside a $tpl template — date formatting, defaults, conditionals, Slack mrkdwn.

For anyone past the basics in References and templates who wants a recipe instead of a tutorial.

Before you copy

  • Snippets use .trigger.foo as shorthand. The actual chip path uses your trigger node's id. Fastest way to get the right path: open the trigger's INPUT pane in the Logs panel after a test run, then click the field you want.
  • These snippets go in fields that have Template ($tpl) mode selected. Switch the field's mode button before pasting. See References and templates for mode-button details.

Dates and times

Today, in your local time:
{{ dateInZone "Monday, January 2" now "Europe/Oslo" }}
ISO timestamp:
{{ dateInZone "2006-01-02T15:04:05Z07:00" now "Europe/Oslo" }}
Just the day-of-week:
{{ dateInZone "Monday" now "Europe/Oslo" }}
Time only:
{{ dateInZone "15:04" now "Europe/Oslo" }}

Tip: Go's date format uses the reference time Mon Jan 2 15:04:05 MST 2006. Other strings will produce odd output. Full layout reference at https://pkg.go.dev/time#pkg-constants.

Defaults and missing fields

Templates that reference a missing path render the literal <no value>. Wrap with default:

Hi {{ default "there" .trigger.event.organizer.firstName }}!
Subject: {{ default "(no subject)" .trigger.event.subject }}

Conditionals

Show a line only on certain weekdays:

{{ if eq (dateInZone "Monday" now "Europe/Oslo") "Monday" }}
Stand-up at 09:30.
{{ end }}

Different message based on a flag:

{{ if .trigger.event.isAutoBooked }}
This was an auto-booked meeting.
{{ else }}
This was scheduled by a human.
{{ end }}

Combine conditions:

{{ if and .trigger.event.isAutoBooked .trigger.event.isRecurring }}
Recurring auto-booked meeting.
{{ end }}

String manipulation

{{ upper .trigger.event.space.name }}            -> SKY ROOM
{{ title .trigger.event.organizer.name }}        -> Alice Smith
{{ trim "  hello  " }}                            -> hello
{{ replace "_" " " "meeting_room" }}              -> meeting room

Numbers

{{ mul .trigger.event.count 2 }}
{{ printf "%.1f%%" .trigger.event.fillRate }}
{{ add 1 .trigger.event.attendees }}

For non-string fields, set the type dropdown next to the template editor — integer, number, or boolean.

Slack mrkdwn

When the Slack action's Content type is markdown, Slack uses its own flavour — mrkdwn — not standard markdown:

What you want

Mrkdwn

Bold

*bold* (single asterisk, not double)

Italic

_italic_

Strikethrough

~strike~

Inline code

`code`

Block quote

> a quoted line

Manual link

<https://example.com|click here>

User mention

<@U12345> (Slack user id, not email)

Channel mention

<#C12345|general>

Plain URLs auto-link. Tables and inline images aren't supported.

JSON output (for non-string fields)

Most templates produce strings. To produce a JSON object or array, set the type dropdown to json and write a template that emits valid JSON:

{ "subject": {{ quote .trigger.event.subject }}, "auto": {{ .trigger.event.isAutoBooked }} }

Use quote to safely string-escape values — it adds the surrounding " and escapes inner quotes.

Go deeper

For features beyond these recipes:

Related