DEV Community

Gie Zoljic
Gie Zoljic

Posted on

Twitter Bot 🤖

It’s no secret that there are bots on Twitter.

Twitter bots can do a heck of a lot more than just spam trending hashtags and relentlessly follow users or liked tweets. I personally use a bot to enhance my portfolio by liking and re-tweeting subjects I have an interest in -- like #programmingmemes.

Today’s social media environments probably contain more bots than you’re aware of. Perhaps none of these environments are more bot-friendly than Twitter, and the proof is in the numbers.

So, here's what i did, ready to get started? OK. Let’s do this!

How to build a Twitter Bot in 30 minutes:

1. Apply for a developer account

To build your bot, you’ll need to apply for a developer account. Don’t worry, creating apps on Twitter is free!

Head over to developer.twitter.com to get started. Be sure to add your phone number to your Twitter account before clicking the Create your Twitter application button.

User profile

Select a user profile that is most likely to be associated with the bot. This can be your own personal account, or you can create a new Twitter account altogether.

Keep in mind, if you create a new Twitter account solely for the bot, your personal information will still need to be verified – like phone number and email address.

You should now be in the ‘Application Management’ section, where you will need to take a note of your keys. You should have your ‘Consumer Key (API Key)’ and ‘Consumer Secret (API Secret)’ already available.

You’ll need to scroll to the bottom of the page and click the Create my access token to get the ‘Access Token’ and ‘Access Token Secret’ take note of all four of them you’ll need them when setting up the bot.

2. Set up your development environment

Now comes the fun part – programming your Twitter bot.

For this I’m just going to say use Visual Studio Code. and i follow this steps from [Dev Ed](https://www.youtube.com/channel/UClb90NQQcskPUGDIXsQEz5Q)

Full Code Here:

GitHub logo Giezoljic / twitterbot

A TwitterBot (or Twitter Bot) is a twitter account whose actions are automated through an exterior software program. These automated actions include posting, liking, retweeting, following, messaging or any combination of these actions specified by the user and on a user-defined schedule, with the intent of engaging real twitter users and/or other bots to raise awareness around a brand, political cause, or business.

3. Test the bot

If all goes well, your bot should be completing its action, but it doesn’t hurt to run some tests.

Made it this far? Wow, thanks for reading! If you liked this story, please don’t forget to recommend it by clicking the ❤

Top comments (0)