Starter pack for running telegram bot on the Heroku using Node.js
- node ^18
- Create your own bot using Telegram's BotFather and grab your TOKEN.
- Clone or download and unpack this repo.
- Go to the app's folder using
cd ~/heroku-node-telegram-bot
- Run
npm install
(in some cases you will need to run this with sudo, you know, just the permissions). - Rename .env_example file into .env and set TG_BOT_TOKEN to the value, you've got from the BotFather.
- Run
npm run dev
and send smth to your bot. - After it says "hello" to you, we can go to the next step 😎
- Create the Heroku account and install the Heroku Toolbelt.
- Login to your Heroku account using
heroku login
. - Go to the app's folder using
cd ~/bot-template
- Run
heroku create
to prepare the Heroku environment. - Run
heroku config:set TG_BOT_TOKEN=SET HERE THE TOKEN YOU'VE GOT FROM THE BOTFATHER
andheroku config:set HEROKU_URL=$(heroku info -s | grep web_url | cut -d= -f2)
to configure environment variables on the server. - Run
git add -A && git commit -m "Ready to run on heroku" && git push heroku main
to deploy your bot to the Heroku server. - Send smth to the bot to check out if it works ok.
Possible issues:
After installing modules (npm i) check that package.json (only) has this stroke: "type": "module"