PopcornPal is a Telegram bot that randomly picks a movie or a game from my Notion databases and fetches rich details for Telegram. Movies are enriched with TMDB, while games are enriched with IGDB.
For the new webhook-based Supabase setup and implementation plan, see docs/supabase-edge-functions-setup.md.
To run this bot locally, use the Supabase Edge Function webhook flow.
-
Install project dependencies using Bun:
bun install
-
Create the local function env file:
cp .env.example supabase/functions/.env.local
-
Fill in
supabase/functions/.env.local.Required values:
TELEGRAM_BOT_TOKENSUPA_FUNCTION_SECRETNOTION_API_KEYNOTION_MOVIES_DATABASE_IDNOTION_SERIES_DATABASE_IDNOTION_GAMES_DATABASE_IDTMDB_API_KEYIGDB_CLIENT_IDIGDB_CLIENT_SECRETSUPA_URL
Notes:
- Keep
SESSION_STORE_DRIVER=memoryfor the simplest local setup. SUPA_SECRET_KEYis only needed if you switch toSESSION_STORE_DRIVER=supabase.SUPA_FUNCTION_SECRETmust only useA-Z,a-z,0-9,_, and-because Telegram rejects other characters insecret_token.
-
Start the local Supabase runtime:
supabase start
-
Serve the Telegram Edge Function locally:
bun run dev:webhook
The bot webhook will be available at
http://localhost:54321/functions/v1/telegram-bot.If you change
supabase/functions/.env.local, stop and start the serve command again so the function runtime reloads the new values. -
Expose the local webhook with a tunnel:
Example with ngrok:
ngrok http 54321
-
Register the Telegram webhook:
Register the webhook and pass the secret via Telegram's
secret_tokensupport.Replace the placeholders and open this URL:
https://api.telegram.org/bot<TELEGRAM_BOT_TOKEN>/setWebhook?url=https://<YOUR_TUNNEL_URL>/functions/v1/telegram-bot&secret_token=<SUPA_FUNCTION_SECRET>If you previously registered the webhook with an older secret, run the same
setWebhookcall again after restarting the local function runtime. -
Open the bot in Telegram and test it:
- send
/start - press
Знайти кіно - check that the bot returns movie options
- send