Grandma Bot is written in JavaScript/NodeJS and can send a randomly chosen message specified in a TXT file and send it as an SMS via the Twilio API.
-
Active Twilio Account
-
NodeJS/npm installed on the machine you want to use
You can run the Grandma Bot in many configurations:
-
Natively
-
Inside a Docker container
-
On a Kubernetes Cluster
-
As a Cloud Function (like Azure Functions)
Variable | Description | Default |
---|---|---|
TWILIO_ACCOUNT_SID | The SID of your Twilio account, check the Twilio Dashboard. | - |
TWILIO_AUTH_TOKEN | The Auth Token of your Twilio account, check the Twilio Dashboard. | - |
TWILIO_PHONE_NUMBER | The phone number your messages will be send from, check the Twilio Dashboard. | - |
RECEIVER_PHONE_NUMBER | The phone number which will receive your messages. | - |
MIN_MSG_AMMOUNT | Minimum ammount of messages in messages.txt , more are better for the random selection. |
- |
PERFORM_MESSAGE_TEST | Test if messages in messages.txt are appropriate to be sent as SMS by settting this var to true. |
false |
Follow the steps below to setup the project to run natively on your computer.
-
Get the project's code by running
git clone https://github.com/pitscher/grandma-bot.git
-
Inside the project's directory run
npm install
-
Create a new file
.env
with the following content and fill in your data: See chapter "Needed variables" for further reference.TWILIO_ACCOUNT_SID=<yourValueHere> TWILIO_AUTH_TOKEN=<...> TWILIO_PHONE_NUMBER=<...> RECEIVER_PHONE_NUMBER=<...> MIN_MSG_AMMOUNT=<...> PERFORM_MESSAGE_TEST=<...>
-
Fill the
messages.txt
with your messages you want to send via SMS. One message per line. Empty lines are not permitted. Keep in mind that each message should be <159 characters to avoid splitting and multiple billing. -
If you filled the
messages.txt
you can check if your input is valid by settingPERFORM_MESSAGE_TEST=true
and starting the tool. -
Start the tool with
npm start
-
The bot is running and will tell you what is happening via the command line. Messages normally take a few seconds to be processed by Twilio. You're done.
Follow the steps below to setup the project to run inside a Docker container.
-
Make sure Docker is installed on your machine and you've setup permissions correctly. Take a look at this nice guide by the DigitalOcean community to setup Docker on a Linux server.
-
Get the project's code by running
git clone https://github.com/pitscher/grandma-bot.git
-
Inside the project's directory run
docker build -t grandmabot:1.0 .
. Docker will use the projects Dockerfile and build an image. -
You have to provide all needed variables for the bot to function properly. You can use the
docker-start.sh
script from the repo to run the bot once. Fill in the values for the required variables before running the script. -
Run the bash script
./docker-start.sh
. The script takes care of executing the correct docker commands for you. You're done.
Follow the steps below to setup the project to run as a cron job on a Kubernetes cluster.
-
Make sure you build an image of grandmabot and push it as a public image at DockerHub. The already mentioned guide by the DigitalOcean community is very useful if you've never done this before.
-
Check the included k8s manifests inside the
kubernetes
directory. You must setup your DockerHub user and image name atimage:
in thecronjob.yaml
file. -
Apply the manifest
kubectl apply -f cronjob.yaml
. You're done.
Comming soon.