Skip to content
@jennifer/slack

slack cheatsheet

Every export of @jennifer/slack. Background is in the introduction.

jennifer
import "@jennifer/slack/" as slack;
import "http.j" as http;

Every post is a JSON POST to the webhook URL and returns the http.Response unchecked: 200 with body ok on success, 4xx for a bad webhook. A URL that is not https:// (or http:// to a loopback host) throws slack; transport failures throw from http.

Types

Message

FieldMeaning
text as stringfallback text, "" to omit
blocks as list of stringrendered block JSON fragments

Posting

FunctionReturnsPosts
slack.send(webhookUrl, text)http.Response{"text": text}
slack.sendMessage(webhookUrl, m)http.Responserender(m)

Escaping

FunctionReturnsDoes
slack.escape(text)string&, <, > as &amp;, &lt;, &gt;, for untrusted text

Building

Each builder returns a new Message with one block appended.

FunctionReturnsAdds
slack.message()Messagean empty message
slack.text(m, text)Messagethe fallback text
slack.header(m, heading)Messagea plain-text header
slack.section(m, markdown)Messagea mrkdwn section
slack.fieldsSection(m, fields)Messagea section of mrkdwn fields
slack.contextBlock(m, text)Messagea small mrkdwn context line
slack.actionsBlock(m, buttons)MessageURL buttons from button
slack.divider(m)Messagea horizontal rule
slack.button(text, url)stringa button fragment for actionsBlock
slack.render(m)stringthe JSON payload, without posting