skirl

Slack-compatible webhooks

Many tools can post their notifications to a Slack "incoming webhook". Give them Skirl's address in its place, and each post arrives in a topic as a message, with no Slack involved.

Setting it up#

In the app the address is under Connect a system → Slack-compatible, or a topic's Send to this topic tab, with your address, the topic and a token filled in; New token makes the token.

For anything that posts to a Slack incoming webhook, such as Alertmanager's slack_configs: use this as the webhook URL. It answers "ok", as Slack does. It cannot send a token header, so the token is in the URL: keep the URL as secret as the token.

  • Webhook URL: https://notify.example.com/chat?template=slack&auth=QmVhcmVyIHRrX3JlcGxhY2Vfd2l0aF95b3VyX3Rva2Vu

Paste it where the tool asks for a Slack webhook URL. It is the topic's address with ?template=slack, which reads the post in Slack's format, and &auth= with the token: these tools cannot send a token any other way, so keep the whole address as secret as the token. Skirl never writes it in its log, and answers ok, as Slack does. Skirl's tests point Alertmanager 0.35.1's Slack receiver (slack_configs, the address as its api_url) at it, and check that firing and resolved alerts arrive readable.

  • The post must be JSON, as Slack's webhooks take it. The older form some tools send, a form field payload= with the JSON inside, is refused (400).
  • Each post is a new message. Nothing is replaced when a problem clears. For Alertmanager, its own sender does that: Alertmanager.
  • A tool that takes only addresses on slack.com cannot be pointed here. If it can post JSON to any address, Any webhook may suit it better.

What a message looks like#

What Skirl reads from a post:

In the post In the message
text the text, first
the first attachment's title, else its pretext, else the post's username the title
the first attachment's text, else its fallback the text, next
the first attachment's fields, the first 10 a line each, Title: value
blocks that have text (section and header blocks), the first 10 a line each
the first attachment's title_link the address the title opens
the first attachment's color the priority

The colour, in capitals or not, sets the priority: danger, red, #ff0000, #d00000 or #e01e5a is 4; good, green, #36a64f or #2eb886 is 2; any other colour, or none, is 3.

Each part is shortened to a length (the title to 250 characters, text and the attachment's text to 1500, a block to 600, a field's value to 200), and the whole message to 4096 bytes: a long post arrives shortened, never refused. Each cut ends with "…" and never splits an accented letter or an emoji. Slack's own formatting, such as *bold* and <https://…|links>, shows as it is written. A post with none of these parts arrives as the word "triggered".

A post with a red attachment and two fields:

{"username": "Zabbix", "attachments": [{"color": "danger", "title": "Problem: High CPU on web1", "title_link": "https://zabbix.example.com/tr_events.php?triggerid=1", "text": "CPU load is above 5 for 10 minutes", "fields": [{"title": "Host", "value": "web1", "short": true}, {"title": "Severity", "value": "High", "short": true}]}]}

arrives as:

Problem: High CPU on web1 CPU load is above 5 for 10 minutes Host: web1 Severity: High

Priority 4 · The title opens https://zabbix.example.com/tr_events.php?triggerid=1

Alertmanager's Slack receiver sends one post per alert group, with a one-line summary: it arrives as the title, and again as the text with a link to Alertmanager, at priority 4 while firing and 2 once resolved.

When nothing arrives#

The tool's log or its test button shows Skirl's answer:

  • 401 unauthorized: the token in the address is wrong, revoked or expired. Make a new one with New token, or Rotate, and copy the whole address again: the auth= part changes with the token.
  • 403 forbidden: the token may not send to this topic, or the address lost its &auth= part when it was pasted.
  • 400 message body must be JSON if templating is enabled: the tool posts a form, not JSON (see above).
  • 413 JSON body too large: the post itself is over 128 KB.
  • 429: too many posts too fast, or too many failed sign-ins from the tool's address: Rate limits. A tool that keeps posting with a wrong token causes the second.
  • No answer at all, or a timeout: the tool cannot reach your server from where it runs.

To tell Skirl from the tool, post a Slack-style message yourself from the machine the tool runs on, here with the token in a header rather than in the address:

curl -H "Authorization: Bearer tk_replace_with_your_token" -d '{"text":"Hello from curl"}' "https://notify.example.com/chat?template=slack"
ok

The general checks: A sender gets no message through. Every error code: Error messages.

This page on GitHub