______ ______ __ _____ ______ ______ ______ ______ ______
/\ == \ /\ == \ /\ \ /\ __-. /\ ___\ /\ ___\ /\ == \ /\ __ \ /\__ _\
\ \ __< \ \ __< \ \ \ \ \ \/\ \ \ \ \__ \ \ \ __\ \ \ __< \ \ \/\ \ \/_/\ \/
\ \_____\ \ \_\ \_\ \ \_\ \ \____- \ \_____\ \ \_____\ \ \_____\ \ \_____\ \ \_\
\/_____/ \/_/ /_/ \/_/ \/____/ \/_____/ \/_____/ \/_____/ \/_____/ \/_/
This project has been abandoned. Firstly, I rewrote it in Kotlin (with tests) as a job for Shiny shiny, shiny boots of leather. Secondly, I left the club and apparently nobody had an interest in working on it.
Automated email alerts using text files in Dropbox as a datastore and the Gmail API, (currently) built in Node.js.
BRIDGE-BOT is an automated messaging system. It consumes a list of club members' names and email addresses (in JSON format) from a file in Dropbox. Every week it prepares an email - either to one member or all members - and then emails it using its own Gmail account and the Gmail API (Google auth secrets are also read from JSON files in Dropbox). Hosted in Heroku, it uses a 'custom' Node buildpack (no web process) and the Heroku scheduler set to run a single process every hour. It then checks whether it needs to do anything, depending on the time of day and whether it has done anything that day, then either writes and sends a message, or shuts down. The bot is built and destroyed once every hour, so it reads and writes to another file in Dropbox to store the state of the application.
Current version is little more than a spike, but it works and is plenty good enough for our purposes.
If you can write code, feel free to contribute some. If you want to make suggestions about functionality, those are also very welcome.
- Better testing.
- Design improvements / refactoring.
- More modularity - less hardcoded stuff and more config.
- Java (?) version. Just cuz I wanna.
- Twilio integration - members can report jobs that need doing via SMS and those on shift are notified.
- NodeJS
- Heroku account & Heroku CLI toolbelt installed
- Dropbox account
- A Dropbox application access token (stored in environment variables)
- Gmail account
- Google Gmail API client_secret.json (stored in your named Dropbox app folder)
- Google gmail-node.js-quickstart.json (stored in your named Dropbox app folder)
- members.json and bridge-bot.txt (see below) (stored in your named Dropbox app folder)
- git
git clone
this repo.
npm install
create a Heroku app:
heroku create <your-app-name> --buildpack https://github.com/endofhome/heroku-buildpack-nodejs
git push heroku master
set the BRIDGE_BOT_DROPBOX_ACCESS_TOKEN environment variable in your Heroku app.
an EMAIL environment variable is used to add some hard-coded email addresses to the BCC field in the Gmailer buildMessage() function.
set the Heroku scheduler to run npm start
every hour - or as often as suits you.
optionally: set the timezone of your app in the CLI using the TZ format (ie. heroku config:add TZ="Europe/London"
)
members.json:
{
"members": [{
"id": 1,
"name": "Carla",
"surname": "Azar",
"email": "[email protected]"
}, {
"id": 2,
"name": "Drumbo",
"surname": "",
"email": "[email protected]"
}, {
"id": 3,
"name": "Chris",
"surname": "Corsano",
"email": "[email protected]"
}]
}
bridge-bot.txt (the "memory"):
{
"currentMember": {
"id": 2,
"name": "Drumbo",
"surname": "",
"email": "[email protected]"
},
"cleaningScheduled": true,
"dayTracker": 5
}
*****************
* E N J O Y ! *
*****************