Skip to content

GorillaStack/serverless-slack-memebot

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

22 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

serverless-slack-memebot

We implemented a memebot for slack, built on the serverless framework to use as a demonstration for the Disruptors in Tech meetup. See slides. It was implemented by GorillaStack to serve as a boilerplate for similar serverless projects.

The key purpose of the talk was to demonstrate how to work with frameworks and minimise risks around framework changes and provider lock-in.

Usage

Development environment

It is possible to run this slackbot in your slack rooms without deploying to AWS!

Local environment variables

The serverless framework will be loading environment variables from the file bot/.env. For security reasons, we ignore this file from the repository. There is an example file you can copy.

cp bot/.env.example bot/.env

Then, it is important to get SLACK_CLIENT_ID, SLACK_CLIENT_SECRET and the SLACK_VERIFICATION_TOKEN from Settings > Basic Information within the configuration of the Slack App.

Terminal1:

#!/bin/bash

## First install npm dependencies for the project
npm install

## Now install npm dependencies that will be packaged up with our slackbot and deployed
pushd bot && npm install && popd

## Now run babel in watch mode to listen for changes to our code
npm run compile:dev

Terminal2:

#!/bin/bash

## Move into the bot/ directory
cd bot

## Run the offline plugin for the serverless framework to emulate API gateway and invoke our lambda functions
## We should now be listening on localhost:3000
sls offline

Terminal3:

#!/bin/bash

## Use ngrok to expose our localhost:3000 to a public https endpoint
ngrok http 3000

While contributing, or working on your fork, run npm test to run tests, npm run cover to run tests and check code coverage and npm run lint to check our code styling. To see an HTML report of our code coverage, go to /path/to/project/coverage/lcov-report/index.html in your web browser.

Slack configuration

To integrate your development, production or any other environment with slack, you will need to set up a slack app.

  1. Go to https://api.slack.com/apps
  2. Click the "Create New App" button
  3. Enter your app's name and a development slack team and click "Create App" create app
  4. Under "Add features and functionality", click "Slash Commands" add features and functionality
  5. Click "Create New Command"
  6. Enter the command details and press save slash command details
  7. Select OAuth & Permissions from the sidebar
  8. Click "Install App to Team" to finish :)

Deploy to production

Releases

No releases published

Packages

No packages published