Search code examples
node.jstwitter

How to make twitter bot track tweets from our followers?


I was making a twitter bot with Twit, I found making tutorials using T.stream('user') to get stream data about our account, now its deprecated. So in 2021, how can i achieve these? requirements:

  1. Know when someone follows my bot, and make a thanks post.
  2. Know when someone in my followers list or following list makes a tweet.

Also I have a doubt, when we use stream, old data is also coming, so how exactly stream works? if i only want latest tweets, I have to sent get by setting interval?


Solution

  • For the new followers, you will need to build something using the Account Activity API, which uses webhooks to send you event messages. You will need to filter for the follow events.

    For new Tweets from people you are following, you will need to poll the home timeline endpoint. There’s no realtime method for this.