1

I'm currently working with slack-starter-chatbot to create a chat bot on Slack. I'm making use of the hears handler functions.On the folder skill/sample_hears.js I have the following code.

module.exports = function(controller) {

    controller.hears(['^hello$'], 'direct_message,direct_mention', function(bot, message) {
        bot.reply(message, "Hi there, you're on workspace: " + message.team)
    });

    // listen for a message containing the world "food", and send a reply
    controller.hears('^food$','message_received',function(bot, message) {
        // do something!
        bot.reply(message, 'What do you want to eat today?')
    });

};

However when I enter the food or hello on the Slack channel the bot doesn't reply. I know that the ngrok endpoint works from the respond I got from the Slack channel. Hi there, you're on workspace: T674NXXXX Here is the output from ngrok

Session Status                online
Session Expires               6 hours, 57 minutes
Version                       2.2.8
Region                        United States (us)
Web Interface                 http://127.0.0.1:4040
Forwarding                    http://b6dXXXX.ngrok.io -> localhost:3000
Forwarding                    https://b6dXXXX.ngrok.io -> localhost:3000

Connections                   ttl     opn     rt1     rt5     p50     p90
                              0       0       0.00    0.00    0.00    0.00

What could it be?

Steven Aguilar
  • 3,107
  • 5
  • 39
  • 89

1 Answers1

0

I think this is happening due to the event type that the bot is listening for: ['direct_message', 'direct_mention']. If you mention the bot in your message, you should receive a reply.

If you'd like the bot to listen to any message in any channel without needing to directly mention the bot, you should listen to the ambient event.

ni_lo
  • 111
  • 1
  • 5