Skip to content

Instantly share code, notes, and snippets.

@devStepsize
Last active April 22, 2016 21:19
Show Gist options
  • Save devStepsize/003f491c650f5c0e5012b9eabc1a6805 to your computer and use it in GitHub Desktop.
Save devStepsize/003f491c650f5c0e5012b9eabc1a6805 to your computer and use it in GitHub Desktop.
Botkit hear middleware to change the way bots hear triggers
// From https://github.com/howdyai/botkit#hear-middleware
// this example does a simple string match instead of using regular expressions
function custom_hear_middleware(patterns, message) {
for (var p = 0; p < patterns.length; p++) {
if (patterns[p] == message.text) {
return true;
}
}
return false;
}
controller.hears(['hello'],'direct_message',custom_hear_middleware,function(bot, message) {
bot.reply(message, 'I heard the EXACT string match for "hello"');
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment