I keep experimenting with go and bots, so this week I decided to create a Twitter bot. It’s not the typical bot that just publishes things or does some scraping, this one will react to mentions; each time someone mentions the bot, it will reply with a “hello”. This is possible through the Account Activity API of Twitter, which will call our service for every new event related to our bot.
The code is pretty simple and straightforward, so I will not get into too many details; there are 3 endpoints on our server:
This is where the behavior of our bot lives. So, in my case is only replying with “hello”, but here is where you would make any customization in case you clone/fork it.
For security reasons, Twitter requires us to have an endpoint that will solve a CRC request. So we follow Twitter guidelines and that’s what this endpoint is doing.
Nothing fancy. Just returning “Server is up and running” for you to make sure that the server is up and running.