Build a Telegram Bot That Makes Money: Complete Node.js Guide
Build12 min read·April 15, 2026·--

Build a Telegram Bot That Makes Money: Complete Node.js Guide

Telegram bots are easier to build than WhatsApp bots, have no per-message fees, and serve a global audience. Here's the full guide from bot creation to paying customers.

@
@kivorablog
April 15, 2026
Share

Telegram vs WhatsApp for Bot Businesses


Before building, understand the trade-offs:


FactorTelegram BotWhatsApp Bot
API costFree, no per-message fees$0.005–$0.08 per message (Meta)
Setup complexityLow — official free Bot APIHigh — requires Meta Business verification
Global reach900M users, strong in NG/GH/KE2.8B users, dominant in Africa
Bot capabilitiesRich: inline keyboards, files, paymentsBasic: text + media
Group featuresFull bot support in groupsLimited
Best forContent, communities, developer toolsBusiness customer service

The strategic answer: build Telegram bots for developers, communities, and content delivery. Build WhatsApp bots for local business customer service.




Step 1: Create Your Bot


  • Open Telegram and search for @BotFather
  • Send /newbot
  • Choose a name (displayed in chats): e.g. "Kivora Assistant"
  • Choose a username (must end in 'bot'): e.g. "kivoraassist_bot"
  • Copy the API token you receive

Store it:

TELEGRAM_BOT_TOKEN=123456789:AAFxxxxxxxxxxxxxxxxxxxxx

Step 2: Build the Foundation

mkdir telegram-bot && cd telegram-bot
npm init -y
npm install node-telegram-bot-api dotenv express
// bot.js
require('dotenv').config()
const TelegramBot = require('node-telegram-bot-api')

const bot = new TelegramBot(process.env.TELEGRAM_BOT_TOKEN, { polling: true })

// Handle /start command
bot.onText(/\/start/, (msg) => {
  const chatId = msg.chat.id
  const name   = msg.from.first_name

  bot.sendMessage(chatId,
    `Welcome, ${name}! 👋\n\nI'm your AI assistant. Here's what I can do:\n\n/ask [question] — Ask me anything\n/summary — Summarise a URL\n/help — Show this menu`,
    {
      reply_markup: {
        inline_keyboard: [[
          { text: '🤖 Ask a Question', callback_data: 'ask_mode' },
          { text: '📰 Summarize URL',  callback_data: 'summary_mode' }
        ]]
      }
    }
  )
})

// Handle callback from inline keyboard
bot.on('callback_query', (query) => {
  const chatId = query.message.chat.id
  const data   = query.data

  bot.answerCallbackQuery(query.id)

  if (data === 'ask_mode') {
    bot.sendMessage(chatId, 'Ask me anything! Type your question:')
  }

  if (data === 'summary_mode') {
    bot.sendMessage(chatId, 'Paste a URL and I'll summarize it for you:')
  }
})

// Handle regular text messages
bot.on('message', async (msg) => {
  if (msg.text && !msg.text.startsWith('/')) {
    const chatId = msg.chat.id
    // Send "typing..." indicator
    bot.sendChatAction(chatId, 'typing')
    // Process the message (add your AI logic here)
    bot.sendMessage(chatId, `You said: "${msg.text}". AI response coming soon!`)
  }
})

console.log('Bot is running...')

Step 3: Add AI With Groq

npm install groq-sdk
const Groq = require('groq-sdk')
const groq = new Groq({ apiKey: process.env.GROQ_API_KEY })

// Conversation memory per user (replace with Redis/Supabase for production)
const conversations = new Map()

async function askAI(userId, userMessage) {
  if (!conversations.has(userId)) {
    conversations.set(userId, [])
  }

  const history = conversations.get(userId)
  history.push({ role: 'user', content: userMessage })

  // Keep last 10 messages to avoid token overflow
  const recentHistory = history.slice(-10)

  const completion = await groq.chat.completions.create({
    model: 'llama-3.3-70b-versatile',
    messages: [
      {
        role: 'system',
        content: 'You are a helpful AI assistant on Telegram. Be concise — Telegram messages work best under 500 words. Use bullet points for lists.'
      },
      ...recentHistory
    ]
  })

  const reply = completion.choices[0].message.content
  history.push({ role: 'assistant', content: reply })

  return reply
},

// Updated message handler with AI
bot.on('message', async (msg) => {
  if (!msg.text || msg.text.startsWith('/')) return

  const chatId = msg.chat.id
  const userId = msg.from.id

  bot.sendChatAction(chatId, 'typing')

  try {
    const reply = await askAI(userId.toString(), msg.text)
    bot.sendMessage(chatId, reply, { parse_mode: 'Markdown' })
  } catch (err) {
    bot.sendMessage(chatId, 'Sorry, I had trouble processing that. Try again in a moment.')
  }
})

Step 4: Add Payments With Telegram's Built-In Payment API

Telegram has a native payment system — users never leave the app:

// Send an invoice
bot.onText(/\/premium/, async (msg) => {
  const chatId = msg.chat.id

  await bot.sendInvoice(
    chatId,
    'Kivora Pro',                           // Title
    'Unlimited AI queries for 30 days',     // Description
    'premium_30days',                       // Payload
    process.env.STRIPE_PROVIDER_TOKEN,      // Payment provider token
    'USD',                                  // Currency
    [{ label: 'Pro Plan', amount: 999 }]   // Prices (in cents = $9.99)
  )
})

// Handle pre-checkout
bot.on('pre_checkout_query', (query) => {
  bot.answerPreCheckoutQuery(query.id, true)
})

// Handle successful payment
bot.on('successful_payment', async (msg) => {
  const chatId  = msg.chat.id
  const payload = msg.successful_payment.invoice_payload

  // Update user's plan in your database
  if (payload === 'premium_30days') {
    await upgradeToPro(msg.from.id)
    bot.sendMessage(chatId, '✅ Payment successful! You now have Pro access for 30 days.')
  }
})

Step 5: Deploy With Webhooks (Better Than Polling)

Polling constantly checks for new messages — inefficient for production. Webhooks let Telegram push messages to your server instantly:

// webhook-server.js
require('dotenv').config()
const TelegramBot = require('node-telegram-bot-api')
const express     = require('express')

const bot = new TelegramBot(process.env.TELEGRAM_BOT_TOKEN)
const app = express()

app.use(express.json())

// Set webhook (run once)
const WEBHOOK_URL = `https://your-server.com/bot${process.env.TELEGRAM_BOT_TOKEN}`
bot.setWebHook(WEBHOOK_URL)

// Handle webhook requests
app.post(`/bot${process.env.TELEGRAM_BOT_TOKEN}`, (req, res) => {
  bot.processUpdate(req.body)
  res.sendStatus(200)
})

app.listen(3000, () => console.log('Webhook server running'))

Monetisation Models for Telegram Bots

ModelHow It WorksRevenue Potential
FreemiumFree tier (10 queries/day), paid for unlimited$5–$20/month per user
Channel subscriptionBot manages access to premium channel$5–$50/month per subscriber
B2B white-labelSell customised bots to businesses$200–$2,000 setup + $50–$300/month
Lead generationFree bot for a niche, sell the leads$5–$50 per qualified lead
AffiliateBot recommends products, earns commission10–40% per sale

The most reliable model for African markets: B2B white-label. Find businesses that need a Telegram community bot, build it once, charge a monthly management fee.

Read more on Kivora Blog

Read more on Kivora Blog

Get started →