Twitter Bot using Python and Deployed on Heroku

Twitter Bot using Python and Deployed on Heroku

Introduction:

Hello Everyone, Let’s check out Twitter Bot using Python. So we’re gonna automate your Twitter account, you can add many functionally as you want and make it even cooler. Let’s get started….

Pre-requisites:

  1. First of all, create Twitter Developer Account for your Twitter Bot’s Account Here
  2. Fill up all details which are needed
  3. Get keys (API KEY, API KEY SECRET, ACCESS TOKEN, ACCESS TOKEN SECRET) from your Twitter Account
  4. Create Twitter App. Make Sure to give Read and Write Permission
  5. Create Heroku Account Here

I’ve already created one and deployed it on Heroku source code, It is tweeting already Here

Set-up on Machine

  1. Clone this Repository. (Make necessary changes in utils/tweet_it.py like set up while loop so it tweets the right message at right time)
  2. You can remove those greetings functions in tweet_it.py if you don't want them.
  3. open the tweet-it directory and type the below command

python3 -m venv twitter-bot && source environment/bin/activate

pip install -r requirements.txt

  • Now it’s time to add Credentials. if you want to test this Twitter bot you can directly replace the key with your key. but if you want to deploy it then STOP, we have got a better approach.

Deploy

  1. Login to Heroku. Create new app
  2. Now go to settings and put your secret keys in the config vars section.
  3. Now open a terminal in your root directory of the project and login to Heroku from CLI.

heroku login

git init

heroku git:remote -a tweet-it

git add .

git commit -am "initial commit"

git push heroku master

  • Now Most importantly set worker=1

heroku ps:scale worker=1

Now it should be running by now.

Thank You ☺️

Let me know if you are stuck somewhere while performing the above process

Did you find this article valuable?

Support ARTH PRAJAPATI by becoming a sponsor. Any amount is appreciated!