💬 Telegram Webhook Forwarder Bot

ChatOps as a Service

License lastcommit

Introduction

CopyRight 2022 TechProber. All rights reserved.

Maintainer: Kevin Yu (@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

./install

Configure Environment with .env

# .env
API_TOKEN=
CHAT_ID=
WEBHOOK_PATH=
PORT=

Notes:

  • API_TOKEN can be obtained by BotFather
  • CHAT_ID can be obtained by sharing the chat to the IDBot
  • 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
. ./venv/bin/activate
# fish
. ./venv/bin/activate.fish

Spin up the local server for debugging

python3 server.py

Deploy

This bot can be hosted as a serverless function. e.g hosted on Vercel

# 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