This is a template for making fun Twitter bots with Glitch and the Twit node.js library. For a bit more advanced version of this starter project see twitterbot-advanced.
- Create a new Twitter account and a new Twitter app. (See how.)
- Update the
.env
file with your Twitter API key/secrets and change theBOT_ENDPOINT
(it could just be random letters). - Update
server.js
with some cool Twitter bot code. (Make sure your bot follows Twitter's rules and is overall not a jerk.) - Set up a free service (Uptime Robot, or a similar one) to wake up your bot every 25+ minutes and tweet. Use
https://YOUR_PROJECT_NAME.glitch.me/BOT_ENDPOINT
as a URL to which to send the HTTP request.
The included example tweets out "hello world 👋". Check out the Twit module documentation for more examples of what your bot can do.
You can find more tutorials and open source Twitter bots on Botwiki. Be sure to join Botmakers and submit your bot to Botwiki :-)
For more bot starter projects on Glitch, check out the official Botwiki page on Glitch.
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.
See this Glitch starter project where i work around this limitation and make a Twitter bot that responds to DMs and @ mentions (with a 25 minute delay).
🙇
Powered by Glitch
\ ゜o゜)ノ