skirl

Templates

A template turns the JSON a tool posts into a readable message. You need one only for a tool that posts its own JSON and has no ntfy option: Skirl has templates built in for Grafana, Alertmanager, Wazuh, Docker, GitHub, Gitea and Forgejo, GitLab, and Slack- and Discord-style webhooks, and Any webhook (the generic template) makes a readable message of any other JSON, so often there is nothing to write.

To do better for one tool, Listen for a real message under Any webhook builds a template from what the tool really sends, by clicking on its values: Listen for a real message. Or an admin writes one by hand in Admin → Templates, as below. A sender uses a template by naming it in the topic's address, after ?template= (Using a template).

In a template, {{ auto "title" }} (and "message", "priority", "tags", "link" and "sequence_id") is that part as the generic template makes it: what the sender stated in a header or the address, such as a Title header (What the tool sends besides the body), else what generic works out from the body (Any webhook). A template built by clicking uses it for every part you did not pick.

A worked example#

Uptime Kuma's Webhook notification posts this when a monitor goes down (cut down to the parts used here):

{
  "heartbeat": {"monitorID": 3, "status": 0, "msg": "connect ECONNREFUSED 10.0.0.12:443", "time": "2026-11-26 03:12:44.120"},
  "monitor": {"id": 3, "name": "Nextcloud", "url": "https://cloud.example.com"},
  "msg": "[Nextcloud] [🔴 Down] connect ECONNREFUSED 10.0.0.12:443"
}

Without a template the message would be that whole JSON. In Admin → Templates, pick Start from: An empty template and New template, paste the JSON into JSON body under Sample, and build the template one part at a time: Preview shows each step.

1. The title. Text between {{ and }} is filled in from the JSON; a dot reads a field, and dots go deeper:

{{ .monitor.name }} is down

The preview shows "Nextcloud is down".

2. The message. The reason Uptime Kuma gives:

{{ .heartbeat.msg }}

3. Down or back up. status is 0 when the monitor is down and 1 when it is up again. if picks between two texts, and 0 counts as false. Change the title, and set the priority, 5 for down and 3 for up:

{{ .monitor.name }} {{ if .heartbeat.status }}is back up{{ else }}is down{{ end }}
{{ if .heartbeat.status }}3{{ else }}5{{ end }}

4. A link. Link is opened when the notification is tapped:

{{ .monitor.url }}

5. One message per monitor. With a Sequence id, the "back up" message replaces the "down" one instead of adding a second:

kuma-{{ .monitor.id }}

The whole template, as Admin → Templates saves it:

title: '{{ .monitor.name }} {{ if .heartbeat.status }}is back up{{ else }}is down{{ end }}'
message: '{{ .heartbeat.msg }}'
priority: '{{ if .heartbeat.status }}3{{ else }}5{{ end }}'
tags: '{{ if .heartbeat.status }}white_check_mark{{ else }}rotating_light{{ end }}'
click: '{{ .monitor.url }}'
sequence_id: 'kuma-{{ .monitor.id }}'

With the JSON above it gives:

Title: Nextcloud is down
Message: connect ECONNREFUSED 10.0.0.12:443
Priority: 5
Tags: rotating_light
Link: https://cloud.example.com
Sequence id: kuma-3

Save it as kuma: type the name in Name and press Save. On the server, the command line saves the same template from a file, here kuma.yml (The skirl commands):

skirl template set kuma --file kuma.yml

Then in Uptime Kuma add a Webhook notification with the URL https://notify.example.com/alerts?template=kuma, the body sent as JSON (application/json), and the token in its additional headers: {"Authorization": "Bearer tk_replace_with_your_token"}.

What a template can set#

Part In the editor What it is
title Title The message's title. Empty: none.
message Message Its text; empty means "triggered".
priority Priority 1–5, or min, low, default, high, urgent (or max). Left empty in the editor, the sender's own priority is used; a priority that comes out empty is the default, 3; anything else refuses the message ("invalid priority parameter").
tags Tags Comma-separated; emoji names show as emoji. They are added to the tags the sender sends.
click Link Opened when the message is tapped.
sequence_id Sequence id A later message with the same id replaces this one.
actions Buttons (up to 3) Each a label and an address, both templates. A button whose label or address comes out empty is left out, and so is one whose address is not http://, https://, mailto:, tel: or geo:. The sender's own buttons come first.
events, event Events a sender can choose, Event The kinds of message the tool sends, each an id, a label and whether it is on at first, so a sender can tick which to receive; Event works out the kind of each message, and an empty one drops it.
reply Reply What the tool gets back: the message as JSON, the text ok (as Slack-style tools expect) or nothing, 204 (as Discord-style tools expect).

A part the template does not set is the sender's own (its Title header, for example). A title, message or priority the template sets replaces the sender's, even when it comes out empty, as in ntfy; a link or sequence id that comes out empty leaves the sender's. A part made with auto is the sender's when the sender stated it.

Saved templates can also use five functions an inline template cannot: header "Name" reads a header of the request (GitHub names its event in X-GitHub-Event; Authorization and cookies read as nothing), skip drops the message, event is the kind Event worked out, auto is a part as the generic template makes it, and shorten 200 .text shortens a text to 200 characters, ending it with "…" (unlike trunc, it never cuts an accented letter or an emoji in half).

A title or message a template makes may be at most 4096 bytes. One of your own that makes more is refused (400, message or title is too large after replacing template), as in ntfy. A built-in, or this server's copy of one under its name, shortens what it made to fit instead, ending it with "…".

Reading fields safely#

A field the JSON does not have prints nothing: {{ .note }} is empty. But reading into something missing stops the template: {{ .monitr.name }} (a typing mistake) or {{ .service.name }} on a message without service fails with "can't read "name" of a missing value". For a part that some messages have and others do not, use dig, which gives a fallback instead:

{{ dig "service" "name" "unknown service" . }}

or with, which skips the text when the field is missing:

{{ with .service }}Service: {{ .name }}{{ end }}

default gives a fallback for an empty field: {{ .monitor.name | default "A monitor" }}. The | passes the value on its left to the function on its right, as its last argument.

The functions people use#

Each example runs against the Uptime Kuma message above. Every function, with an example each: Template functions.

Function Example Gives
default {{ .missing | default "none" }} none
dig {{ dig "monitor" "name" "?" . }} Nextcloud
upper {{ .monitor.name | upper }} NEXTCLOUD
trunc {{ .heartbeat.msg | trunc 18 }} connect ECONNREFUS
replace {{ .msg | replace "[🔴 Down]" "is down:" }} [Nextcloud] is down: connect ECONNREFUSED 10.0.0.12:443
trimPrefix {{ .monitor.url | trimPrefix "https://" }} cloud.example.com
contains {{ if contains "ECONNREFUSED" .heartbeat.msg }}refused{{ end }} refused
eq {{ if eq .monitor.name "Nextcloud" }}files{{ end }} files
len {{ len .monitor }} 3
printf {{ printf "%s (%v)" .monitor.name .monitor.id }} Nextcloud (3)
toDate, date {{ .heartbeat.time | toDate "2006-01-02 15:04:05" | date "15:04" }} 03:12

Dates are read and written with Go's layout, which uses the example date 2006-01-02 15:04:05: write the date that way in the format you want.

Three common mistakes#

The preview shows the error, naming the part and the line.

  1. A misspelt function: function "uppr" not defined. Check the name in Template functions; names are case sensitive (toDate, not todate).
  2. Reading into something missing: can't read "name" of a missing value; use dig for optional fields. A field name is misspelt (.monitr), or this message does not have that part: use dig or with (above).
  3. Comparing a number: incompatible types for comparison: float64 and int. Numbers in JSON are decimals, so compare with a decimal, {{ if eq .heartbeat.status 0.0 }}, or test the number directly, {{ if .heartbeat.status }}.

An {{ without its }} says unclosed action, and an if, with or range without its {{ end }} says unexpected EOF. A Priority that comes out as something other than a priority (critical, say) says invalid priority parameter: turn the tool's words into 1–5 with if.

Testing before saving#

Beside the parts, Sample holds the message to try the template on:

  • Start from an example fills in a real message from Alertmanager, Grafana, GitHub, Gitea, GitLab, a Slack-style or a Discord-style tool. Better still, paste one your tool really sent (its own log, a test from the tool, or Listen for a real message).
  • JSON body is the message; Headers, one a line as Name: value, are the request's headers (GitHub's X-GitHub-Event: push, for example).
  • ?events= in the sender’s URL tries the events a sender ticked; empty means the template's own choice.

Preview shows the message as the inbox would, a moment after each change: its priority, emoji, title, text, tags and buttons, and the event and sequence id. A message the template drops shows as "Skipped", with its event. The preview runs up to 30 times a minute; past that it pauses for a moment.

Save only when the preview shows what you want: a saved template is in force at once.

The Templates page#

Admin → Templates, for admins, lists This server’s templates and the ones Built in. Each opens on a page of its own.

Built-in templates#

Skirl's own: alertmanager, discord, docker, generic (also auto), gitea (also forgejo), github, gitlab, grafana, slack and wazuh. Each sender's page says what its template makes: Connecting your systems.

A built-in opens read only. Customise makes this server's own copy under the same name, which replaces the built-in for every sender that names it ("replaces the built-in" in the list; the built-in shows "replaced by this server’s"). The other names, auto and forgejo, always mean generic and gitea, so they reach the copy too. The copy keeps what goes with the name: a copy of generic takes a body that is not JSON, as the built-in does, and a copy of any built-in shortens a message that comes out too long. Deleting the copy brings the built-in back.

Starting a new one#

Start from picks An empty template or a built-in to copy (The github template), and New template opens it. Name: a-z, 0-9, _ and -, starting with a letter or digit, up to 64. new is taken by the page itself, and yes, no, true, false, 1 and 0 are refused, since an address with ?template=yes means a template written in the address itself. auto and forgejo are refused too, as new is: under Name the page says "“auto” is another name for the built-in generic; pick another name, or generic to replace it." and Save stays off. Save under generic or gitea to replace those.

A name already in use asks first, as Save as template does in Listen for a real message, and says what saving would replace:

  • a template saved on this server: "A template saved here is already called mytool. Saving replaces it for every sender that uses it, and what it says now is lost."
  • a built-in template (github, grafana): "github is a built-in template. Saving replaces it for every sender whose address says ?template=github. Deleting yours later in Admin → Templates brings the built-in back."
  • this server's copy of a built-in: "This server already has its own github, in place of the built-in. Saving replaces that one, and what it says now is lost."

Replace mytool saves over it; Keep it, pick another name saves nothing and leaves the page as it is. A template's own page saves without asking: it is saved under its own name, which cannot be changed there. Customise on a built-in saves the copy under the built-in's name without asking again, as the page already says it replaces the built-in; given another name in use, it asks.

Renamed when Skirl was upgraded#

Before 1.0.0-test.8, a template could be saved under the names auto and forgejo. Since then those names always mean generic and gitea, so such a template could no longer be used. On upgrading to 1.0.0-test.9, Skirl renames it to auto-saved or forgejo-saved (auto-saved-2, -3 and so on when that name is taken), with everything in it kept, and says so once, in the log of the start that renamed it (the output of a skirl command, when one opened the database first):

time=2026-11-28T09:00:00.000Z level=WARN msg="a saved template was renamed: auto and forgejo always mean the built-ins generic and gitea now" from=auto to=auto-saved

Admin → Templates then says, above the list, "A template saved here was renamed when Skirl was upgraded:" with each old and new name, until an admin presses Dismiss for every admin. A sender meant to use the template needs its new name in its address: ?template=auto-saved.

A template's page#

The parts are on the left (above, on a narrow screen), as in What a template can set. Beside them, How templates work is the short version of this page, with Find a function: type a name or what it does ("date", "replace"), and Insert puts the function where the cursor was. Fold away hides the panel, and this browser remembers. Below it are Sample and Preview (Testing before saving).

Saving and deleting#

Save checks every part and stores the template; "Saved. In force now." means senders get it from their next message. A part that does not read as a template is refused, with the part and the line. Delete asks once more: Delete for good, or, for a copy of a built-in, Delete, bring the built-in back.

Using a template#

A sender names the template in the topic's address, https://notify.example.com/alerts?template=kuma, or in a Template (or X-Template) header. The body must then be JSON, except for generic (the built-in, or this server's copy of it), which takes any body. &events= (or an Events header) picks which of the template's events to receive, by their ids: &events=push,ci_failed.

What the sender is told when it goes wrong:

Answer Why
400 invalid request: template file not found No template of that name.
400 invalid request: message body must be JSON if templating is enabled The body is not JSON (for a template other than generic).
400 invalid request: message or title is too large after replacing template A template of your own made a title or message over 4096 bytes (What a template can set).
400 invalid request: events; unknown event "…"; valid: … &events= names an event the template does not have.
400 invalid request: template execution failed; … The template stopped on this message, as the preview would show.
413 JSON body too large The body is over 128 KB.
200 {"dropped":true,"event":"…"} Taken and dropped: the event is not ticked, or the template has no event for it, or it called skip. (A template whose Reply is ok or nothing answers that instead.)

This page on GitHub