Awesome
<img src="http://i1-news.softpedia-static.com/images/news2/telegram-adds-video-player-and-drafts-on-android-and-ios-apps-505276-2.jpg" width="150"><img src="https://appmetrica.yandex.com/ogimage.png" width="180"><img src="https://cdn.joinhoney.com/images/lp/store-logos/herokuapp-logo.png" width="140">
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.
Getting Started π
# 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
Telegram π
- Send @BotFather a
/newbot
message - Pick name and username (e.g., Fitness Trainer + myFitness_bot)
- Receive a BOT_TOKEN;
Metrics π
- 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;
Hacking π©π»βπ» π¨πΌβπ»
- 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)
Deployment π³
- 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
Congrats!β¨π
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.
Contributing π³
If you have any suggestion on how to improve the boilerplate or faced any issues feel free to contact me.