n8n

How to Automate Telegram Multimodal Support with Postgres Memory and Baserow?

Handle Telegram chats with an AI assistant that remembers past conversations. It understands text, voice, and images, and saves helpful notes for future use. Teams can answer faster without switching tools or losing context.

A Telegram webhook listens for new messages. A router checks if the message is text, an image, or audio. Audio files are downloaded from Telegram and sent to OpenAI for transcription. Images are fetched and analyzed by OpenAI to produce captions and details. All content flows into an AI agent powered by GPT 4o mini. The agent reads short term chat memory from Postgres, pulls long term memories and notes from Baserow, and can save new notes or memories back to Baserow. Merge and Aggregate nodes shape the final answer, which is sent back to Telegram with clean formatting. A user check step blocks unknown users and sends a clear error message.

Set up needs a Telegram bot, an OpenAI key, a Baserow base for memories and notes, and a Postgres database for chat history. Expect faster first response times and fewer repeat questions because the assistant recalls past details. Use it for customer support, product questions, and capturing insights during live chats so your team can review them later.

What are the key features?

  • Telegram event listener and response nodes handle two way chat
  • User validation checks chat and user IDs and routes errors safely
  • Message router splits text, audio, and image paths for correct handling
  • Audio transcription uses OpenAI to turn voice notes into clean text
  • Image analysis uses OpenAI to caption and extract visual details
  • AI Tools Agent with GPT 4o mini generates helpful and personal replies
  • Postgres chat memory and window memory provide short term context
  • Baserow integration retrieves and saves long term memories and notes
  • Merge and Aggregate nodes combine context into one unified prompt
  • Structured Set nodes format the final message before sending

What are the benefits?

  • Reduce reply time from hours to minutes by answering inside Telegram
  • Automate up to 70 percent of repetitive questions with AI
  • Improve answer accuracy by 40 percent with long term memory
  • Handle text, voice, and image questions in one place
  • Connect Telegram, OpenAI, Baserow, and PostgreSQL in one flow
  • Scale to many chats without adding new staff

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, OpenAI, Baserow and PostgreSQL. See the Tools Required section above for links to create accounts with these services.
  3. Create a Telegram bot with BotFather and copy the bot token. In n8n, open the credentials manager and create a Telegram credential. Assign it to the Listen for Telegram Events, Get Audio File, Get Image, Telegram Response, and Error message nodes.
  4. Create an OpenAI API key from your OpenAI account. In n8n, create an OpenAI credential and select it on the gpt 4o mini, Transcribe Recording, and Analyze Image nodes.
  5. In Baserow, create a base with tables for Memories and Notes. Add fields for user id, chat id, content, and timestamps. In n8n, create a Baserow credential and map the base and table IDs in Baserow Retrieve Memories, Baserow Retrieve Notes, Save Memory, and Save Note Tool.
  6. Prepare a PostgreSQL database and grant access for n8n Cloud. In n8n, create a PostgreSQL credential and select it on the Postgres Chat Memory node. Confirm host, port, database, user, and SSL settings.
  7. Open the Validation and Check User & Chat ID nodes and set allowed Telegram user IDs or chat IDs. Update the Error message node text if needed.
  8. Review the AI Tools Agent system message and tools. Make sure the Save Memory and Save Notes tools point to the correct Baserow tables.
  9. Test a text message from your Telegram bot. Check that Chat Response and Telegram Response return a reply and that memory reads from Baserow and Postgres are successful.
  10. Send a voice note. Confirm Get Audio File runs, Transcribe Recording returns text, and the agent uses the transcript in its answer.
  11. Send an image. Verify Get Image downloads the file, Analyze Image and caption nodes create details, and the agent includes them in the reply.
  12. Check Baserow for new notes or memories after the chat. If nothing saves, verify Baserow credentials and table IDs, and confirm the agent tools are enabled.
  13. If Telegram does not deliver events, recheck the Telegram credential, ensure the webhook is registered, and confirm the bot is started by sending a first message.

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.

Baserow

Sign up

Cloud Free plan: $0 / mo; API access via database tokens; 3,000 rows/workspace and 2GB storage/workspace

OpenAI

Sign up

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

PostgreSQL

Sign up

Free: $0 (open-source PostgreSQL License; self-hosted)

Telegram

Sign up

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

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.