botkit: Duplicate message when using replyPublic.

I’ve been using botkit for a while now but only in the replyPrivate method, i’m in the process of adding in another Slash Command to the bot where the response is public but i’m running into an issue where the message is duplicated: the original message and then the response.

screen shot 2017-01-12 at 4 49 50 pm

Is there a way to prevent the user input from showing up in Slack when using replyPublic like replyPrivate does?

Here’s what i’m working with:

controller.on('slash_command', function (slashCommand, message) {
   switch (message.command) {
      case '/links':

         if (message.token !== process.env.SLACK_TOKEN) return;

         var incomingLink = message.text,
             outgoingLink = incomingLink.replace(/\s/g, '%20');

         slashCommand.replyPublic(message, outgoingLink);

      break;
      default:
         slashCommand.replyPrivate(message, "I'm afraid I don't know how to " + message.command + " yet.");
   }
});

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Comments: 21

Most upvoted comments

@robbawebba i have. This is what i’m currently running:

controller.on('slash_command', function (slashCommand, message) {
    switch (message.command) {
        case "/question": 
            if (message.token !== verificationToken) return; //just ignore it.
            slashCommand.replyAcknowledge();
            slashCommand.replyPublicDelayed(message, "@"+message.user_name+" has asked: "+message.text);
            break;
        default:
            slashCommand.replyPublic(message, "I'm afraid I don't know how to " + message.command + " yet.");
    }
   })

The message still sends but i get the timeout error on the first message. and every message i send re-appears in the input box as if it hasn’t sent.