Skip to content

AnshumanFauzdar/telegram-bot-heroku-deploy

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

34 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Intial Deploy to heroku

Intially I was not able to push a simple bot to heroku, but yeah googling a lot made it work!

Very Initial Steps [NOOB Steps]

  1. Install Telegram :)
  2. Create a telegram bot by talking to Bot Father
  3. Install python in your computer, if you are on windows follow this
  4. Install git, follow this
  5. Install Heroku account here
  6. Install Heroku CLI from here
  7. Install editor of your choice, I preffer Atom

Step 0 [Optional]:

  • Just git clone this repository and start working by editing the code
    git clone https://github.com/AnshumanFauzdar/telegram-bot-heroku-deploy.git
    cd telegram-bot-heroku-deploy
  • Or follow steps below!

Step 1:

  • Create your bot like we have bot.py and write any python code that is intially working on your local machine!

Step 2:

  • Make a folder like telegram-bot and put bot.py in the folder

Step 3:

  • Make a blank python file named
    __init__.py

Step 4:

  • Make a Procfile this should be without any extension like .txt, you can go to view -> tick file name extensions and remove any extension
    worker: python bot.py
  • Write this in Procfile by using notepad or any editor of your choice! Here bot.py is your python code!

Step 5:

  • Now we have to make a requirements.txt through which heroku will install the dependencies to make our bot work!
  • What to add in requirements.txt
    • Mine looks like this:
    future>=0.16.0
    certifi
    tornado>=5.1
    cryptography
    python-telegram-bot
    

Add anything which you have included in the python code!

Step 6:

  • Change directory to where you have made these files
  • now in git bash CLI, intialize a git
    git init
    

Step 7:

  • Now install heroku CLI
  • Next
    heroku login
    heroku create app_name
  • If you have already created app then select it:
    heroku git:remote -a app_name
  • Or else continue:
    git add -f bot.py Procfile requirements.txt __init__.py
  • git commit -m "Added Files"
  • Push files to heroku:
    git push heroku master
  • If it is not working then try this one:
    git push heroku master --force

At this point your bot should be running, you can check by

  •  heroku ps

If it is not running then we have to reset dynos:

  • heroku ps:scale worker=0
  • heroku ps:scale worker=1

Now it should be running fine! Enjoy :)

If you are trying to lazy which you should not! (Deploying to Heroku)

Deploy

Choose App name and deploy! Follow from Step 7 and edit bot.py with your token! And finally deploy!

Want a video tutorial?

About

Detailed guide to initially deploy a simple telegram python bot to heroku

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages