{"id":13461891,"url":"https://github.com/telegraf/micro-bot","last_synced_at":"2025-03-24T23:31:58.505Z","repository":{"id":57296386,"uuid":"70660278","full_name":"telegraf/micro-bot","owner":"telegraf","description":":robot: Zero-configuration Telegram bot runner","archived":true,"fork":false,"pushed_at":"2023-10-21T20:58:15.000Z","size":54,"stargazers_count":182,"open_issues_count":10,"forks_count":29,"subscribers_count":9,"default_branch":"master","last_synced_at":"2024-10-29T10:03:07.348Z","etag":null,"topics":["bot","telegram","telegram-api","telegram-bot"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/telegraf.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2016-10-12T03:46:58.000Z","updated_at":"2024-08-23T09:16:13.000Z","dependencies_parsed_at":"2024-01-23T21:43:16.117Z","dependency_job_id":null,"html_url":"https://github.com/telegraf/micro-bot","commit_stats":{"total_commits":75,"total_committers":5,"mean_commits":15.0,"dds":0.07999999999999996,"last_synced_commit":"4fbab198dc0a7a3c8308d6b6cb6502366e9223eb"},"previous_names":[],"tags_count":29,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/telegraf%2Fmicro-bot","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/telegraf%2Fmicro-bot/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/telegraf%2Fmicro-bot/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/telegraf%2Fmicro-bot/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/telegraf","download_url":"https://codeload.github.com/telegraf/micro-bot/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245372193,"owners_count":20604487,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["bot","telegram","telegram-api","telegram-bot"],"created_at":"2024-07-31T12:00:26.607Z","updated_at":"2025-03-24T23:31:58.215Z","avatar_url":"https://github.com/telegraf.png","language":"JavaScript","readme":"# ⚠️ This package is deprecated. Use [telegraf](https://github.com/telegraf/telegraf)'s builtin CLI instead.\n\n[![NPM Version](https://img.shields.io/npm/v/micro-bot.svg?style=flat-square)](https://www.npmjs.com/package/micro-bot)\n[![node](https://img.shields.io/node/v/micro-bot.svg?style=flat-square)](https://www.npmjs.com/package/micro-bot)\n[![Build Status](https://img.shields.io/travis/telegraf/micro-bot.svg?branch=master\u0026style=flat-square)](https://travis-ci.org/telegraf/micro-bot)\n[![js-standard-style](https://img.shields.io/badge/code%20style-standard-brightgreen.svg?style=flat-square)](http://standardjs.com/)\n\n# μ-bot\n\u003e 🤖 Zero-configuration Telegram bot runner\n\n## Documentation\n\n`micro-bot` was built on top of [`Telegraf`](https://github.com/telegraf/telegraf) library.\n\n[Telegraf API documentation](http://telegraf.js.org).\n\n## Installation\n\nInstall from NPM:\n\n```bash\n$ npm install micro-bot\n```\n\n## Scaffolding\n\nIf you have installed latest `yarn` or `npm` you can use [`create-bot`](https://github.com/telegraf/create-bot) scaffolding tool:\n\n```bash\n$ npm init bot smart-bot\n$ cd smart-bot\n```\n\nOr using `yarn`:\n\n```bash\n$ yarn create bot smart-bot\n$ cd smart-bot\n```\n\n## Quick start\n\nThe following example will answer with important information about everything.\n\n```bash\n$ mkdir smart-bot\n$ cd smart-bot\n$ npm init\n$ npm install micro-bot --save\n```\n\nThen write your `index.js`.\n\n```js\nmodule.exports = ({ reply }) =\u003e reply('42')\n```\n\nThen in your `package.json`:\n\n```js\n\"main\": \"index.js\",\n\"scripts\": {\n  \"start\": \"micro-bot\"\n}\n```\n\nTo run the bot, use the `micro-bot` command:\n\n```bash\n$ BOT_TOKEN='TOKEN' npm start\n```\n\nor\n\n```bash\n$ micro-bot -t TOKEN index.js\n```\n\nTo run the bot with webhook support, provide webhook domain name:\n\n```bash\n$ micro-bot -t TOKEN -d yourdomain.tld echo.js\n```\n\nSupported environment variables:\n\n* `process.env.BOT_TOKEN` - Bot token\n* `process.env.BOT_DOMAIN` - Webhook domain\n\n## Deployment to `now`\n\nLet's deploy your `micro-bot` with Realtime global deployments by Zeit.\n\nFirst, install [`now`](https://zeit.co/now)\n```bash\n$ npm install now -g\n$ now login\n```\n\nFinally use `now` to deploy:\n\n```bash\n$ now -e BOT_TOKEN='YOUR BOT TOKEN'\n```\n\nCongratulations, your bot is alive! 🎉\n\n## Deployment to Heroku\n\nOkay, now we will deploy our `micro-bot` to Heroku. Why not?!\n\nFirst, install [`heroku binaries`](https://devcenter.heroku.com/articles/getting-started-with-nodejs#set-up) and login via console.\n\nThen, init new git repo:\n```bash\n$ git init\n$ heroku create\n```\n\nAfterwards, update Heroku config:\n\n```bash\n$ heroku config:set --app YourAppId BOT_TOKEN='YOUR BOT TOKEN'\n$ heroku config:set --app YourAppId BOT_DOMAIN='https://YourAppId.herokuapp.com'\n```\n\nThen add `Procfile` into the root of your project, with one line:\n\n```Procfile\nweb: micro-bot -p $PORT\n```\n\nFinally use git to deploy:\n\n```bash\n$ git add index.js package.json\n$ git commit -m 'initial commit'\n$ git push heroku master\n```\n\n#### Example μ-bots\n\n* [ 🔥 Glitch example](https://glitch.com/edit/#!/dashing-light)\n* [`@uncover_bot`](https://telegram.me/uncover_bot) - [Source code](https://uncover.now.sh/_src)\n* [`@epub2mobi_bot`](https://telegram.me/epub2mobi_bot) - [Source code](https://epub2mobi.now.sh/_src)\n* [`@gorchichkabot`](https://bot.gorchichka.com) - [Source code](https://github.com/agudulin/gorchichkabot)\n* [`@aloudbot`](https://telegram.me/aloudbot) - [Source code](https://github.com/shrynx/aloudbot)\n\n## Advanced Examples\n\n```js\nconst { mount, reply } = require('micro-bot')\nmodule.exports = mount('sticker', reply('👍'))\n```\n\n```js\nconst { readFileSync } = require('fs')\nconst { Composer } = require('micro-bot')\nconst bot = new Composer()\n\nbot.start((ctx) =\u003e ctx.reply('Welcome'))\nbot.help((ctx) =\u003e ctx.reply('Help message'))\nbot.hears('hi', ({ reply }) =\u003e reply('Hello'))\nbot.on('sticker', ({ reply }) =\u003e reply('👍'))\n\n// Export bot handler\nmodule.exports = bot\n\n// Or you can export hash with handlers and options\nmodule.exports = {\n  bot: bot,\n  init: (bot) =\u003e {\n    console.log('Bot initialization hook')\n  },\n  server: (req, res, next) =\u003e {\n    console.log('Http request hook')\n  },\n  options: {\n    telegram: {\n      agent: new HttpsProxyAgent('proxy url')\n    }\n  },\n  tlsOptions: {\n    key:  readFileSync('server-key.pem'),\n    cert: readFileSync('server-cert.pem'),\n    ca: [\n      // This is necessary only if the client uses the self-signed certificate.\n      readFileSync('client-cert.pem')\n    ]\n  }\n}\n```\n\n### Stages \u0026 Scenes\n\n```js\nconst { Composer, Stage, Scene, session } = require('micro-bot')\n\n// Greeter scene\nconst greeter = new Scene('greeter')\ngreeter.enter((ctx) =\u003e ctx.reply('Hi'))\ngreeter.leave((ctx) =\u003e ctx.reply('Buy'))\ngreeter.hears(/hi/gi, (ctx) =\u003e ctx.scene.leave())\ngreeter.on('message', (ctx) =\u003e ctx.reply('Send `hi`'))\n\nconst stage = new Stage()\nstage.register(greeter)\n\nconst bot = new Composer()\nbot.use(session())\nbot.use(stage)\nbot.command('greeter', (ctx) =\u003e ctx.scene.enter('greeter'))\nbot.command('cancel', (ctx) =\u003e ctx.scene.leave())\nmodule.exports = bot\n\n```\n\n## Credits\n\n`micro-bot` is highly inspired by [`Micro`](https://github.com/zeit/micro/)\n","funding_links":[],"categories":["JavaScript","Libraries"],"sub_categories":["Node.js"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftelegraf%2Fmicro-bot","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftelegraf%2Fmicro-bot","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftelegraf%2Fmicro-bot/lists"}