e-mail Chatbot with both semantic and structured RAG, using Telegram and Pgvector
Configured with Agent, Chat Trigger, Embeddings Ollama, OpenAI Chat Model, and additional nodes. Review the connections and setup before adapting this template.
Node categories in this workflow
- Trigger
- Routing
- Data store
- Subworkflow
- AI & models
- Transform
- Code
- Messaging
Icons describe general node roles, inferred from node types. Inspect the parameters for the configured action.
Drag to pan; use + and − to zoom. Reconstructed from the exported node positions; nothing runs here. Dashed lines represent non-main connections. Full node names and notes appear below.
How it works
The exported workflow contains the following configured nodes. Their connections are shown above; inspect the JSON for the complete logic, expressions, and external actions.
| Node | Category | Type | Operation |
|---|---|---|---|
| Telegram Trigger | Trigger | Telegram Trigger | See node parameters |
| Loop Over Items | Routing | Loop Over Items | See node parameters |
| Came from Telegram? | Routing | If | See node parameters |
| When chat message received | Trigger | Chat Trigger | See node parameters |
| Postgres PGVector Store | Data store | Vector Store Pgvector | See node parameters |
| Call the SQL composer Workflow | Subworkflow | Tool Workflow | See node parameters |
| Embeddings Ollama | AI & models | Embeddings Ollama | See node parameters |
| Beautify chat response | Transform | Edit Fields | See node parameters |
| Split text into chunks | Code | Code | See node parameters |
| Respond on Telegram in batches | Messaging | Telegram | See node parameters |
| Escape Markdown | Code | Code | See node parameters |
| No Operation, do nothing | Routing | No Op | See node parameters |
| Simple Memory | Data store | Memory Buffer Window | See node parameters |
| AI Agent | AI & models | Agent | See node parameters |
| OpenAI Chat Model | AI & models | OpenAI Chat Model | See node parameters |
| Generate session id | Transform | Edit Fields | See node parameters |
Setup
- Download the JSON and import it into an isolated n8n instance. Leave the workflow inactive.
- Connect your own credentials through n8n’s credential store. Replace
REPLACE_WITH_*values with your resource identifiers. - Inspect API destinations, Code nodes, database queries, file paths, and outbound actions.
- Run with synthetic data and harmless destinations. Enable triggers only after checking the actual outputs.
Requirements
An n8n instance with the listed node types and compatible versions. Service-connected workflows may require accounts, credentials, or paid APIs.
Credential types declared in the source
ollamaApiopenAiApipostgrestelegramApi
Workflow notes
Chat around!
Chat around!
You can use this workflow both as a Telegram bot, or by chatting with it in n8n's interface.
🤖
🤖
This AI Agent has the mission to query both structured and vectorized databases containing all your e-mail communications.
Adjust the SQL composer Workflow to point at a copy of my Translate questions about e-mails into SQL queries and run them template.
IMPORTANT
IMPORTANT
For this step to work, you must download my other template Translate questions about e-mails into SQL queries and run them.
Response
Response
This section takes care of formatting the answer and either responding over Telegram, or in n8n's chat.
e-mail Chatbot with both semantic and structured RAG, using Telegram and Pgvector
e-mail Chatbot with both semantic and structured RAG, using Telegram and Pgvector
Purpose and structure
This folder contains the e-mail Chatbot with both semantic and structured RAG, using Telegram and Pgvector workflow. Its executable nodes use agent, chatTrigger, code, embeddingsOllama, if, lmChatOpenAi, memoryBufferWindow, noOp, set, splitInBatches, telegram, telegramTrigger, toolWorkflow, vectorStorePGVector. The table and connection map below are derived from the JSON, not an inferred guarantee of behavior.
Setup
Import inactive. Configure your own credentials and replace REPLACE_WITH_* values. Review external destinations and Code nodes before running.
Entry points
Telegram Trigger, When chat message received
Verification
Sanitized source candidate; not runtime-tested. This overview is generated from node metadata. Read the folder README for the connection map, credential types, and license.
Attribution
https://github.com/Zie619/n8n-workflows/blob/94007c1445d9258a7da116646b79473e7c7c3282/workflows/Telegram/1843_Telegram_Code_Automate_Triggered.json MIT; preserve source notices.