slackslack-apislack-commands

Cannot replace or delete the response to Slack slash command


I'm building a Slack bot that handles slash commands.

I'm following the Slack documentation https://api.slack.com/interactivity/handling#message_responses

and manage to get proper payload sent with the command activation, i.e

token=TTT
apiAppId=AAA
teamId=MMM
teamDomain=acme
enterpriseId=null
enterpriseName=null
channelId=CCC
channelName=chan
userId=UUU
userName=Mugen
command=/cmd
text=my-text
responseUrl=https://hooks.slack.com/commands/XXX/YYY/ZZZ
triggerId=a.b.c
isEnterpriseInstall=false

To which I immediately respond with some text.

Then when I POST a delayed response using responseUrl, I get my response posted fine, however, the original message is not modified or deleted. Even if I post it again and again to same url.

curl --location --request POST 'https://hooks.slack.com/commands/XXX/YYY/ZZZ' \
--header 'Content-type: application/json; charset=utf-8' \
--data-raw '{
    "response_type": "ephemeral",
    "replace_original": true,
    "delete_original": true,
    "text": "txt"
}'

I tried with all sorts of combinations on the two booleans, nothing worked. Did I miss something?

I'm using the Java sdk to handle the command, posted here with simplified terms to show its unrelated to the Java code.


Solution

  • Seems that delete/replace of message is simply not supported for command responses. Only for action responses.

    This isn't evident in the documentation, but is strongly suggested by the sdk objects.