How to Send Ephemeral Responses to Slack ChatOps Commands
An ephemeral Slack reply is seen only by the user who ran the command, ideal for acknowledgements and validation errors.
Return response_type: ephemeral from the slash command handler so the immediate reply is private. Use in_channel only for results the whole channel should see.
Steps
- Ack the command within 3 seconds with an ephemeral message.
- Use
response_type: ephemeralfor private replies. - Post an
in_channelmessage only for shared results.
Ephemeral reply
Terminal
# immediate response body from the slash command handler
{
"response_type": "ephemeral",
"text": "Deploy to staging queued. You will get a DM when it finishes."
}
# later, an in_channel result via response_url
curl -X POST -H 'Content-type: application/json' \
--data '{"response_type":"in_channel","text":"Deploy to staging succeeded."}' \
"$RESPONSE_URL"Gotchas
- Slack requires a response within 3 seconds; ack ephemerally and finish the work asynchronously.
- The
response_urlis valid for a limited time and a limited number of posts. - Keep authorization errors ephemeral so you do not leak who tried what to the channel.
Related guides
How to Add a Command Help Response for ChatOpsAdd a /help response for ChatOps so users can discover available slash commands, their arguments, and require…
How to Post Command Results Back to a PR or Slack in GitHub ActionsPost the result of a chat-triggered command back to the pull request or Slack in GitHub Actions, so the reque…