Telegram Web Bridge is a bidirectional, web-based, proxy-like application which can act as a middleman for Telegram Bot API requests (from your actual application to Telegram) and Webhooks (from Telegram to your actual application).
Built on Slim framework, light-weight and works smoothly.
This bridge can be useful in situations in which accessing Telegram Bot API is not possible (like being hosted in a country restricting/blocking access to Telegram).
Here are the problems come in:
Here this bridge comes in. You can host it in outside of the blocking region, use it to call APIs and receive webhooks.
Yes, there are plenty of other solutions too. However, not everyone can implement those solutions without technical knowledge.
This is a deployment-ready application built to be hosted even on a shared-hosting (since they are pretty cheap) without hassles. Simply download, extract on your shared web hosting, change few settings and done!
The bridge application requires following conditions:
json
extension enabled.You can either use deployment-ready archive or clone source code and build for yourself.
Visit following link and download the latest version:
Download Builds
Unzip the content of the build into a publicly accessible directory on your shared hosting. URL to that directory will be your appUrl
in settings.
⛓ Jump to next section to continue installation.
Clone this repository on your server or local computer:
$ git clone https://github.com/AmirrezaNasiri/telegram-web-bridge
Use Composer to install dependencies:
$ composer install
Basic tests for API calls are available but for webhooks, no tests has been written yet.
Create a Telegram bot for testing purpose and start chatting with it. Open tests/settings.php
and configurate like this:
Enter the API token created for test bot:
'botApiToken' => '123456789:aBcdEfghIjklm_nOpqRsTuvWXyZaBcDEFjhi',
Specify your chat id (can be extracted from @chatid_echo_bot):
'chatId' => '123456789,
Then run tests:
$ composer test
All configurable settings are located and described in:
src/settings.php
Basically, you only need to change appUrl
, crtPath
and webhookEndpoints
settings.
Now that everything is ready, you just need to change the request URLs from https://api.telegram.org
to what you've set in appUrl
.
For example, following request
GET https://api.telegram.org/bot123456:ABC-DEF1234ghIkl-zyx57W2v1u123ew11/getMe
Must be changed to:
GET https://example.com/path-to/telegram-web-hook/bot123456:ABC-DEF1234ghIkl-zyx57W2v1u123ew11/getMe
To receive webhook callbacks, you need to fire setWebhook
once again:
POST https://example.com/path-to/telegram-web-hook/bot123456:ABC-DEF1234ghIkl-zyx57W2v1u123ew11/setWebhook
The bridge will inject its own url
and certificate
parameters according to settings you've just set. So you should expect result of getWebhookInfo
to be different than what you've sent in setWebhook
request.
On every callback from Telegram, bridge will catch and forward it to the defined URL in the settings file.
No problem. You may be able to easily change target of requests from Telegram's URL to your bridge. Here are tips for several packages:
This project welcomes community contributions.
hi``@``amirreza.in
.Code is licensed under the MIT License.
PyBotNet framework, high level remote control
This simple Python script allows you to download songs from Spotify by your Telegram bot
This is a Fake-Copy of a persian telegram ChatBot called 'برنامه ناشناس' .
Easy and optimized way to apply Filtering, Sorting, and Pagination using text-based data.
خبرنامهای برایِ مهندسانِ نرمافزار
Free Shadowsocks Proxy by YasserDivar
Guide App for Tehran Metro.
A free, open-source, integrated and extensible library which connects your web applications to online payment gateways. Gateways can be added or developed by you.