Volley / Templates / Slack slash command
Webhooks templateSlack slash command sequence diagram
A /deploy command from Slack to your app and back, with the signed request, the immediate ephemeral reply and the follow-up posted to response_url when the work is done.
Click any arrow in the editor to see its request and response as a table or the raw body. Change the hosts, ids and fields to match your integration, then share a link or embed it in your README.
Step by step
- A user types the command. Slack posts it to your request URL, form encoded, with
command,text,user_id,response_urland a signature. - Your app verifies the signature: an HMAC-SHA256 of
v0:<timestamp>:<body>with the signing secret. - Your app starts the work and answers within 3 seconds with an ephemeral message only the user sees.
- When the work finishes, your worker posts the result to
response_url, here into the channel.
Easy to get wrong
- Slack shows an error to the user if you take longer than 3 seconds, so do slow work after answering.
- Reject requests whose timestamp is more than five minutes old to stop replays.
- A
response_urltakes up to five messages within 30 minutes.
The source
The whole diagram is this plain text. Copy it into your repo, or open it in the editor.
slack-slash-command.volley
title: Slack slash command with a delayed response
order: User, Slack, App, Worker
User -> Slack: /deploy api production
Slack -> App: POST /slack/commands
in: Command
```http
POST /slack/commands HTTP/1.1
Content-Type: application/x-www-form-urlencoded
X-Slack-Request-Timestamp: 1760608800
X-Slack-Signature: v0=<redacted>
team_id=T0001&channel_id=C2147483705&user_id=U2147483697&user_name=ada&command=%2Fdeploy&text=api+production&response_url=https%3A%2F%2Fhooks.slack.com%2Fcommands%2FT0001%2F1234%2Fabcd&trigger_id=13345224609.738474920.8088930838d88f008e0
```
note: Verify `X-Slack-Signature`: an HMAC-SHA256 of `v0:<timestamp>:<raw body>` with the signing secret. Reject timestamps more than five minutes old.
App ->> Worker: Start the deploy
App --> Slack: 200 OK within 3 seconds
out: Immediate reply
```json
{ "response_type": "ephemeral", "text": "Deploying api to production. I'll post here when it's done." }
```
Slack -> User: Reply only the user can see
...: {fas-rocket} Deploy runs for a few minutes
Worker -> Slack: POST response_url
in: Follow-up message
```json
{ "response_type": "in_channel", "text": "api is live in production :white_check_mark:" }
```
note: A `response_url` accepts up to five messages within 30 minutes of the command.
Slack --> Worker: 200 OK
Slack -> User: Message in the channel