Automate Tweet

In this article I am going to show you steps to automate tweet. We are going to use the most popular programming language Python. If you want other automation ideas then you can read here.


  1. Download & Install Python
  2. Install Tweepy

Twitter Developer Account

You need to register with Twitter Developer Account in order to get API Token and API Secret Keys. These will be required to authenticate to twitter on your behalf. Once you make a for twitter developer account than it is probably going to take approximately 24 hours before Twitter team reviews and approves your request.

Twitter Developer Account Setup to Automate Tweet

You can follow this Twitter’s official link for initial setup of your account.

Download Inspirational Quotes Data

In this program we are using Inspirational Quotes which can be downloaded from here. This file contains around 75000+ Inspirational Quotes. We are going to read quotes from this file and tweet it.

Feel free to use any other dataset if you want.

Python Program to Automate Tweet

Here is the complete code which I have written, of-course you can change it as per your need.

import tweepy
import pandas as pd
import time

latest_tweet_number = 0

with open('C:\\twitter\\latest.txt') as f:
    latest_tweet_number = int(


import pandas as pd
df = pd.read_csv(r'C:\Users\USER\Downloads\quotes.csv', sep=';')

def tweet_now(msg):
    msg = msg[0:270]

        auth = tweepy.OAuthHandler("DthisisnotrealEcjpTv1", 
        api = tweepy.API(auth)
            print("Authentication OK")
            print("Error during authentication")
        api = tweepy.API(auth, wait_on_rate_limit=True, wait_on_rate_limit_notify=True)

    except Exception as e:

for idx, rows in df.iterrows():
    if idx <= latest_tweet_number:
    hashtags = '#inspirational #inspiration #motivation #motivational #inspirationalquotes #inspire #motivationalquotes #quotes #love #quoteoftheday #success #believe #mindset #life #positivevibes #entrepreneur #quote #positivity #goals #selflove #happiness #lifestyle #successquotes #bhfyp #yourself #thoughts #instadaily #loveyourself #photooftheday #bhfyp'
    tweet_now(rows['QUOTE'] + ' - ' + rows['AUTHOR'] + '\n\n\n' + hashtags)
    with open('C:\\twitter\\latest.txt',"w") as f:


Scheduling Program

If you want to run this program 24*7 then you need to make sure that you are running it on one of the servers which remains always available. I would recommend to use IBM Cloud as you can just sign-up there without the need of using any Credit Card.

I tried using IBM Cloud Functions which gives you option to run your Python program without the need of creating any servers. IBM Cloud Function is server-less which can be used to trigger your python code based on any Trigger or Scheduled Frequency.

Automate Tweets Video

If you are someone who likes to see the steps in order to understand it better than you can watch this video.