{"id":13793858,"url":"https://github.com/odditive/heroku-node-telegram-bot","last_synced_at":"2025-05-12T20:31:15.071Z","repository":{"id":46316167,"uuid":"56172038","full_name":"odditive/heroku-node-telegram-bot","owner":"odditive","description":"Starter pack for running telegram bot on the Heroku using Node.js","archived":false,"fork":false,"pushed_at":"2021-10-31T05:07:23.000Z","size":27,"stargazers_count":159,"open_issues_count":4,"forks_count":93,"subscribers_count":8,"default_branch":"master","last_synced_at":"2024-11-18T08:55:42.816Z","etag":null,"topics":["heroku","starter-kit","telegram","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/odditive.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}},"created_at":"2016-04-13T17:23:21.000Z","updated_at":"2024-08-31T19:43:12.000Z","dependencies_parsed_at":"2022-08-20T11:30:12.680Z","dependency_job_id":null,"html_url":"https://github.com/odditive/heroku-node-telegram-bot","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/odditive%2Fheroku-node-telegram-bot","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/odditive%2Fheroku-node-telegram-bot/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/odditive%2Fheroku-node-telegram-bot/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/odditive%2Fheroku-node-telegram-bot/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/odditive","download_url":"https://codeload.github.com/odditive/heroku-node-telegram-bot/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253816731,"owners_count":21968874,"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":["heroku","starter-kit","telegram","telegram-bot"],"created_at":"2024-08-03T23:00:32.355Z","updated_at":"2025-05-12T20:31:14.686Z","avatar_url":"https://github.com/odditive.png","language":"JavaScript","funding_links":[],"categories":["JavaScript"],"sub_categories":[],"readme":"# heroku-node-telegram-bot\nStarter pack for running telegram bot on the Heroku using Node.js\n\n# Step-by-step\n\n### Try bot locally\n\n1. Create your own bot using Telegram's [BotFather](https://core.telegram.org/bots#3-how-do-i-create-a-bot) and grab your TOKEN.\n2. Clone or download and unpack this repo.\n3. Go to the app's folder using `cd ~/heroku-node-telegram-bot`\n4. Run `npm install` (in some cases you will need to run this with sudo, you know, just the permissions).\n5. Rename .env_example file into .env and set TOKEN to the value, you've got from the BotFather.\n6. Run `npm start` and send smth to your bot.\n7. After it says \"hello\" to you, we can go to the next step😎\n\n### Deploy your bot to the heroku\n\n1. Create the [Heroku account](https://heroku.com) and install the [Heroku Toolbelt](https://toolbelt.heroku.com/).\n2. Login to your Heroku account using `heroku login`.\n3. Go to the app's folder using `cd ~/heroku-node-telegram-bot`\n4. Run `heroku create` to prepare the Heroku environment.\n5. Run `heroku config:set TOKEN=SET HERE THE TOKEN YOU'VE GOT FROM THE BOTFATHER` and `heroku config:set HEROKU_URL=$(heroku info -s | grep web_url | cut -d= -f2)` to configure environment variables on the server.\n6. Run `git add -A \u0026\u0026 git commit -m \"Ready to run on heroku\" \u0026\u0026 git push heroku master` to deploy your bot to the Heroku server.\n7. Send smth to the bot to check out if it works ok.\n\n### Going further\n\nNow you may wish to add other functionality to your bot and here you can face some problems. The reason is that in development mode your bot works using [polling](https://en.wikipedia.org/wiki/Push_technology#Long_polling) and on the heroku server it uses the [webhook](https://core.telegram.org/bots/api#setwebhook), because heroku will shut down the web-server after a period of inactivity that will result in your polling loop to shut down too. Once webhook was enabled, telegram will return an error `{\"ok\":false,\"error_code\":409,\"description\":\"Error: Conflict: another webhook is active\"}` when you will try to use polling again, and it's actually ok.\n\nTo go back to development mode, you will need to run `npm run switch_to_dev`. This script will disable current webhook and start your local server. Don't be afraid - when you will finish with the changes you may simply push your bot to heroku using `git push heroku master`. Then you should restart your app using `heroku restart`. It will set the webhook again.\n\n### Possible OS issues\n\nAs i work on MacOS and sometimes on Ubuntu, you may face some problems with my npm scripts, so let's figure out how they work.\n\n`npm run switch_to_dev` runs `export $(cat .env | xargs) \u0026\u0026 wget --spider https://api.telegram.org/bot$TOKEN/setWebhook?url= --delete-after \u0026\u0026 node index.js` which is actually an API call which will reset webhook (with the TOKEN from your environment variable) and `npm start`. \n\n**If wget don't work (or is not installed) on your OS**, you can simply open the `https://api.telegram.org/botYOUR_TOKEN/setWebhook?url=` in your browser, but don't forget to replace YOUR_TOKEN with the token, you've got from the BotFather.\n\nIf your bot is not responding locally, in most cases, you will need to reset the environment variables by restarting your application.\n\n### Links and references\n\nActually, this repo is created because I've faced problems when I was trying to run the bot using [mvalipour's article](http://mvalipour.github.io/node.js/2015/12/06/telegram-bot-webhook-existing-express/) and [this PR](https://github.com/mvalipour/telegram-bot-webhook/pull/3) to his repo. Still, these links will be very useful for the beginners. \n\nThe solution relies on the [node-telegram-bot-api wrapper](https://github.com/yagop/node-telegram-bot-api) by the @yagop, so you can find more info there.\n\nAlso check out [official API docs](https://core.telegram.org/bots/api) by Telegram team, it may be helpfull.\n\nGood luck, BotCoder!\n\nP.S. If you see that something is not working, please, open an [issue](https://github.com/volodymyrlut/heroku-node-telegram-bot/issues) or send me a PR if you've managed to make code better.\n\nCreated with great passion for bots.\nIn case of any bot development proposals, contact me [here](http://lut.rocks).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fodditive%2Fheroku-node-telegram-bot","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fodditive%2Fheroku-node-telegram-bot","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fodditive%2Fheroku-node-telegram-bot/lists"}