Building your first Twitter bot
Let's build a simple Twitter bot. This bot will listen to tweets and pick out those that have a particular hashtag. All the tweets with a given hashtag will be printed on the console. This is a very simple bot to help us get started. In the following sections, we will explore more complex bots.
- Go to the root directory and create a new Node.js program using
npm init
:

- Execute the
npm install twitter --save
command to install the Twitter Node.js library:

Run npm install request --save
to install the Request library as well. We will use this in the future to make HTTP GET
requests to a news data source.
- Explore your
package.json
file in the root directory:
{ "name": "twitterbot", "version": "1.0.0", "description": "my news bot", "main": "index.js", "scripts": { "test": "echo \"Error: no test specified\" && exit 1" }, "author": "", "license": "ISC", "dependencies": { "request": "^2.81.0", "twitter": "^1.7.1" } }
- Create an
index...