Quick Overview
This workflow runs a Telegram bot that guides users through a multi-step chat flow, stores session state in Supabase, logs completed astrology reading requests to a Supabase history table, and replies to the user in Telegram.
How it works
- Receives incoming messages and callback queries from Telegram.
- Looks up the sender’s session in a Supabase
sessions table using the Telegram chat ID.
- Evaluates the user’s message against the current session state to choose the next prompt, update stored inputs, and decide whether the interaction is complete.
- Updates the existing Supabase session record or inserts a new one when the chat ID has no prior session.
- When a reading flow is marked complete, inserts a record into the Supabase
astrology_readings table with the captured input details.
- Sends the generated reply back to the user in Telegram using HTML parse mode.
Setup
- Create a Telegram bot with BotFather, add your Telegram credentials in n8n, and configure the workflow’s Telegram trigger to use that bot.
- Add Supabase API credentials in n8n and ensure you have
sessions and astrology_readings tables with fields matching chat_id, state, mode, p1_data, and p2_data.
- Update the Supabase table names/field mappings in the Supabase nodes if your schema differs from the workflow defaults.