{"product_id":"n8n-telegram-ai-support-agent-with-pgvector-openrouter","title":"n8n Telegram AI Support Agent with pgvector \u0026 OpenRouter","description":"\u003ch3\u003eTurn Your Telegram Bot Into an AI Support Agent Powered by pgvector + OpenRouter\u003c\/h3\u003e\n\u003cp\u003eThis n8n workflow automatically handles incoming customer messages in Telegram, retrieves answers from your Postgres \u003cstrong\u003epgvector\u003c\/strong\u003e knowledge base, and uses an \u003cstrong\u003eOpenRouter\u003c\/strong\u003e chat model to respond—while cleanly escalating to a human support chat when confidence is low or retrieval fails.\u003c\/p\u003e\n\n\u003ch3\u003eWhat this workflow does\u003c\/h3\u003e\n\u003cul\u003e\n  \u003cli\u003e\n\u003cstrong\u003eListens for new Telegram messages\u003c\/strong\u003e sent to your bot.\u003c\/li\u003e\n  \u003cli\u003e\n\u003cstrong\u003eSearches your Postgres pgvector knowledge base\u003c\/strong\u003e using OpenAI embeddings and selects the best match using a minimum similarity threshold.\u003c\/li\u003e\n  \u003cli\u003eIf retrieval is \u003cstrong\u003econfident\u003c\/strong\u003e, calls an \u003cstrong\u003eOpenRouter\u003c\/strong\u003e chat model using \u003cstrong\u003ePostgres chat memory\u003c\/strong\u003e plus a \u003cstrong\u003epgvector search tool\u003c\/strong\u003e to answer strictly from your documents.\u003c\/li\u003e\n  \u003cli\u003e\n\u003cstrong\u003eVerifies response quality\u003c\/strong\u003e: if the agent reply is not empty and not “HANDOFF,” it sends the answer back to the customer in Telegram.\u003c\/li\u003e\n  \u003cli\u003e\n\u003cstrong\u003eHands off to humans when needed\u003c\/strong\u003e: if retrieval or the agent is not confident, the workflow informs the customer and forwards the question to your Telegram support chat with a \u003cstrong\u003e“Respond”\u003c\/strong\u003e button.\u003c\/li\u003e\n  \u003cli\u003e\n\u003cstrong\u003eCaptures human resolution\u003c\/strong\u003e: if the support team replies within \u003cstrong\u003e24 hours\u003c\/strong\u003e, forwards the human answer to the customer and saves the Q\u0026amp;A as a new embedded FAQ entry in pgvector.\u003c\/li\u003e\n  \u003cli\u003e\n\u003cstrong\u003eLogs results\u003c\/strong\u003e: stores answered\/unanswered Q\u0026amp;A in Postgres and records workflow errors in a Postgres error table with an alert to the support chat.\u003c\/li\u003e\n\u003c\/ul\u003e\n\n\u003ch3\u003eUse cases\u003c\/h3\u003e\n\u003cul\u003e\n  \u003cli\u003eCustomer support for SaaS FAQs where answers must come from your knowledge base.\u003c\/li\u003e\n  \u003cli\u003eReducing support load by automating first-response handling in Telegram.\u003c\/li\u003e\n  \u003cli\u003eContinuous improvement: turning resolved human answers into new pgvector entries.\u003c\/li\u003e\n\u003c\/ul\u003e\n\n\u003ch3\u003eTechnical details\u003c\/h3\u003e\n\u003cul\u003e\n  \u003cli\u003e\n\u003cstrong\u003eIntegrations\/Nodes\u003c\/strong\u003e: Telegram, Postgres (with pgvector), OpenRouter (via chat model), plus n8n nodes such as \u003cstrong\u003eif\u003c\/strong\u003e, \u003cstrong\u003eset\u003c\/strong\u003e, \u003cstrong\u003ecode\u003c\/strong\u003e, and \u003cstrong\u003esticky note\u003c\/strong\u003e.\u003c\/li\u003e\n  \u003cli\u003e\n\u003cstrong\u003eCore features\u003c\/strong\u003e: pgvector retrieval with similarity threshold, OpenAI embeddings, Postgres chat memory, confidence-based “HANDOFF,” Q\u0026amp;A logging, and error recording to a Postgres error table.\u003c\/li\u003e\n\u003c\/ul\u003e\n\u003cp\u003e\u003cstrong\u003eSetup:\u003c\/strong\u003e create and connect a Telegram bot, add it to your support group, and configure \u003ccode\u003esupportChatId\u003c\/code\u003e. Ensure Postgres is set up with \u003cstrong\u003epgvector\u003c\/strong\u003e and the required tables\/structures.\u003c\/p\u003e","brand":"N8N Commerce","offers":[{"title":"Default Title","offer_id":46275699835059,"sku":"N8N-21398","price":16.99,"currency_code":"GBP","in_stock":true}],"thumbnail_url":"\/\/cdn.shopify.com\/s\/files\/1\/0749\/6279\/6723\/files\/xRHq-h-ng15HwyhIS3q_Q_MJTJpj1P.png?v=1792833563","url":"https:\/\/buyflowscripts.com\/products\/n8n-telegram-ai-support-agent-with-pgvector-openrouter","provider":"N8N Commerce","version":"1.0","type":"link"}