# slack

A Slack app's back end over the Web API, and what Slack sends it as checked
routes. The whole of it is [docs/slack.md](../../docs/slack.md).

```text
use "pkg:slack/slack.mote"     // the Web API (takes blocks.mote)
use "pkg:slack/blocks.mote"    // Block Kit as shapes, and fns that make them
use "pkg:slack/events.mote"    // /slack/events, /slack/commands, /slack/interactivity (takes slack.mote)

slackPost("C123", {text: "Deployed", blocks: [slackSection("*v42* is out")]}, "")?
fn slackCommand(c: SlackCommand): SlackReply      // the program's hooks, each optional
```

Settings: `SLACK_BOT_TOKEN` and `SLACK_SIGNING_SECRET` (secrets);
`SLACK_WAIT`, `SLACK_TOLERANCE`, `SLACK_API`.

| File | |
|---|---|
| `slack.mote` | The calls and the shapes of what comes back; limits and pages. |
| `blocks.mote` | Block Kit: `SlackBlock`, `SlackElement`, `SlackView`, … and their fns. |
| `events.mote` | The three routes: Slack's signature checked, the answer at once, the work in jobs, events once. |
| `tests.mote` | Its tests: `use "pkg:slack/tests.mote"`, then `mote test` (tests/svc_chat/unit.mote). |

**Covered:** messages (post, reply in a thread, ephemeral, update, delete,
a DM, a permalink), reactions, files (the upload of 2024 on:
getUploadURLExternal, the bytes, completeUploadExternal), people (one, by
address, all) and channels (one, a list, members, join, history and
threads page by page), modals (open, push, update with its hash) and the
home tab, `auth.test`; Block Kit as shapes; events (url_verification, each
event once by its id), slash commands and interactivity (buttons, selects,
shortcuts, modals submitted with their errors), each with Slack's v0
signature and the timestamp's tolerance, answered within three seconds, the
rest in a job, replies to `response_url`; Retry-After honoured and shared.

**Left out on purpose:** Socket Mode (the back end's WebSocket client, `ws.open`,
is there now; what remains is a `server start` that opens
`apps.connections.open`'s address, acknowledges each envelope and hands it
to the same hooks), OAuth installs (each call takes a token; a person's comes from
another extension), the legacy files.upload, attachments, the RTM API,
Workflow steps, Enterprise Grid's admin methods, external selects' options
URL. Incoming webhooks are [alert](../alert/README.md).

**Not yet run against Slack**: only against a stand-in
(`tests/all.sh real_svc_chat`), and the signature against the example in
Slack's documentation.
