el n00b
el n00b

Reputation: 1863

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

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);
};

Upvotes: 3

Views: 1524

Answers (1)

Erik Kalkoken
Erik Kalkoken

Reputation: 32852

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.

Upvotes: 6

Related Questions