Deploying our Telegram Bot to Heroku [Part — 4]


What’s Heroku?

Process Types

Web Process

Worker Process

Deploy to Heroku

  • Create a new app, and select the Europe region, as the app will be closer to Telegram BOT API Servers, which will improve the response times of the application.

Defining process type & runtime

Worker Configuration

Web Configuration

import os
PORT = int(os.environ.get('PORT', 5000))
# replace this line
# with
webhook_url='https://<your-app-name>' + TOKEN)
  • Create a runtime.txt file and mention the version of python to run the application Ex: python-3.10.6
  • Create a Procfile file with no extension
  • Define the process as either web or worker and the file to be executed. Ex:
web: python3

Deploying using Git

  1. Open CMD and use the command heroku login.
  2. Login into your Heroku account.
  3. Open your working directory and initialize the repo using git init and set the remote heroku git: remote -a <your-app-name>
  4. git add .
  5. git commit -m "Initial Commit"
  6. git push heroku master
  7. To look at the application logs use heroku logs -t

Deploying using GitHub

Things to remember


Dyno Hours

Free Dynos

Dyno restarts

Worker vs Web

Alternatives to Heroku

Useful links




Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store