Creating a Twitter bot with Node.js
This tutorial will show you how to create a simple twitter bot that tweets at users that have tweeted public tweets with certain keywords. It will also tweet normal tweets randomly at configurable intervals.
NOTE: This tutorial assumes you have node, npm, and git installed. If you don’t have these tools install them first.
Open a terminal window and enter the following command:
git clone [email protected]:kklopfenstein/simpletweet.git
Install the dependencies:
npm install twit
npm install datejs
npm install sqlite3
npm install moment
npm install node-rest-client
Now open the twit_config.json in your favorite editor:
cd simpletweet
vim twit_config.json
Set the twit_data information to your twitter information (consumer key, consumer secret, access token, access token secret). If you don’t know this info visit https://dev.twitter.com/apps/new.
Set the phrases array to the random phrases you want your bot to tweet. For example:
"phrases": [
"phrase1",
"phrase2",
"phrase3"
]
The twitter bot script will search public tweets for a specific phrase. Enter this phrase under search_phrase.
Enter your bot’s screen name under bot_screen_name.
Now you’re all set! Run the twitter bot with:
node simpletweet.js
You can follow me on twitter at @klopkev.