An open API service indexing awesome lists of open source software.

https://github.com/techprober/telegram-webhook-forwarder-bot


https://github.com/techprober/telegram-webhook-forwarder-bot

serverless telegram-bot

Last synced: 9 months ago
JSON representation

Awesome Lists containing this project

README

          

💬 Telegram Webhook Forwarder Bot



ChatOps as a Service


License


lastcommit

## Introduction

CopyRight 2022 TechProber. All rights reserved.

Maintainer: [ Kevin Yu (@yqlbu) ](https://github.com/yqlbu)

The `telegram-webhook-forwarder-bot` forwards any incoming webhooks to the target telegram chat.

The bot is written in Python with Web Server Gateway Interface (WSGI) and Flask

## Prerequisites

Install depedencies

```bash
./install
```

Configure Environment with `.env`

```
# .env
API_TOKEN=
CHAT_ID=
WEBHOOK_PATH=
PORT=
```

Notes:

- `API_TOKEN` can be obtained by [BotFather](https://t.me/botfather?start=botostore)
- `CHAT_ID` can be obtained by sharing the chat to the [IDBot](https://t.me/username_to_id_bot?start=botostore)
- `WEBHOOK_PATH` is the api endpoint as part of the webhook url. e.g. `/webhook/hello`
- `PORT` is the port that the server listens to when running the bot locally

## Usage

Activate the virtual environment

```bash
# bash
. ./venv/bin/activate
# fish
. ./venv/bin/activate.fish
```

Spin up the local server for debugging

```bash
python3 server.py
```

## Deploy

This bot can be hosted as a serverless function. e.g hosted on [Vercel](https://vercel.com/)

```bash
# install vercel client (cli)
npm -g install vercel
# login and authenticate
verlcel
# publish a new deployment and automatically promote it to production
vercel --prod
```

## References

- [Github - pyTelegramBotAPI](https://github.com/eternnoir/pyTelegramBotAPI)
- [Vercel Advanced Python Usage - Web Server Gateway Interface](https://vercel.com/docs/runtimes#advanced-usage/advanced-python-usage/web-server-gateway-interface)