Create Your Own Twitter Bot

Earlier this year, we discussed on how Organisations are leveraging social-media as a key component of their marketing strategies, and how social-media is key for engaging with customers, creating awareness, and driving sales.

An extensive community engagement is key to any effective social media strategy. This engagement, however, may result in resources spending man-hours on repetitive tasks. This will have a negative impact on both the budget and employee satisfaction. Bots can be highly productive tools to automate a part or all of your Twitter activity, allowing you to stay in touch with the community while saving time and money.

In this post, we’ll build a simple Twitter bot that will search for specified text phrases in the background and perform pre-defined actions on each one in turn.


  • A Twitter Developer Account account.

Create Twitter Application

  • Create a developer account if prompted.
  • Provide app name and click on Get Keys.
  • Copy API Key and API Secret Key and Save it.

Configure Twitter Application Permissions

  • Click on Set up under User authentication settings
  • Toggle OAuth 1.0a and Select Read and write and Direct message
  • Provide below details and Click on Save
    • Callback URI / Redirect URL – destinations to redirect after authentication process.
    • Website URL
  • In the prompt window to confirm permission changes, Click on Yes.

Generate access token and secret access token

  • Under Keys and Tokens, click on Generate
  • Save Access Token and Secret for later use.

Configure the Twitter Bot

  • Sign-in into Twitter Bots app
  • Provide below details:
    • Consumer Key – API key
    • Consumer Secret – API Secret
    • Access Token
    • Access Secret
    • Twitter Search – Bots will use this phrase to search and take action on match e.g. “CloudWizardInc”,”AzureBlog” etc.
    • Select Action – Action to be taken by the bot e.g. Send Public reply, Retweet Tweet etc.
  • Click on Save.

The bot is now initialised, and will run in the background to search for specified text phrases on Twitter. Then, the bot will take pre-defined action on each of the tweet which were part of the search result sequentially. 

You have options to upgrade to Premium APIs or Enterprise APIs depending upon the consumption or usage plan. The premium APIs are built with the similar functionality as the enterprise APIs, but are available via an adjustable monthly pricing model. 

Categories: Twitter

Tags: , ,

Leave a Reply