A simple Twitter bot that uses Node.js to automate tweets. Good for beginners if you want to learn some Node.js.
From the command line / terminal, how can you connect and authenticate to the Twitter API and get information such as:
- Searching Twitter
- Look for who has replied to you on Twitter
- Post Tweets yourself back to Twitter
- and much more
Make a program that will run every x minutes or x hours and post a tweet automatically based on some other type of algorithmic set of rules that you may want to make.
Use npm (node package manager) to spin up a larger Node project and use a Twitter package to connect to the Twitter API.
- Clone this repository
- Must have Git installed and in your PATH
- Make sure you have Node.js installed and in your PATH
- In your terminal, go to the location where you cloned this repository
- Type
npm startin your terminal- This will run
node bot.jsfor you, which will spit information from Twitter to your console from the conditions made inbot.js
- This will run
- Download Node.js
- Get it Installed
- Figure out how to get to the command line / terminal
- Type Node into your terminal
- Enter some JavaScript that will run some small JavaScript program that just spits something back to the console
Next: How to use npm (node package manager) to spin up a larger Node project and use a Twitter package to connect to the Twitter API.
How do you install an npm package?
npm install <package-name>
One of the things that happens when you're working on a Node project is you want to have this file called package.json.
A package.json is a file that holds your projects "settings", "configuration", and other dependencies you need to use.
- Create a package.json file using the
npm initcommand in your terminal npm install twit --savecommand saves a reference to the twit package to your package.json file as a dependency- Add
"start": node bot.jsto your scripts in your package.json file. Doing so will enable you to runnpm startwhich will runnode bot.jsfor you.
Thank you to ttezel for creating the twit package.