How do I prevent my Slack slash command from echoing into the channel?

谁说胖子不能爱 提交于 2019-12-02 01:11:43

问题


Using Serverless and NodeJS, I have a Slack command set up like:

/myCommand doStuff

When I type /myCommand doStuff, the Slack output does this:

/myCommand doStuff

The content of the actual response I want shown goes here.

What I want to do is only have this:

The content of the actual response I want shown goes here.

without the /myCommand doStuff getting echoed.

How do I prevent that from happening?

Update - adding some code

Here's the actual command:

module.exports = () => {
  return new Promise(function(fulfill) {
    fulfill({
      response_type: 'in_channel',
      text: 'some testing text
    });
  });
};

Here's the handler:

module.exports.handler = (event, context, callback) => {
  var response = {
    statusCode: 200,
    body: JSON.stringify(myCommand()),
  };

  callback(null, response);
};

回答1:


When you are replying with

"response_type": "in_channel"

the reply is visible to all users in a channel and it will always copy the command back into the channel. This can not be turned off.

When you are replying with

 "response_type": "ephemeral"

it is only visible to the user and the command will not be copied back. That is also the default, so you must be using in_channel in your script.

See here for the official documentation on that topic.



来源:https://stackoverflow.com/questions/46123295/how-do-i-prevent-my-slack-slash-command-from-echoing-into-the-channel

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!