Download integrations/telegram-relay/README.md from EnergyVenom/patchwise-agent-studio: direct link, hf CLI and curl.
- Browser
- Download file 2.83 kB
-
https://huggingface.co/spaces/EnergyVenom/patchwise-agent-studio/resolve/main/integrations/telegram-relay/README.md
- Command line
-
hf download hf://spaces/EnergyVenom/patchwise-agent-studio/integrations/telegram-relay/README.md
-
curl -L -o README.md https://huggingface.co/spaces/EnergyVenom/patchwise-agent-studio/resolve/main/integrations/telegram-relay/README.md
Telegram relay (only if your host blocks Telegram)
Some hosts, Hugging Face Spaces among them, block connections to api.telegram.org. You can tell from the Space log: Patchwise prints notify: telegram delivery failed with a connection error, and the startup summary shows Telegram configured but nothing arrives.
The fix is a small free Cloudflare Worker that forwards Patchwise's Telegram calls.
Set it up (about 5 minutes)
- Sign in at https://dash.cloudflare.com (a free account is enough), then go to Workers & Pages → Create → Create Worker.
- Name it, for example
patchwise-telegram, and select Deploy. - Select Edit code, replace everything with the contents of
worker.js, and select Deploy. - Go to Settings → Variables and Secrets → Add. Name it
BOT_ID, with the number before the colon in your bot token (for9172594614:AA…it is9172594614). Save. The relay refuses calls for any other bot. - Copy the Worker's address, for example
https://patchwise-telegram.<you>.workers.dev. - In the Patchwise Space settings, add the variable
FPT_TELEGRAM_API_BASEwith that address, then restart the Space.
What the relay does and doesn't do
- It forwards only the Bot API methods Patchwise uses (
getMe,getUpdates,sendMessage,editMessageText,editMessageReplyMarkup,answerCallbackQuery,deleteWebhook), and only for your bot. - It stores nothing and logs nothing. It is about 30 lines; read it before you deploy it.
- The bot token still travels in the request path, as Telegram requires. The relay runs in your own Cloudflare account, so the only party that sees it is your Worker, which the code shows does nothing with it.
On Hugging Face Spaces: use the Supabase relay
Hugging Face Spaces block api.telegram.org, and they also cut connections to *.workers.dev (the first request may get through, then every TLS handshake is dropped). supabase.co is reachable from Spaces, so for a Space use the Edge Function in supabase/index.ts, which has the same rules as the Worker:
- In your Supabase project, go to Edge Functions → Deploy a new function → Via Editor. Name it
telegram-relay, pastesupabase/index.ts, and select Deploy. - In the function's details, turn off "Enforce JWT verification". The requests carry the bot token in their path, as Telegram requires, not a Supabase login.
- Go to Edge Functions → Secrets and add
BOT_IDwith the number before the colon in your bot token. - In the Space, set
FPT_TELEGRAM_API_BASE=https://<project-ref>.supabase.co/functions/v1/telegram-relayand restart it.
The Space log then shows getUpdates … 200 OK through …supabase.co/functions/v1/telegram-relay/bot(hidden)/….