👀 Have you ever been lost in the TX Groups building in Zürich?
🙉 Have you ever been invited to a meeting in a room you have never heard of?
🏃♂️ Have you ever learned 2 minutes before a meeting that the room is 6 minutes away?
TX Rooms Slack Bot is here to help you find your way ™️ 🌈 ✨
- Install the Serverless framework
$ npm install -g serverless
- Save two files named
config/config.dev.json
andconfig/config.prod.json
with the following structure:
{
"SLACK_SIGNING_SECRET": "Your Apps's Signing Secret",
"SLACK_VERIFICATION_TOKEN": "Your App's Verification Token",
"SLACK_BOT_USER_OAUTH_ACCESS_TOKEN": "Your Slack App's User OAuth Access Token"
}
These files will help you keep your enviornments variables safely out of version control, but in a place that conveniently loads them to the lambda runtime when you are testing or invoking locally.
💡 You only need the config/config.prod.json
file if you ever want to try and envoke your lambda functions locally with production settings, for example, running commands with the --stage prod
flag. Otherwise you can keep your production secrets secure in AWS Lamda console using the Enviornment Variables feature for your Lambda functions.
We can use ngrok to get Slack to connect to our local instance of Lambda (which uses serverless offline
behind the scenes).
To get started:
- In a terminal window run
npm run start
to get lambda running locally - In a new terminal window run
npm run ngrok
- Copy the ngrok url into your Slack App's Event Subscription, Slash Commands and Interactivity & Shortcuts
🌈 Now your app will use your local lambda functions to respond to your Slack interactions
This app uses the Serverless framework and Lambda functions. You can inspect the serverless.yaml file to see which functions are mapped to lambda functions. Spoiler Alert: All of the lambda functions are mapped to the files in the api
directory.
If you need to make any changes to the room entries, simply do the following:
-
Edit the file
modules/rooms.js
with your room updates -
Run
npm run build
💡 Running the command
npm run build
will auto-generate some static files that are used in various parts of the app. The idea is that we can save in computation time (which costs money) if we use static files where we can get away with it.
To deploy to your staging
enviornment
$ serverless deploy --stage dev
To deploy to your production
enviornment
$ serverless deploy --stage prod
Made with ❤️ by Michael Wuergler so he can stop getting lost at work.