4

How to deploy an slack bot which is built using Botkit in Aws Lambda. If it is a slash command we can respond to event by using below code.

exports.handler = function(event, context) {
    //Echo back the text the user typed in
    context.succeed('You sent: ' + event.text);
};

But not sure how to do the same for Bots. example code for Bots using Botkit(Howdy) is

Controller.hears(['help'], 'direct_message,direct_mention,mention', (bot, message) => {
    bot.reply(message, {
        text: `You can ask me things like:
    "Search Contact"
    "Search Account"`
    });
});
krish
  • 63
  • 6

1 Answers1

5

Slack support two API integration styles RTM through WebSockets (original style with lowest latency) and Events API pushed over HTTP whenever something you're interested in happens (newer and more efficient but a bit more latency which is usually not a problem). You can read more in the Slack events documentation.

As of today BotKit only supports the RTM API in Slack which is based on WebSockets. WebSockets wouldn't work out in Lambda because they are constantly connected which goes against the rapid spin up/down event based handling nature of a Lambda function.

The BotKit team at Howdy is aware of this and is interested in adding support for the Slack Events API.

ss2k
  • 1,258
  • 1
  • 13
  • 20
  • 2
    Botkit announced Events API support this week. https://medium.com/slack-developer-blog/botkit-is-better-with-slacks-events-api-f9a27e051591 I can't tell if it still requires persistent processes or not, though. – Tim Swast Jan 05 '17 at 19:21