SHADE is young: 0.1.0-next.2 is a pre-release, and 0.1.0 isn't out yet.

SHADE
Services

Channels

Channels are the chats your team uses: a Slack channel, a Discord channel, a Matrix room or a generic webhook. A module can tell them when something happens, such as a form that was sent. The module decides what a message says; an admin decides which chat gets which messages, on the Channels screen. A site with no channel sends nothing.

What users can do

Admins:

  • Add a channel: a Name, the kind of Chat, where it is, and the Messages it takes. Each module that is on lists the kinds of message it sends, with what each is about.
  • Send a test, to check the channel works.
  • Read each channel's delivery log: every message sent there, how many tries it took, what the chat answered and why the last try failed. Send a message that did not get through again.
  • Change a channel, or switch it off with Send messages to this channel; remove it, with its delivery log.

Who may do it

ActionPermissionRoles
Everything on the Channels screenpackages.manage (where the modules' messages go is for whoever decides which modules run; no custom role can have it)admin

In the admin

Channels is in the settings area's Connections group, for admins.

  • A table of the channels: its name and where it sends, the messages it takes, and how the last message went (delivered, waiting to be sent, sending or not delivered, and when), or Nothing sent yet, or Off. Each row has Send a test, Log, Change and Remove (asks first).
  • Add channel opens a form. What it asks depends on the Chat, see below. Messages has one box per kind of message the modules that are on send.
  • Change opens the same form. A secret you leave empty stays as it was saved. A channel keeps its kind of chat: to move to another chat, add a new channel. When another admin changed the channel after you opened it, the save is refused and nothing is lost.
  • Send a test sends a short test message, also to a channel that is switched off.
  • Log opens the channel's delivery log, newest first: when, the message, and how it went (with the tries, the answer, and why it failed). A message that did not get through has Send again.

Slack

Choose Slack. In Slack, make an app for your workspace, switch on incoming webhooks and add a webhook for the channel. Slack gives an address; paste it in Address.

Discord

Choose Discord. In Discord, open the channel's settings, then Integrations, make a webhook and copy its address into Address.

Matrix

Choose Matrix. A Matrix room needs three things:

  • Server: the address of the Matrix server the bot account is on, such as https://matrix.example.org.
  • Room id: from the room's settings (Advanced), such as !abc:example.org.
  • Access token: the bot account's access token.

Invite the bot account to the room first, or its messages are refused.

Webhook

Choose Webhook to send each message as data to another system. Give its address, which starts with https://. After adding, the signing secret is shown once, with Copy: give it to whoever builds the other system, so it can check each message with a Standard Webhooks library.

What the chats get

A Slack or Discord address and a Matrix token are secrets, because whoever has them can post in the chat. They are kept sealed and never shown again. When you change a channel, leave the field empty to keep the one saved. A webhook's signing secret is shown once, when the channel is added.

A module sends a title, and may add a text, a few fields, sections and a link, as plain text. SHADE draws it in the chat's own way and escapes every part, so words a visitor typed never become a mention, a link or markup in your chat. The forms module's message, for example, says which form was sent, when, and has a link to it in the inbox. It never holds the answers: those are visitors' personal data. See Forms.

Rules and limits

  • Only https:// addresses outside this server's own network; a redirect is not followed.
  • A message is written in the same save as the change it is about, so a change that could not be saved sends nothing. It is sent in the background.
  • A message that does not get through is tried again after 1, 2, 4, 8 and 16 minutes: six tries in about half an hour. Then it is not delivered and its error is in the error log. Send it again from the log. When you switch a channel off, the messages still waiting for it are not delivered.
  • A kind of message goes only to the channels that take it. A kind no channel takes goes nowhere.
  • The delivery log keeps each message for 30 days by default (Channel delivery log under Data retention). Messages that name a person's address are listed in their data, and deleted with it (Privacy).
  • Every change to a channel is in the audit log.
  • A module sends messages only with its channels capability, shown on the Modules page with its kinds. Only trusted modules have it.

For developers

Channels are experimental until a second, different module sends messages.

Declare the kinds. A module lists the kinds it sends in its channels capability, each with what it is about. Each is a line of the consent. A module never names a channel.

capabilities: {
  channels: { kinds: { submission: 'A form was sent: which form, when, and a link to it in the inbox (never the answers)' } }
}

A kind is lowercase letters, digits and -; a module declares 1 to 20. Admins see it as <plugin>.<kind>, here forms.submission.

Send a message. sendChannelMessage(ctx, kind, message) writes the message in the transaction of the change it is about, one for each channel that is on and takes the kind, and gives back how many channels it went to. It works only from the module's own context. This is the forms module's:

await sendChannelMessage(ctx, 'submission', {
  layout: 'detailed',
  title: m.t('channels.submission.title', { form: form.title }),
  status: 'info',
  fields: [{ label: m.t('channels.submission.form'), value: form.title }, { label: m.t('channels.submission.sent'), value: when }],
  link: { label: m.t('channels.submission.open'), url: `${adminUrl}/modules/forms/submissions?form=${form.id}` }
})

The message. Plain text in parts, never markup:

PartWhatLimit
layoutcompact: the title and the link on one line. detailed (the default): every part
titleThe headline200 characters
textA line or two under it1000 characters
statusinfo, success, warning or danger: a colour where the chat has one
fieldsShort label and value pairs10; label 60, value 200 characters
sectionsEach with an optional title, text and fields5
linkA label and a url starting with https:// or http://label 60, url 2000 characters

How each chat draws it. Slack gets blocks, with the status as the colour beside them. Discord gets one embed, and mentions reach nobody. Matrix gets a notice in plain text and HTML. Every part is escaped for the chat it goes to.

The generic webhook gets the structure itself as JSON, { type, timestamp, data }: the kind (forms.submission), when the message was written, and the message as the module sent it. It is signed with the Standard Webhooks headers (webhook-id, webhook-timestamp, webhook-signature), the same as Webhooks.

The code and its tests: shade/features/channels/README.md in the shade repository. The decision is 0013.