Node-telegram-bot-api: How to run multiple bots with webhook through a proxy

Created on 2 Jun 2017  路  4Comments  路  Source: yagop/node-telegram-bot-api

Question

Hello.
How i can deploy many bots with webhook updates through local proxy?

question

Most helpful comment

The bot checks for its token in the path in each request. Therefore, different bots could setWebHook() different paths that are handled by the proxy. Imagine this:

Bot 1:

bot.setWebHook(`https://custom-url.com/bot${TOKEN_1}`);

Bot 2:

bot.setWebHook(`https://custom-url.com/bot${TOKEN_2}`);

Note the different tokens TOKEN_1 and TOKEN_2. Now you'll have to configure your proxy (listening at url https://custom-url.com) to pass requests in path /bot${TOKEN_1} to bot 1 and /bot${TOKEN_2} to bot 2.

Hope that helps.

ANS

All 4 comments

The bot checks for its token in the path in each request. Therefore, different bots could setWebHook() different paths that are handled by the proxy. Imagine this:

Bot 1:

bot.setWebHook(`https://custom-url.com/bot${TOKEN_1}`);

Bot 2:

bot.setWebHook(`https://custom-url.com/bot${TOKEN_2}`);

Note the different tokens TOKEN_1 and TOKEN_2. Now you'll have to configure your proxy (listening at url https://custom-url.com) to pass requests in path /bot${TOKEN_1} to bot 1 and /bot${TOKEN_2} to bot 2.

Hope that helps.

ANS

This doesn't seem to work. Error that two items are running on the same port when you do this.

Ah sorry. Do you do set webhook twice on the same bot?

Same issue. Any solution?
Is only one Bot instance possible by server? (using same port 8443)

Was this page helpful?
0 / 5 - 0 ratings

Related issues

FerX picture FerX  路  4Comments

saeedhei picture saeedhei  路  4Comments

Dohoon-Kim picture Dohoon-Kim  路  3Comments

jacopocappelli1989 picture jacopocappelli1989  路  4Comments

Rezania815 picture Rezania815  路  3Comments