Slack slash commands - show user input?

I work with a weak slash command API , and so far it works without problems with my bot ( https://github.com/jesseditson/slashbot ), except for one:

In other integrations with a slash (for example, giphy), when a user enters a slash command, the command is displayed in a public chat, and then the answer is published:

giphy integration
(source: pxfx.io )

However, when I use my own slash command, the original command is not output at all:

no message
(source: pxfx.io )

I am currently using the Incoming Webhooks API to send messages back to the feed, which works fine, but the responses are free and have no context without the original request.

:

  1. /command
  2. , (, 2XX URL-, )
  3. , - ( , )

-, , giphy , :

  • giphy API API, ?

  • , , ?

node.js, , , .


, , Bot API Realtime Messaging API - , - , , , .

+7
4

, Slack - /command , /giphy .

- Slack API . /command /command message chat.postMessage, .

+1

API Slack/Command API:

"" "

, , , ( " " ). , , , , response_type of in_channel JSON, :

{ "response_type": "in_channel", "text": "It 80 degrees right now.", "attachments": [ { "text":"Partly cloudy today and tomorrow" } ] }

, response_type "in_channel", .

+4

. . "In Channel" "Ephemeral"

, , , ( "" ). , , , , response_type in_channel JSON, .

, ( node):

- , " " , . , Slack URL- .

, , ,

response.send({"response_type": "in_channel"});

/command. , , response_url - /command.

+4

, " " " ".

When I send my messages via cURL, it does not show the β€œin channel” slash command. I found that if I just included the header ("content-type header: application / json") and echo'd my answer with the json payload, including "in_channel", a slash command appeared. No API required!

Example:

$reply = "Whatever you want";
    $data = array(
        "response_type"=>"in_channel",
        "text"=>$repy,
        );
    header('Content-Type: application/json');
    echo json_encode($data);

Hope this helps, this is my first post, so be careful if I break any unspoken stackoverflow rules.

+3
source

Source: https://habr.com/ru/post/1599397/


All Articles