This boilerplate includes a starter set of tools to build a 🤖Telegram bot from scratch in no time:
- NTBA - Telegram Bot API for NodeJS.
- Botan.io - analytics by AppMetrica for your Telegram bot.
- Heroku - cloud platform for application deployment.
# Get the latest snapshot
git clone https://github.com/txwkx/node-telegram-bot-boilerplate.git myBot
# Change directory
cd myBot/
# Install NPM dependencies
npm install
# Or, if you prefer to use `yarn` instead of `npm`
yarn install
- Send @BotFather a
/newbot
message - Pick name and username (e.g., Fitness Trainer + myFitness_bot)
- Receive a BOT_TOKEN;
- Create an AppMetrica account
- Click
+ Add application
button.
! Set the application name to be same as the bot username
- Enter application name (e.g., @myFitness_bot)
- Receive an API KEY aka METRICS_TOKEN;
- Insert the BOT_TOKEN in config.js
- Run
npm run dev
to start the bot in development mode - Do the magic 👾
This project includes examples of handling:
- Commands
- Keyboards
- Inline keyboards
- Payments (soon)
- Create a Heroku account
- Install Heroku CLI
- Create a new app from Heroku WebGUI
! Run the following commands from the console
heroku login
heroku git:remote -a *app_name_on_heroku*
! The next step could be done from Heroku app Settings: -> Reveal Config Vars -> add [KEY = VALUE] pairs.
- Setup config variables
heroku config:set TOKEN=BOT_TOKEN heroku config:set METRICS=METRICS_TOKEN heroku config:set APP_URL=$(heroku info -s | grep web_url | cut -d= -f2)
git add * && git commit -m "my smart comment"
npm run deploy
orgit push heroku master
Now your bot is up and running. (If not - check Heroku View logs)
Be sure to follow the latest updates at Telegram bots API.
In case you want to share your bot - try publishing it at StoreBot.
If you have any suggestion on how to improve the boilerplate or faced any issues feel free to contact me.