Home / Blog & Tutorials / Frameworks

Hosting Node.js & Telegraf Telegram Bots 24/7 on Cloud Containers

While Python is extremely popular for Telegram bots, JavaScript and Node.js are revered for high-throughput I/O performance. Using libraries like Telegraf or GrammY, you can handle thousands of concurrent updates with minimal memory overhead.

Sample Telegraf v4 Application

// index.js
const { Telegraf } = require("telegraf");

const bot = new Telegraf(process.env.BOT_TOKEN);

bot.start((ctx) => ctx.reply("👋 Hello! I am a Node.js bot running 24/7 on BotifyHost!"));

bot.help((ctx) => ctx.reply("Send me any message and I will echo it back."));

bot.on("text", (ctx) => {
    ctx.reply(`Echo: ${ctx.message.text}`);
});

bot.launch().then(() => {
    console.log("Telegraf bot is polling on BotifyHost cloud servers 🚀");
});

// Enable graceful stop
process.once("SIGINT", () => bot.stop("SIGINT"));
process.once("SIGTERM", () => bot.stop("SIGTERM"));

Configuring package.json

{
  "name": "my-telegram-bot",
  "version": "1.0.0",
  "main": "index.js",
  "scripts": {
    "start": "node index.js"
  },
  "dependencies": {
    "telegraf": "^4.16.3"
  }
}

Deploying on BotifyHost

Upload your index.js and package.json to BotifyHost. Our container automatically executes npm install --production, starts your Node.js runtime, and protects it with anti-crash monitoring.

BotifyHost

Written by Alex Johnson

Specialist at BotifyHost Cloud Infrastructure. Passionate about Telegram MTProto protocol, Python asynchronous concurrency, and building high-performance hosting clusters for developers worldwide.

Host Your Telegram Bot 24/7 on BotifyHost

Say goodbye to laptops running overnight and sleeping web dynos. Deploy your bot in 30 seconds with 99.99% uptime, built-in code editor, and live logs.

Need Help? Chat on Telegram