(work in progress...)
Note: You can see the bot on Twitter.
Apps hosted on Glitch are automatically put to sleep after 5 minutes of inactivity (that is, if nobody opens your app in a browser window or it doesn't receive any data).
Twitter's API doesn't send requests to your app, instead your app has to poll Twitter for data, which means, the bot will simply doze off after the first five minutes and will sleep through all the DMs and tweets it receives.
If you want your bot to respond to @ mentions and DMs, you can wake it up every 25+ minutes using a web service like Uptime Robot, cron-job.org, or others, have the bot search for tweets mentioning it, and respond to those tweets and any DMs it received.
- First, create a new Twitter account and a new Twitter app. (This tutorial shows how.)
- Update the
.env
file with your Twitter API key/secrets (the tutorial above explains how to get these) and your bot's username. - Update
server.js
with some cool Twitter bot code. - Set up a free service (Uptime Robot, cron-job.org, or others) to wake up your bot every 25+ minutes and tweet. Use
https://YOURPROJECTNAME.glitch.me/tweet
as a URL to which to send the HTTP request.
Check out the Twit module documentation for examples of what your bot can do, for example retweet a specific tweet by its ID:
T.post('statuses/retweet/:id', { id: '799687419259797504' }, function (err, data, response) {
console.log(data)
});
You can find more tutorials and open source Twitter bots on Botwiki.
And be sure to join the Botmakers online hangout and submit your bot to Botwiki :-)
🙇
Powered by Glitch
\ ゜o゜)ノ