Disclaimer: This application is designed to work exclusively with Telegram bots. It does not support Telegram channels or other Telegram triggers.
A FastAPI application that connects Telegram Bot messages with n8n workflows.
- Automatic Telegram webhook setup
- n8n workflow integration
- Rich terminal logging
- Local development with ngrok
- Place
ngrok.exe
in project root - Create
.env
file:BOT_TOKEN=<telegram_bot_token> N8N_WEB_HOOK_URL=<n8n_webhook_url> NGROK_URL=<ngrok_url> PORT=8000 NGROK_API_KEY=<ngrok_authtoken>
-
Install UV:
pip install uv
-
Run uv:
uv run
python -m venv .venv
.venv\Scripts\activate
pip install -r requirements.txt
- CMD (Windows):
run.bat
- Linux/macOS:
./start.sh
- Start ngrok:
ngrok http --url=%NGROK_URL% %PORT%
- Run server:
uv run main.py
For a more seamless experience, it is recommended to generate a static ngrok_url
from the ngrok dashboard. Using a static URL eliminates the need to update the NGROK_URL
in the .env
file every time you restart ngrok
.
Steps to set up a static ngrok_url
:
- Log in to your ngrok account.
- Navigate to the (https://dashboard.ngrok.com/domains) section in the dashboard.
- create a custom subdomain (e.g.,
your-app-name.ngrok.io
). - Update the
NGROK_URL
in your.env
file with the reserved domain.
To connect this application with n8n, use the Webhook Trigger node instead of the Telegram Trigger node. Configure the webhook path to /telegram
(or any custom path of your choice). If you choose a custom path, ensure that the same path is updated in the .env
file. Additionally, set the "Respond with" option in the Webhook Trigger node to "First Entry JSON" for proper functionality.