Skip to content

πŸ€– Boilerplate for creating Telegram bots using Node.js

Notifications You must be signed in to change notification settings

txwkx/node-telegram-bot-boilerplate

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

1 Commit
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

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:

  • Commands
  • Keyboards
  • Inline keyboards
  • Payments (soon)

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.

Releases

No releases published

Packages

No packages published