- 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
- Change the telegraf import to:
- 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
- Just save all changes.
- Run following commands:
git add . git commit -m 'commit message' git push heroku master