Skip to content

ishan0445/telegraf-telegram-bot-deploy

master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
 
 

Steps to host your Telegram bot

Heroku:

  • Create a Telegram bot with Telegraf API.
  • Create account on Heroku.
  • Install Heroku CLI.
  • Install and setup git.
  • Add micro-bot to the project
    npm install micro-bot --save
  • Remove Telegraf dependency from package.json.
  • set the start command in package.json:
    ...
    "main": "index.js",
    "scripts": {
    "start": "micro-bot"
    }
    ...
  • Make changes in the code.
    • Change the telegraf import to:
      const { Composer } = require('micro-bot')
    • Create bot from Composer:
      const bot = new Composer()
    • Finally remove bot.launch() line instead use:
      module.exports = bot
  • Init a new git repo:
    git init
  • make .gitignore file with following content:
    node_modules
    
  • Login to Heroku:
    heroku login
  • Create a Heroku app:
    heroku create
  • Update Heroku config
    heroku config:set --app YourAppId BOT_TOKEN='YOUR BOT TOKEN'
    heroku config:set --app YourAppId BOT_DOMAIN='https://YourAppId.herokuapp.com'
  • Create a Procfile in the root of the bot with the following content:
    web: micro-bot -p $PORT
    
  • Finally use git to deploy:
    git add .
    git commit -m 'commit message'
    git push heroku master

How to make changes and redeploy the code:

  • Just save all changes.
  • Run following commands:
    git add .
    git commit -m 'commit message'
    git push heroku master

About

Telegram bot deploy steps for Telegraf API using micro-bot

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published