Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Only I can see my output from custom slash commands

I created a custom slash command in Slack. The backend code, not that it's important, is a Lambda function in Python in AWS.

My problem is that when I enter the slash command, I am the only one who can see the message. Otherwise, it works perfectly. Is there a way to get others to see the output from my custom slash command?

like image 747
Xanxir Avatar asked Apr 27 '16 03:04

Xanxir


People also ask

How do you make a custom slash command?

To create a Slash command, enter the https://[yourTeam].slack.com/apps/build/custom-integration URL to your browser's address bar, just replace the [yourTeam] placeholder with the name of your Slack team, and click the Slash Commands option.

How do you use the slash command?

With Slash Commands, all you have to do is type / and you're ready to use your favorite bot. You can easily see all the commands a bot has, and validation and error handling help you get the command right the first time. Not every bot might be using Slash Commands right now.


2 Answers

See "'In Channel' vs. 'Ephemeral' responses" here: https://api.slack.com/slash-commands#responding_to_a_command.

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 of in_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"
        }
    ]
}

When the response_type is in_channel, both the response message and the initial message typed by the user will be shared in the channel.

like image 191
user94559 Avatar answered Nov 12 '22 13:11

user94559


If you have a block in your JSON payload to slack (you used slacks block-kit) e.g

`"blocks": []`

you'll have to put the "response_type": "in_channel" above blocks for it to work :) e.g

{
    "response_type": "in_channel",
    "blocks": [....]
}
like image 26
chin90 Avatar answered Nov 12 '22 11:11

chin90