_____ _______ ____ _
| __ \__ __/ __ \| |
| |__) | | | | | | | | ___ _ __ ___ _ _
| ___/ | | | | | | |/ _ \ '_ ` _ \| | | |
| | | | | |__| | | __/ | | | | | |_| |
|_| |_| \____/|_|\___|_| |_| |_|\__, |
__/ |
|___/
PTOlemy is a Slackbot who interacts with Google Calendar. It periodically lets us know about important things like who's on call and who's going to be out of the office.
It also responds to specific slash commands on Slack.
Currently, PTOlemy responds to:
/out < today | this week | next week >
Slash Commands are managed via api.slack.com.
PTOlemy can make announcements by running ptolemy.js
and passing command
or say
and
channel
arguments.
--command <command> Commands are specified as keys in `actions.js`
--say "message" Alternative to --command.
ptolemy will repeat whatever string she is given.
--channel <channel> Available channels are specified in `.ptolemy.js`.
ptolemy's announcement schedule is currently run by the sudo crontab on ml01
.
To prepare ptolemy to run locally or on a server, just install the necessary node modules:
npm i
The other side of ptolemy's functionality is her ability to respond. That's provided via an API Gateway on AWS that triggers one of ptolemy's lambdas. This deployment is handled via serverless, as configured in serverless.yml
.
It's very useful to be able to execute lambdas locally.
serverless invoke local --function responder -l --path sample_events/im.json
The above command specifies the function to invoke (--function responder
), instructs it to output any console logging (-l
) and gives it a path from which to grab data to send to the lambda, so that you can mock what the lambda would receive once deployed.
You can deploy everything:
serverless deploy
Or a single function:
serverless deploy -f responder
We're slowly getting ptolemy into a good spot with testing. Currently, it should be impossible to make a commit without passing current jest tests.
npm test
We also use prettier: we recommend setting up your editor to run prettier to reformat your code on save.
The actual deployment of PTOlemy relies on these pieces:
- A Google Cloud Project to enable use of the Google Calendar API for the Greymatter calendar (Manage Google Cloud Project, currently Carolyn Dadant and Kyle Gallagher are owners)
- Access to AWS to deploy 1) an API Gateway, and 2) lambdas
- A Slack app where you can manage the slash commands the app uses and point them toward the AWS endpoints
- A Serverless account to manage the deployment
The app should continue running fine on its own for the time being, but if/when it needs to be redeployed, it will take a little bit of setting up.
- Need to create an account on Serverless.com and create an app. It will need to have an AWS Provider set of access/secret keys added to be able to deploy. The current IAM role for the app is
decipher-serverless
, and the current access key isAKIAW2U7EPPADXA6I6WD
. You can't retrieve the secret key, so a new one will have to be created. Please contact n.eagle@gmail.com to have the PTOlemy app transferred to you, or you can recreate one using the new AWS IAM role. - Manage Slack Apps
- PTOlemy Slack App
- PTOlemy Slash Commands
- Manage PTOlemy's (Slack App) Collaborators
- Guide to AWS Credentials for Serverless