/emojibot

Learning AWS Lambda on Node.js.

Primary LanguageJavaScript

Emojibot

Learning AWS Lambda on Node.js.

Getting started

  • Create an AWS account if haven't got one already

  • Install Serverless and configure your AWS credentials

  • Create your Slack app and configure its credentials by creating a local.yml file:

     # Local variables -- DO NOT COMMIT!
     
     dev:
       slack:
         clientId: "<Your Dev Slack App Client ID>"
         clientSecret: <Your Dev Slack App Client Secret>
     
     production:
       slack:
         clientId: "<Your Production Slack App Client ID>"
         clientSecret: <Your Production Slack App Client Secret>
    

    Note that the client id must be quoted otherwise it is interpreted as a number. Do not commit this file. It is already Git ignored.

  • Deploy the server to AWS Lambda:

     serverless deploy
    

    Make a note of the endpoints output once it has deployed, e.g.:

     endpoints:
       GET - https://ab12cd34ef.execute-api.eu-west-1.amazonaws.com/dev/install
       GET - https://ab12cd34ef.execute-api.eu-west-1.amazonaws.com/dev/authorized
       POST - https://ab12cd34ef.execute-api.eu-west-1.amazonaws.com/dev/event
    
  • Go to your Slack app settings and update them to point to your server:

    • Select 'OAuth & Permissions' and in the 'Redirect URL(s)' box paste the authorized endpoint
    • Select 'Event Subscriptions' and in the 'Request URL' box paste the event endpoint

See also