Hello,
I couldn't find the actual function or logic that is how can my bot replies a random greetings whenever someone mentions or message the bot. As you see below, my current line is .. bot.reply(message, 'Hi there!')
controller.hears(['hi', 'hello', 'good morning'], ['direct_message','direct_mention','mention'], function (bot, message) {
bot.reply(message, 'Hi there!')
})
What if I have 4-5 different/random greetings? What function should I use..any example would be good. Thanks
I'm not sure botkit should have a function here. Maybe use something like this:
var message_options = [
"Hello there!",
"How are you?",
"What's up?"
]
var random_index = Math.floor(Math.random() * message_options.length)
var chosen_message = message_options[random_index]
bot.reply(message, chosen_message)
Thanks @agamrafaeli It worked.
I used the following snippet
controller.hears(['hello','hey','hi','aloha'], ['direct_message','direct_mention','mention'], function(bot, message) {
var message_options = [
"Hello there!",
"Hello.",
"Yes, I'm listening...",
"Hi! How can I help?",
"Hey, what's up!",
"Yes, tell me! What are you looking for?",
"What's up?"
]
var random_index = Math.floor(Math.random() * message_options.length)
var chosen_message = message_options[random_index]
bot.reply(message, chosen_message)
});
@peterswimm I think we can close this issue now.
@agamrafaeli Will do!
Most helpful comment
I'm not sure
botkitshould have a function here. Maybe use something like this: