A twitter bot backend to fetch URLs from google alerts and push them out as tweets with zero infra cost.
-
Set up your google alert with the
Deliver to
field asRSS Feed
. If this field is disabled, try this: while you are on the Google Alerts page, you will have the Settings (Gear) icon in the My alerts section. Please click on that and uncheck the option Digest and then click on Save.Remember to copy the RSS Feed URL once the GAlert is saved, using the RSS icon in the list of you set alerts.
-
Sign up for a twitter dev account (using the bot's twitter account for simplicity), create an application and enter the api connection credentials in main.py
-
Set up a heroku application and push these files into it.
-
Visit
<your app name>.herokuapp.com/news/autotweet
(without a trailing slash) in a browser to test. It should give a JSON response with a status and tweet count. -
Now we need to call this endpoint in regular intervals. Go to script.google.com, create a new project. Enter the following code and plug in your heroku app URL:
function tweetbot_timer() {
Logger.log(UrlFetchApp.fetch("https://<your app name>.herokuapp.com/news/autotweet"));
}
- Set up a new trigger for this script as per your preference, and you're done.