This is a very simple application, a proof of concept as working code written in Golang, that access Twitter API to send an answer in the name of the account owner for those tweets that matches the query pattern.
The Docker image is hosted at Docker Hub and it is build and pushed through GitHub Actions.
$ docker build -t twitter-echo-bot .
$ docker run -p 8080:8080 \
-e CONSUMER_API_KEY="key" \
-e CONSUMER_API_SECRET="secret" \
-e ACCESS_TOKEN="token" \
-e ACCESS_TOKEN_SECRET="token_secret" \
-e SEARCH_QUERY="#ariel17echobot" \
-e GREET_TEXT="Hellou!" \
-e RESPONSE_TEXT="bip bop bip!" \
-e JOB_SECONDS=10 \
twitter-echo-bot
Using an .env
is preferred, also the deployment process uses it to provide
the required settings to the application instead of setting raw environment
variables. Watch out to not track it!
$ docker run --env-file=.env twitter-echo-bot
This project includes a Makefile to avoid writting all those commands by hand and go directly to the point with the same results:
$ make build # to test and build the image with :dev tag
$ make run # builds AND executes the application in your terminal
The deployment is made using Terraform to a AWS t2.nano instance. The execution plan works as follows: