All Projects → odditive → Heroku Node Telegram Bot

odditive / Heroku Node Telegram Bot

Licence: mit
Starter pack for running telegram bot on the Heroku using Node.js

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Heroku Node Telegram Bot

PDF-Bot
A bot for PDF for doing Many Things....
Stars: ✭ 38 (-70.31%)
Mutual labels:  heroku, telegram, telegram-bot
FileStreamBot
Telegram File to Link Fastest Bot , Its Generate Direct Links Quickly
Stars: ✭ 99 (-22.66%)
Mutual labels:  heroku, telegram, telegram-bot
Telegram Clonebot
Simple Bot to clone Google Drive Files (or Folders) to your Team Drive[or Normal Drive]. P.S This is not a Mirror Bot. Enjoy ✌🏻
Stars: ✭ 114 (-10.94%)
Mutual labels:  telegram-bot, heroku, telegram
TG-FileStreamBot
Stream Telegram files to web
Stars: ✭ 193 (+50.78%)
Mutual labels:  heroku, telegram, telegram-bot
WilliamButcherBot
Telegram Group Manager Bot Written In Python Using Pyrogram.
Stars: ✭ 187 (+46.09%)
Mutual labels:  heroku, telegram, telegram-bot
Userge
Userge, Durable as a Serge
Stars: ✭ 363 (+183.59%)
Mutual labels:  telegram-bot, heroku, telegram
Telegraff
Kotlin DSL для разработки Telegram ботов
Stars: ✭ 122 (-4.69%)
Mutual labels:  telegram-bot, telegram
Integram
Integrate Telegram into your workflow – Trello, Gitlab, Bitbucket and other bots
Stars: ✭ 1,365 (+966.41%)
Mutual labels:  telegram-bot, telegram
Node Telegram Api
A simple API to create and control Telegram bots
Stars: ✭ 117 (-8.59%)
Mutual labels:  telegram-bot, telegram
Zanzara
Asynchronous PHP Telegram Bot Framework built on top of ReactPHP
Stars: ✭ 107 (-16.41%)
Mutual labels:  telegram-bot, telegram
Libtelegram
Fast, efficient, header-only C++ Telegram bot API library using polling or FastCGI
Stars: ✭ 88 (-31.25%)
Mutual labels:  telegram-bot, telegram
Vk To Telegram Bot
Bot for auto-reposting posts from VK to Telegram channel
Stars: ✭ 103 (-19.53%)
Mutual labels:  telegram-bot, telegram
Bot Api Base
Clear and simple Telegram bot API
Stars: ✭ 122 (-4.69%)
Mutual labels:  telegram-bot, telegram
Telegram Bot
Telegram Bot using AWS API Gateway and AWS Lambda
Stars: ✭ 96 (-25%)
Mutual labels:  telegram-bot, telegram
Telebot.nim
Async client for Telegram Bot API in pure Nim [Bot API 5.1]
Stars: ✭ 93 (-27.34%)
Mutual labels:  telegram-bot, telegram
Telegram Bot Github
Allows to you receive GitHub notifications right in the Telegram
Stars: ✭ 103 (-19.53%)
Mutual labels:  telegram-bot, telegram
Tgdr
Telegram directory to discover channels, bots and groups.
Stars: ✭ 91 (-28.91%)
Mutual labels:  telegram-bot, telegram
Hackernewsbot
📰 Telegram bot that posts new hot stories from Hacker News to telegram channel
Stars: ✭ 103 (-19.53%)
Mutual labels:  telegram-bot, telegram
Novagram
An Object-Oriented PHP library for Telegram Bots
Stars: ✭ 112 (-12.5%)
Mutual labels:  telegram-bot, telegram
Reactly Starter Kit
Deployable React + Webpack 2 starter kit
Stars: ✭ 122 (-4.69%)
Mutual labels:  heroku, starter-kit

heroku-node-telegram-bot

Starter pack for running telegram bot on the Heroku using Node.js

Step-by-step

Try bot locally

  1. Create your own bot using Telegram's BotFather and grab your TOKEN.
  2. Clone or download and unpack this repo.
  3. Go to the app's folder using cd ~/heroku-node-telegram-bot
  4. Run npm install (in some cases you will need to run this with sudo, you know, just the permissions).
  5. Rename .env_example file into .env and set TOKEN to the value, you've got from the BotFather.
  6. Run npm start and send smth to your bot.
  7. After it says "hello" to you, we can go to the next step😎

Deploy your bot to the heroku

  1. Create the Heroku account and install the Heroku Toolbelt.
  2. Login to your Heroku account using heroku login.
  3. Go to the app's folder using cd ~/heroku-node-telegram-bot
  4. Run heroku create to prepare the Heroku environment.
  5. 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.
  6. Run git add -A && git commit -m "Ready to run on heroku" && git push heroku master to deploy your bot to the Heroku server.
  7. Send smth to the bot to check out if it works ok.

Going further

Now 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 and on the heroku server it uses the webhook, 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.

To 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.

Possible OS issues

As 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.

npm run switch_to_dev runs export $(cat .env | xargs) && wget --spider https://api.telegram.org/bot$TOKEN/setWebhook?url= --delete-after && node index.js which is actually an API call which will reset webhook (with the TOKEN from your environment variable) and npm start.

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.

If your bot is not responding locally, in most cases, you will need to reset the environment variables by restarting your application.

Links and references

Actually, this repo is created because I've faced problems when I was trying to run the bot using mvalipour's article and this PR to his repo. Still, these links will be very useful for the beginners.

The solution relies on the node-telegram-bot-api wrapper by the @yagop, so you can find more info there.

Also check out official API docs by Telegram team, it may be helpfull.

Good luck, BotCoder!

P.S. If you see that something is not working, please, open an issue or send me a PR if you've managed to make code better.

Created with great passion for bots. In case of any bot development proposals, contact me here.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].