n8n

How to Automate Telegram OpenAI Customer Support?

Turn your Telegram bot into a smart support agent that remembers users. Incoming messages go to an AI assistant, and the chat history stays linked to each person. This fits teams that get many questions and want fast, consistent replies without losing context.

When a user sends a Telegram message, the flow checks Supabase for that user’s record. If the user is new, it creates an OpenAI thread and stores both the Telegram ID and the thread ID. Then the message is added to the same thread, the assistant runs, and the latest answer is fetched and sent back to Telegram. Memory lives in Supabase and the OpenAI thread, so future chats feel connected. This design reduces repeat questions and keeps conversations smooth.

You will need a Telegram bot token, a Supabase project with the provided table, and an OpenAI assistant ID. Expect faster response times, less manual typing, and the ability to handle more chats with the same team. It works well for FAQs, first line support, and basic onboarding. Set credentials in n8n, paste your assistant ID, and test by messaging your bot. Once you see the user record and thread ID in Supabase, you are ready to scale.

What are the key features?

  • Listens for new Telegram messages and starts the flow automatically
  • Looks up the user in Supabase by Telegram ID to reuse their chat thread
  • Creates a new OpenAI thread and user record if no match is found
  • Merges paths so every message continues with the correct thread ID
  • Sends the user’s text into the OpenAI thread for processing
  • Runs the selected OpenAI assistant to generate the answer
  • Fetches the latest assistant message and returns it to Telegram
  • Stores telegram_id and openai_thread_id to maintain long term memory

What are the benefits?

  • Reduce reply time from minutes to seconds by sending instant AI answers in Telegram
  • Automate up to 80 percent of common questions with context aware responses
  • Keep conversation memory across chats for fewer repeat explanations
  • Handle up to 5x more simultaneous chats with the same support team
  • Connect Telegram, OpenAI and Supabase so data and memory stay in sync

How do you set it up?

  1. Import the template into n8n: Create a new workflow in n8n > Click the three dots menu > Select 'Import from File' > Choose the downloaded JSON file.
  2. You'll need accounts with Telegram, Supabase and OpenAI. See the Tools Required section above for links to create accounts with these services.
  3. Create your Telegram bot using BotFather and copy the bot token. Start a chat with your bot so it can receive messages.
  4. In Supabase, create a new project. Copy the Project URL and API key. Run the provided SQL to create the telegram_users table with telegram_id and openai_thread_id.
  5. In OpenAI, create an API key and an Assistant. Copy the assistant ID so the flow can run the correct assistant.
  6. In the n8n credentials manager, create credentials for Telegram using your bot token, Supabase using the Project URL and API key, and OpenAI using your API key. Name them clearly.
  7. Open each related node in the workflow and select the credentials you just created. In the Run assistant node, paste your Assistant ID into the assistant_id field.
  8. Verify the Find User filter uses the Telegram chat ID expression. Confirm the Create User node writes telegram_id and openai_thread_id to the correct table.
  9. Save and activate the workflow. Send a Telegram message to your bot. Check n8n Executions to confirm a new row is created in Supabase and the reply is delivered.
  10. If replies fail, confirm your OpenAI key and assistant_id, check that Get messages returns the assistant output, and make sure your Telegram bot is started and not restricted.

Tools Required

$24 / mo or $20 / mo billed annually to use n8n in the cloud. However, the local or self-hosted n8n Community Edition is free.

OpenAI

Sign up

Pay-as-you-go: GPT-5 at $1.25 per 1M input tokens and $10 per 1M output tokens

Supabase

Sign up

Free: $0 / mo — unlimited API requests; 500 MB database; 5 GB bandwidth; 1 GB storage; 50,000 MAUs.

Telegram

Sign up

Free: $0, Telegram Bot API usage is free for developers

Credits:
Made by Mark Shcherbakov. Setup video: YouTube video

Similar Templates

Join Futurise to access 1,200+ automation templates

Get instant access to ready-made automation workflows for n8n, Make.com, AI agents, and more. Download, customise, and deploy in minutes.