Runnable TypeScript examples for node-telegram-bot-api.
| Example | What it shows |
|---|---|
polling.ts |
Long-polling bot: onText commands, sending files, inline keyboards, callback_query |
webhook/express.ts |
Receiving updates through an Express route |
webhook/https.ts |
Built-in webhook server with a self-signed certificate |
webhook/heroku.ts |
Webhook behind Heroku's SSL termination |
game/game.ts |
HTML5 games via sendGame + answerCallbackQuery |
The examples are written in TypeScript and run directly with
tsx — no build step:
export TELEGRAM_TOKEN="<token from @BotFather>"
npx tsx examples/polling.tsThe webhook and game examples additionally need Express:
npm i express
npx tsx examples/webhook/express.tsIn your own project, import from the package name:
import TelegramBot from 'node-telegram-bot-api';(The examples use that same import; within this repo it resolves to the local
build via the package's exports map.)