A high-performance, real-time notification system that instantly forwards TradingView alerts to Telegram via Supabase Edge Functions and Database Webhooks, replacing high-latency polling methods.
Messages are delivered in under a second right when a new trade is recorded in your database.
- TradingView sends a webhook or alert payload into your Supabase database (
your_trades_tabletable). - Supabase Database Webhook listens for
INSERTevents on theyour_trades_tabletable in real-time. - The webhook triggers a serverless Supabase Edge Function (written in TypeScript/Deno).
- The Edge Function fetches additional strategy metrics if needed, formats the message, and instantly dispatches it to your Telegram chat/channel.
- Go to your Supabase Dashboard.
- Click on Edge Functions in the left sidebar.
- Create a new function named
telegram-notifier. - Paste the TypeScript code into the editor and deploy
In your Supabase Dashboard, go to Project Settings -> Edge Functions -> Secrets and add the following keys:
TELEGRAM_BOT_TOKEN: Your Telegram Bot API Token (obtained via @BotFather).TELEGRAM_CHAT_ID: Your target Telegram Chat or Channel ID.
(Note: SUPABASE_URL and SUPABASE_SERVICE_ROLE_KEY are injected automatically by Supabase).
- Go to Database -> Webhooks in your Supabase dashboard.
- Click Create a new webhook with these settings:
- Name:
send_telegram_trade - Table:
public your_trades_table - Events: Check Insert
- Type of webhook: Select Supabase Edge Functions
- Edge Function: Select
telegram-notifier
- Name:
- Save the webhook.
You can test the real-time notification loop by executing a manual test insert in your SQL Editor:
INSERT INTO your_trades_table (
strategy_id,
ticker,
type_order,
status,
tv_timestamp,
pnl,
equity_after
) VALUES (
'YOUR_TARGET_STRATEGY_UUID_HERE',
'BTCUSDC',
'buy',
'closed',
extract(epoch from now()) * 1000,
150.50,
10150.50
);Check your Telegram channel—the update will arrive instantly!