{"id":"178b8d52-1bea-43c0-8eef-08200046086c","shortId":"ZQRH8v","kind":"skill","title":"using-telegram-bot","tagline":"Build and run Telegram bots in Node.js using Telegraf with practical command patterns.","description":"# Telegram (Telegraf) Skill — Node.js\n\nShort guide to build Telegram bots with `telegraf` (Node.js).\n\n## Overview\n- Library: https://github.com/telegraf/telegraf\n- Install: `npm install telegraf`\n- Get a bot token from BotFather and store it in `BOT_TOKEN`.\n\n## Minimal polling bot\n\n```javascript\n// bot.js\nconst { Telegraf, Markup } = require('telegraf');\nconst bot = new Telegraf(process.env.BOT_TOKEN);\n\nbot.start(ctx => ctx.reply('Welcome! I can help with commands.'));\n\nbot.command('echo', ctx => {\n  const text = ctx.message.text.split(' ').slice(1).join(' ');\n  ctx.reply(text || 'usage: /echo your message');\n});\n\nbot.on('text', ctx => ctx.reply(`You said: ${ctx.message.text}`));\n\nbot.launch();\n\nprocess.once('SIGINT', () => bot.stop('SIGINT'));\nprocess.once('SIGTERM', () => bot.stop('SIGTERM'));\n```\n\nRun:\n\n```bash\nBOT_TOKEN=123:ABC node bot.js\n```\n\n## Send media and files\n\n```javascript\n// send photo\nawait ctx.replyWithPhoto('https://example.com/image.jpg', { caption: 'Nice pic' });\n\n// send document\nawait ctx.replyWithDocument('https://example.com/file.pdf');\n```\n\n## Inline keyboards and callbacks\n\n```javascript\n// show inline buttons\nawait ctx.reply('Choose:', Markup.inlineKeyboard([\n  Markup.button.callback('OK', 'ok'),\n  Markup.button.callback('Cancel', 'cancel')\n]));\n\nbot.action('ok', ctx => ctx.reply('You pressed OK'));\nbot.action('cancel', ctx => ctx.reply('Cancelled'));\n```\n\n## Webhook (Express) example\n\n```javascript\nconst express = require('express');\nconst { Telegraf } = require('telegraf');\nconst bot = new Telegraf(process.env.BOT_TOKEN);\nconst app = express();\n\napp.use(bot.webhookCallback('/telegraf'));\nbot.telegram.setWebhook(`${process.env.PUBLIC_URL}/telegraf`);\n\napp.listen(process.env.PORT || 3000);\n```\n\nUse webhooks for production deployments (faster, lower resource use).\n\n## Error handling\n\n```javascript\nbot.catch((err, ctx) => {\n  console.error('Bot error', err);\n});\n```\n\n## Tips\n- Use environment variables for tokens and URLs.\n- Respect Telegram rate limits (avoid flooding large groups).\n- For local testing, use polling; for deployment use webhooks behind HTTPS.\n- Add `NODE_ENV=production` and graceful shutdown hooks for reliability.\n\n---\n\nThis doc shows the most common Telegraf patterns: start/command handlers, text handlers, media, inline buttons, webhook setup, and error handling.","tags":["using","telegram","bot","open","skills","besoeasy","agent-skills","ai-agents","claude-code","clawdbot","clawdbot-skill","llm-tools"],"capabilities":["skill","source-besoeasy","skill-using-telegram-bot","topic-agent-skills","topic-ai-agents","topic-claude-code","topic-clawdbot","topic-clawdbot-skill","topic-llm-tools","topic-mcp-server","topic-openai","topic-openclaw","topic-vibe-coding","topic-vibecoding"],"categories":["open-skills"],"synonyms":[],"warnings":[],"endpointUrl":"https://skills.sh/besoeasy/open-skills/using-telegram-bot","protocol":"skill","transport":"skills-sh","auth":{"type":"none","details":{"cli":"npx skills add besoeasy/open-skills","source_repo":"https://github.com/besoeasy/open-skills","install_from":"skills.sh"}},"qualityScore":"0.505","qualityRationale":"deterministic score 0.51 from registry signals: · indexed on github topic:agent-skills · 111 github stars · SKILL.md body (2,345 chars)","verified":false,"liveness":"unknown","lastLivenessCheck":null,"agentReviews":{"count":0,"score_avg":null,"cost_usd_avg":null,"success_rate":null,"latency_p50_ms":null,"narrative_summary":null,"summary_updated_at":null},"enrichmentModel":"deterministic:skill-github:v1","enrichmentVersion":1,"enrichedAt":"2026-05-02T12:55:05.169Z","embedding":null,"createdAt":"2026-04-18T22:10:57.960Z","updatedAt":"2026-05-02T12:55:05.169Z","lastSeenAt":"2026-05-02T12:55:05.169Z","tsv":"'/echo':89 '/file.pdf'');':137 '/image.jpg'',':127 '/telegraf':191,195 '/telegraf/telegraf':35 '1':84 '123':112 '3000':198 'abc':113 'add':245 'app':187 'app.listen':196 'app.use':189 'avoid':230 'await':123,133,146 'bash':109 'behind':243 'bot':4,9,27,42,50,54,63,110,181,215 'bot.action':156,163 'bot.catch':211 'bot.command':77 'bot.js':56,115 'bot.launch':99 'bot.on':92 'bot.start':68 'bot.stop':102,106 'bot.telegram.setwebhook':192 'bot.webhookcallback':190 'botfath':45 'build':5,25 'button':145,269 'callback':141 'cancel':154,155,164,167 'caption':128 'choos':148 'command':16,76 'common':260 'console.error':214 'const':57,62,80,172,176,180,186 'ctx':69,79,94,158,165,213 'ctx.message.text':98 'ctx.message.text.split':82 'ctx.reply':70,86,95,147,159,166 'ctx.replywithdocument':134 'ctx.replywithphoto':124 'deploy':203,240 'doc':256 'document':132 'echo':78 'env':247 'environ':220 'err':212,217 'error':208,216,273 'exampl':170 'example.com':126,136 'example.com/file.pdf'');':135 'example.com/image.jpg'',':125 'express':169,173,175,188 'faster':204 'file':119 'flood':231 'get':40 'github.com':34 'github.com/telegraf/telegraf':33 'grace':250 'group':233 'guid':23 'handl':209,274 'handler':264,266 'help':74 'hook':252 'https':244 'inlin':138,144,268 'instal':36,38 'javascript':55,120,142,171,210 'join':85 'keyboard':139 'larg':232 'librari':32 'limit':229 'local':235 'lower':205 'markup':59 'markup.button.callback':150,153 'markup.inlinekeyboard':149 'media':117,267 'messag':91 'minim':52 'new':64,182 'nice':129 'node':114,246 'node.js':11,21,30 'npm':37 'ok':151,152,157,162 'overview':31 'pattern':17,262 'photo':122 'pic':130 'poll':53,238 'practic':15 'press':161 'process.env.bot':66,184 'process.env.port':197 'process.env.public':193 'process.once':100,104 'product':202,248 'rate':228 'reliabl':254 'requir':60,174,178 'resourc':206 'respect':226 'run':7,108 'said':97 'send':116,121,131 'setup':271 'short':22 'show':143,257 'shutdown':251 'sigint':101,103 'sigterm':105,107 'skill':20 'skill-using-telegram-bot' 'slice':83 'source-besoeasy' 'start/command':263 'store':47 'telegraf':13,19,29,39,58,61,65,177,179,183,261 'telegram':3,8,18,26,227 'test':236 'text':81,87,93,265 'tip':218 'token':43,51,67,111,185,223 'topic-agent-skills' 'topic-ai-agents' 'topic-claude-code' 'topic-clawdbot' 'topic-clawdbot-skill' 'topic-llm-tools' 'topic-mcp-server' 'topic-openai' 'topic-openclaw' 'topic-vibe-coding' 'topic-vibecoding' 'url':194,225 'usag':88 'use':2,12,199,207,219,237,241 'using-telegram-bot':1 'variabl':221 'webhook':168,200,242,270 'welcom':71","prices":[{"id":"1f795cdf-cc48-4f5f-9fbe-66a6c08e6aaa","listingId":"178b8d52-1bea-43c0-8eef-08200046086c","amountUsd":"0","unit":"free","nativeCurrency":null,"nativeAmount":null,"chain":null,"payTo":null,"paymentMethod":"skill-free","isPrimary":true,"details":{"org":"besoeasy","category":"open-skills","install_from":"skills.sh"},"createdAt":"2026-04-18T22:10:57.960Z"}],"sources":[{"listingId":"178b8d52-1bea-43c0-8eef-08200046086c","source":"github","sourceId":"besoeasy/open-skills/using-telegram-bot","sourceUrl":"https://github.com/besoeasy/open-skills/tree/main/skills/using-telegram-bot","isPrimary":false,"firstSeenAt":"2026-04-18T22:10:57.960Z","lastSeenAt":"2026-05-02T12:55:05.169Z"}],"details":{"listingId":"178b8d52-1bea-43c0-8eef-08200046086c","quickStartSnippet":null,"exampleRequest":null,"exampleResponse":null,"schema":null,"openapiUrl":null,"agentsTxtUrl":null,"citations":[],"useCases":[],"bestFor":[],"notFor":[],"kindDetails":{"org":"besoeasy","slug":"using-telegram-bot","github":{"repo":"besoeasy/open-skills","stars":111,"topics":["agent-skills","ai","ai-agents","claude-code","clawdbot","clawdbot-skill","llm-tools","mcp-server","openai","openclaw","vibe-coding","vibecoding"],"license":null,"html_url":"https://github.com/besoeasy/open-skills","pushed_at":"2026-03-31T13:05:30Z","description":"Battle-tested skill library for AI agents. Save 98% of API costs with ready-to-use code for crypto, PDFs, search, web scraping & more. No trial-and-error, no expensive APIs.","skill_md_sha":"bda9bb028b3bb3fb69f4bf03c36a4e225c9f0ca4","skill_md_path":"skills/using-telegram-bot/SKILL.md","default_branch":"main","skill_tree_url":"https://github.com/besoeasy/open-skills/tree/main/skills/using-telegram-bot"},"layout":"multi","source":"github","category":"open-skills","frontmatter":{"name":"using-telegram-bot","description":"Build and run Telegram bots in Node.js using Telegraf with practical command patterns."},"skills_sh_url":"https://skills.sh/besoeasy/open-skills/using-telegram-bot"},"updatedAt":"2026-05-02T12:55:05.169Z"}}