All About three persons – I ME and MYSELF
All About three persons – I ME and MYSELF

My way of creating a twitter bot – My first one

With Indian IPL on I decided this is a good use case for creating my first Twitter bot. I will try to find the count of tweets from each IPL Team owners and also analyse the popularity of the tweets based on counts of retweet, likes and follows. I am not planning to use direct message functionality and offend the twitter regulations. Anyway the direct message stuff is broken in Tweepy due to the new twitter API V2 access changes.

So, I intend to keep it simple. Get the tweets of all the IPL Team Owners official tweeter handles. And try to do a simple analysis and build up a daily thread of top official messages. Also utilise the top IPL hashtags for the day.

Getting a twitter developer account

I had to go to the Twitter developer site to apply for a developer account. I chose my personal Twitter user responsible for the developer account. You may chose to create a new twitter account if you want to keep your personal and coding lives separate. But does a developer have a separate life at all.

I had to provide a few details while requesting the developer account activation. Actually it was quite a few details. But this process also forces you to write about your project and its intended use. This does help in convincing you the use-case for the app.

Creating a Project and the app

We can directly create standalone apps outside of Projects and use them but that would mean that they can’t use the the most current v2 Twitter API endpoints and only restricted to “V1.1 ACCESS” . These access are the existing endpoints that connect to the Twitter API. Refer here for more on v1.1 access.

It is now recommended to create projects and embed apps into the projects.

Head on to the Overview section of the Project & Apps tab and hit the +New Project blue button and follow along. It would require you to pick a project name, provide a description and link the app.

You will have to choose the purpose of the app from the list.

After creating a project and attaching the app it would look below snapshot. The main page also has the link to the keys and tokens for my app. The keys and tokens are the only inputs I would be using from the twitter page in my bot/app.

My Project Page
My Project settings
My App Page

This ends our setup at the twitter end. As mentioned above, the keys and tokens are the only inputs I would be using from the twitter page in my bot/app. Now lets getting to creating the twitter both app in python using the Tweepy package.

But do we have to use Tweepy – Alternatives

Yes, I did ask the question myself. The answer to that is – No we do not need to use Tweepy and there are alternatives. But that would mean doing all the steps manually. What is the fun in that in a DIY world.

Creating a Project and the app

Leave a comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.