Telegram Bot

Usage no npm install needed!

<script type="module">
  import tgbotars from '';


Library features:

🔨 Installation

Download and install via npm package manager (stable):

npm install tgbotar --save

Or clone fresh code directly from git:

git clone
cd tgbotar
npm install

📌 Usage

Import tgbotar module and create a new bot object:

const TGBotar = require('tgbotar');
const bot = new TGBotar('TELEGRAM_BOT_TOKEN');

bot.on('text', (msg) => msg.reply.text(msg.text));


Don't forget to insert your Telegram Bot API token key.

🔖 Examples

  • Send text on /start or /help command:
bot.on(['/start', '/help'], (msg) => msg.reply.text('Hello World'));
  • Send photo:
bot.on('/photo', (msg) => {
  • Command with arguments /echo <message>:
bot.on(/^\/echo (.+)$/, (msg, argu) => {
    const text = argu.match[1];
    return bot.sendMessage(, text);

See more examples!

⏰ Events

Use bot.on(<event>, <function>) to handle all possible TGBotar events. For example, to catch a command, just add a slash:

bot.on('/start', (msg) => {
  return bot.sendMessage(, `Hello, ${ msg.from.first_name }`);