如何防止Slack斜杠命令回显到通道?

el *_*00b 3 node.js slack-api slack serverless-framework

使用Serverless和NodeJS,我有一个Slack命令设置如下:

/myCommand doStuff
Run Code Online (Sandbox Code Playgroud)

当我输入时/myCommand doStuff,Slack输出执行此操作:

/myCommand doStuff

我想要显示的实际响应的内容就在这里.

我想要做的只是这个:

我想要显示的实际响应的内容就在这里.

没有/myCommand doStuff得到回应.

我该如何防止这种情况发生?

更新 - 添加一些代码

这是实际的命令:

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

这是处理程序:

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

  callback(null, response);
};
Run Code Online (Sandbox Code Playgroud)

Eri*_*ken 5

当你回复时

"response_type": "in_channel"
Run Code Online (Sandbox Code Playgroud)

回复对于通道中的所有用户都是可见的,并且它总是将命令复制回通道.这不能关闭.

当你回复时

 "response_type": "ephemeral"
Run Code Online (Sandbox Code Playgroud)

它仅对用户可见,并且不会复制该命令.这也是默认值,因此您必须in_channel在脚本中使用.

请参阅此处以获取有关该主题的官方文档.

  • 嘿,我只想感谢你发表关于这个主题的所有非常有用的答案! (2认同)