Someone requests to join my private Telegram channel. A bot sends them a PDF in a private message, then approves the request. The part I like about this setup: I don't have a separate server running for the bot. It uses a Supabase Edge Function on the Free plan.

The code is open source: telegram-file-bot on GitHub. Here's how the webhook, file delivery, and approval fit together, and what the free setup does not solve.

Why an Edge Function?

A traditional polling bot repeatedly asks Telegram for updates. This bot uses a webhook: Telegram sends an HTTPS request when a relevant update arrives. Supabase runs the function to handle that request, so I don't need to maintain a separate bot process or rent a VPS.

The flow looks like this:

Private channel join request → Telegram sends chat_join_request to the webhook → Supabase Edge Function checks the webhook secret → Bot sends the file in a private message → Bot approves the join request 

The function doesn't need a database for this workflow. It reads its configuration from environment variables. The setup guide uses a public Supabase Storage URL for the file, so anyone with that URL can access it. That is fine for a public giveaway, but not for confidential documents.

The order matters

Telegram provides a user_chat_id for a join request. Its Bot API documentation says a bot can use that ID to message the requester for five minutes, assuming the request hasn't already been processed and no other administrator has contacted them.

That's why the handler sends the document before approving the request:

try { await tg("sendDocument", { chat_id: req.user_chat_id, document: config.fileUrl, caption: config.caption, }); } catch (e) { console.error("send failed:", e instanceof Error ? e.message : "unknown"); } await tg("approveChatJoinRequest", { chat_id: req.chat.id, user_id: req.from.id, }); 

There's a deliberate trade-off here: if sending the file fails, the bot logs the error and still tries to approve the person. A broken file link won't block access to the channel, but it also means delivery is not guaranteed. Check the function logs if someone joins without receiving the file.

How the webhook is protected

Telegram doesn't send a Supabase user JWT with its webhook. The function is deployed with Supabase's JWT verification disabled, but that doesn't mean the endpoint should accept any request.

When registering the webhook, we set a Telegram secret_token. Telegram sends it in the X-Telegram-Bot-Api-Secret-Token header, and the function compares it with the secret stored in its environment. A missing or incorrect value gets a 401 response. The handler can also check the configured channel ID before processing a join request.

Keep the bot token and webhook secret out of the repository and out of screenshots. The setup guide explains where to enter them. For the protocol, see Telegram's setWebhook documentation and Supabase's function authentication guide.

What it takes to set up

The repository includes the full guide. The short version:

  1. Create a bot with BotFather and add it as an administrator to a private channel, with permission to invite users.
  2. Create an invite link with Request Admin Approval enabled. This is the event the bot handles.
  3. Upload the file to a place Telegram can fetch it. The guide uses a public Supabase Storage bucket; the repository specifies a file under 20 MB.
  4. Deploy the file-bot Edge Function and configure the bot token, webhook secret, channel ID, file URL, and caption as environment variables.
  5. Register the function URL with Telegram using setWebhook, the same secret token, and allowed_updates set to chat_join_request.
  6. Test with a second Telegram account: request to join, check the private message, and verify the approval.

If it doesn't work, start with Telegram's getWebhookInfo and the function logs. A 401 can mean the webhook secret doesn't match or Supabase JWT verification is still enabled. If the person is approved but no file arrives, check the file URL and the logs.

Free, with limits

As of December 3, 2026, Supabase's pricing page lists 500,000 Edge Function invocations on the Free plan. The file in the setup guide uses Storage, which has its own limits. Check current pricing and usage before relying on those numbers; requests, retries, and other functions in the project can also consume quota.

Supabase also says free projects can be paused after a week of inactivity. If that happens, the bot won't answer until the project is restored. I wouldn't present this as an always-on, guaranteed delivery service.

The bot has a narrow scope: one file, one channel, no member database and no analytics. The function returns HTTP 200 after logging a processing error, so a failed operation isn't automatically recovered by a Telegram webhook retry. If guaranteed delivery or audit history matters, this needs additional storage, monitoring and retry handling.

For a small channel that simply wants to send a guide and approve a request, though, one function is enough to make the workflow possible without a server I have to maintain.