Home

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:

  1. NTBA - Telegram Bot API for NodeJS.
  2. Botan.io - analytics by AppMetrica for your Telegram bot.
  3. 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 πŸ—ž

  1. Send @BotFather a /newbot message
  2. Pick name and username (e.g., Fitness Trainer + myFitness_bot)
  3. Receive a BOT_TOKEN;

Metrics πŸ“Š

  1. Create an AppMetrica account
  2. Click + Add application button.

! Set the application name to be same as the bot username

  1. Enter application name (e.g., @myFitness_bot)
  2. Receive an API KEY aka METRICS_TOKEN;

Hacking πŸ‘©πŸ»β€πŸ’» πŸ‘¨πŸΌβ€πŸ’»

  1. Insert the BOT_TOKEN in config.js
  2. Run npm run dev to start the bot in development mode
  3. Do the magic πŸ‘Ύ

This project includes examples of handling:

Deployment πŸ›³

  1. Create aΒ Heroku account
  2. Install Heroku CLI
  3. Create a new app from Heroku WebGUI

! Run the following commands from the console

  1. heroku login
  2. 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.

  1. 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)
    
  2. git add * && git commit -m "my smart comment"
  3. npm run deploy or git 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.