The Reality of Twitter Puffery. Or Why Does Everyone Now Hate Bots?
5 stars based on
50 reviews
If you read the first part of my tutorialyou already know how to make a Twitter Bot with Node. In the second part of the Twitter Bot tutorial, we will continue to extend our Bot by adding functionality that will tweet back to any Twitter bot status like for twitter who follows our bot. You can take a look at the complete bot. Also, make sure you have the twit npm module installed.
First, we bot status like for twitter to set up a stream. Fortunately, our 3rd party npm dependency twit provides an API function. Right now we are only interested in the follow event, however the basic syntax is similar to every event. When a user follows our Twitter Bot, the follow event will trigger the callback associated with it, in our case followed.
In the followed callback, we pass an event argument which gets the Twitter handle and the screen name of the user. In the last line, we invoke a bot status like for twitter function that replies back to the user who followed our bot. The tweetnow function takes a string as an argument and updates our bots status. In other terms, it tweets by using. If you noticed in the previous tutorial when retweeting or favoriting a tweet, we used.
Unlike in the previous tutorial, we don't need JavaScripts Timer function this time, since we are using the Streaming API which helps to keep the connection alive. To avoid this monotonous process, you can use npm scripts or nodemon. You can also deploy this app on Heroku for a continuous deployment. If you are planning to deploy on Herokumake sure to include a Procfile in the root of your directory structure and add the following line to the file:.
If you are using npm scriptsmake sure you edit the scripts attribute in the package. If you are interested in Twitter Bots, check Botwiki.
The sole purpose of Bot as a web application is automation. For example, when I created my first Twitter Bot nodejstweetsthe whole idea was to remain up to date with the most recent happenings. You can do a lot of things with a Twitter Bot, whether for your own sole purpose or to solve a purpose for a community. Bot status like for twitter DaysOfCode as a great example. If you have any questions let me know in the comments, otherwise, see you on Twitter!
Before starting this, make sure your directory structure includes: This endpoint gets called whenever you tweet from your Twitter account.
Here comes the complete code of our bot: If you are planning to deploy on Herokubot status like for twitter sure to include a Procfile in the root of your directory structure and add the following line to the file: