Overview
This bot is built in node.js and uses the Twitter API to search twitter programatically.
Next steps
Among the next steps for this application are building methods for hitting all the different Twitter API endpointsand building out the functionality for saving and anaylizing tweets.
You can view the *project pagefor more details on this project's current tasks.
Running
Pre-requisites
You will need:
- Node.js
- NPM
- A Twitter Developer account
- A mongodb instance (if planning to use the database functionality) otherwise you will need to comment out the mongo related lines in bot.js
Fork the project and create a branch. You can read how to do so here
Create a file called credentials.js to store your bearer token and API keys (obtained from your Twitter Developer Account) as well as your mongodb credentials.
Be sure to add credentials.js to .gitignore so that you don't share them to GitHub should you decide to host your repository there.
Alternately, you can enter these credentials as command line args.
Navigate to the project directory and run npm install
Once dependencies have finished installing, run node bot.js
Performing different searches
In bot.js you can use the methods on getTweets
to perform different searches.
getTweets.searchByHashtag()
allows you to search by hashtag
getTweets.searchByUser()
allows you to search by user
Saving tweets to the database
The bot currently supports two save functions.
Saving users
results.saveUsers
will save a list of user names and the hashtag that was searched for. This the screen_name
attribute on the user object in a status (tweet).
results.saveTweets
will iterate through all the users that have tweeted about a given hashtag and then save that user's recent tweets and their username to the database.