I'm working with the slack slash commands API, and it works swimmingly with my bot (https://github.com/jesseditson/slashbot) so far, except for one thing:
In other slash integrations (for instance giphy), when a user types a slash command, the command is output to the public chat, then the response is posted:
(source: pxfx.io)
However when I use a custom slash command, the original command is not output at all:
(source: pxfx.io)
I'm currently using the Incoming Webhooks API to post messages back to the channel, which works OK, but the responses are disembodied and lacking context without the original request.
/command
This appears to be possible via whatever giphy uses to integrate, which leaves me with some questions:
Is giphy using a private API, or have I missed the correct API to emulate this behavior?
Is there a setting I missed to allow this?
I'm using node.js, but I'm more interested in if this is possible at all, language aside.
As a side note, I realize I could use the Bot API or Real Time Messaging API to achieve something similar, but without the slash - however, I really like the documentation options and autocomplete that comes with the slash commands, so that's what I'm after with this question.
From Slack's /Command API Docs:
In Channel" vs "Ephemeral" responses
By default, the response messages sent to commands will only be visible to the user that issued the command (we call these "ephemeral" messages). However, if you would like the response to be visible to all members of the channel in which the user typed the command, you can add a
response_type
ofin_channel
to the JSON response, like this:
{
"response_type": "in_channel",
"text": "It's 80 degrees right now.",
"attachments": [
{
"text":"Partly cloudy today and tomorrow"
}
]
}
I think you need to set response_type
to "in_channel"
to allow other users to see the response.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With