Template

Telegram long polling minimal

getUpdates loop with offset tracking and SIGTERM stop.

Download ZIP (3.3 KB)

SHA-256: 0bae23d556b768b0eb3d6869f32afb24b7382e2a8bbb03fabf3bf61ead21ffda (checksum file)

Stack: Node.js 20+ · License: MIT · Files: 10

What it includes

getUpdates loop with offset tracking and SIGTERM stop.

File tree

telegram-longpoll-minimal/
├── src/
│   ├── logic.js
│   └── poll.js
├── tests/
│   └── logic.test.js
├── .dockerignore
├── .env.example
├── .gitignore
├── Dockerfile
├── LICENSE
├── package.json
└── README.md

Setup

unzip telegram-longpoll-minimal.zip && cd telegram-longpoll-minimal
cp .env.example .env
npm test
npm run dev

Fill in .env with credentials from the platform's official developer console. Never commit it: the included .gitignore excludes it.

Step-by-step guide

  1. Download the ZIP above, check its SHA-256 and unzip it.
  2. Open @BotFather, /newbot, copy token into BOT_TOKEN. Generate WEBHOOK_SECRET if used.
  3. Copy .env.example to .env (or .dev.vars for Workers) and paste the values. Never commit it.
  4. Install dependencies and run the tests: they pass without network access.
  5. Run it locally with the commands in the Setup section and send your bot a message.
  6. Push the folder to a private GitHub repository so a host can build it.

Deploy on Railway

  1. Press Deploy on Railway below and sign in (it opens a new Railway project).
  2. Choose Deploy from GitHub repo and pick your repository. Railway detects the included Dockerfile.
  3. Open Variables and add: BOT_TOKEN, WEBHOOK_SECRET (if webhook), PORT.
  4. No public domain is needed: the bot opens an outbound gateway connection.
  5. Watch the deploy logs until the bot reports it is running, then test it. Set a usage limit in your Railway workspace settings.

Deploy on Railway

Affiliate link (referral code 8Mexkc): BotNetwork may earn a commission at no extra cost to you. The button opens Railway's new-project page; this template is not a published one-click Railway template, so you connect your own repository. Railway bills by usage: check its pricing page.

Next steps

Run with Docker

docker build -t telegram-longpoll-minimal .
docker run --rm --env-file .env telegram-longpoll-minimal

Official documentation

https://core.telegram.org/bots/api#getupdates

All templates