Skip to main content

Chat with your email history using Telegram, Mistral and Pgvector for RAG

Workflow preview

Workflow preview
100%
Chat with your email history using Telegram, Mistral and Pgvector for RAG preview
Open on n8n.io

Important notice

This workflow is provided as-is. Please review and test before using in production.

1. Workflow Overview

Who is this for? Everyone! Did you dream of asking an AI " what hotel did I stay in for holidays last summer? " or " what were my marks last semester like? ". Dream no more, as [vector similarity s...

Best for

  • Personal Productivity automation workflows
  • AI RAG automation workflows
  • advanced n8n builders looking for reusable templates

Tools used

n8n-nodes-base.telegramtrigger, n8n-nodes-base.splitinbatches, n8n-nodes-base.if, @n8n/n8n-nodes-langchain.chattrigger, @n8n/n8n-nodes-langchain.vectorstorepgvector, @n8n/n8n-nodes-langchain.toolworkflow, @n8n/n8n-nodes-langchain.embeddingsollama, n8n-nodes-base.set

Source and attribution

This workflow is cataloged by N8N Workflows and links back to its original n8n.io source page by Alfonso Corretti.

Original n8n.io source

1.1 Workflow description

Title
Chat with your email history using Telegram, Mistral and Pgvector for RAG
Workflow name
Chat with your email history using Telegram, Mistral and Pgvector for RAG

Who is this for?

Everyone! Did you dream of asking an AI "what hotel did I stay in for holidays last summer?" or "what were my marks last semester like?".

Dream no more, as vector similarity searches and this workflow are the foundations to make it possible (as long as the information appears in your e-mails 😅).

100% Local and Open Source!

This workflow is designed to use locally-hosted open source. Ollama as LLM provider, nomic-embed-text as the embeddings model, and pgvector as the vector database engine, on top of Postgres.

Structured AND Vectorized

This workflow combines structured and semantic search on your e-mail.

No need for enterprise setups! Leverage the convenience of n8n and open source to get a bleeding edge solution.

Setup

  1. You will need a PGVector database with embeddings for all your email. Use my other template Gmail to Vector Embeddings with PGVector and Ollama to set it up in a breeze!
  2. Make a copy of my Email Assistant: Convert Natural Language to SQL Queries with Phi4-mini and PostgreSQL, you will need it for structured searches.
  3. Install this template and modify the Call the SQL composer Workflow step, to point at your copy of the SQL workflow.
  4. Adjust the rest of necessary steps: Telegram Trigger, AI Chat model, AI Embeddings...

Activate the workflow and chat around!

1.2 Logical Blocks

This catalog entry is organized from the workflow JSON. The node-level section below shows the executable blocks available for review before importing the template.

2. Block-by-Block Analysis

Block 1 - Telegram Trigger

Type / Role
n8n-nodes-base.telegramTrigger - telegramTrigger
Config choices
Version 1.2

Block 2 - Loop Over Items

Type / Role
n8n-nodes-base.splitInBatches - splitInBatches
Config choices
Version 3

Block 3 - Came from Telegram?

Type / Role
n8n-nodes-base.if - if
Config choices
Version 2.2

Block 4 - When chat message received

Type / Role
@n8n/n8n-nodes-langchain.chatTrigger - chatTrigger
Config choices
Version 1.1

Block 5 - Postgres PGVector Store

Type / Role
@n8n/n8n-nodes-langchain.vectorStorePGVector - vectorStorePGVector
Config choices
Version 1.1

Block 6 - Call the SQL composer Workflow

Type / Role
@n8n/n8n-nodes-langchain.toolWorkflow - toolWorkflow
Config choices
Version 2.1

Block 7 - Embeddings Ollama

Type / Role
@n8n/n8n-nodes-langchain.embeddingsOllama - embeddingsOllama
Config choices
Version 1

Block 8 - Beautify chat response

Type / Role
n8n-nodes-base.set - set
Config choices
Version 3.4

Block 9 - Split text into chunks

Type / Role
n8n-nodes-base.code - code
Config choices
Version 2

Block 10 - Respond on Telegram in batches

Type / Role
n8n-nodes-base.telegram - telegram
Config choices
Version 1.2

Block 11 - Escape Markdown

Type / Role
n8n-nodes-base.code - code
Config choices
Version 2

Block 12 - No Operation, do nothing

Type / Role
n8n-nodes-base.noOp - noOp
Config choices
Version 1

Block 13 - Sticky Note

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 14 - Sticky Note1

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 15 - Sticky Note2

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 16 - Sticky Note3

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 17 - Simple Memory

Type / Role
@n8n/n8n-nodes-langchain.memoryBufferWindow - memoryBufferWindow
Config choices
Version 1.3

Block 18 - AI Agent

Type / Role
@n8n/n8n-nodes-langchain.agent - agent
Config choices
Version 1.8

Block 19 - OpenAI Chat Model

Type / Role
@n8n/n8n-nodes-langchain.lmChatOpenAi - lmChatOpenAi
Config choices
Version 1.2

Block 20 - Generate session id

Type / Role
n8n-nodes-base.set - set
Config choices
Version 3.4

3. Summary Table

Workflow Chat with your email history using Telegram, Mistral and Pgvector for RAG
Complexity advanced
Nodes 20
Categories Personal Productivity, AI RAG
Author Alfonso Corretti
Published 27 Apr 2025

4. Reproducing the Workflow from Scratch

  1. 1. Download the workflow JSON

    Use the JSON export at /data/workflows/3763/3763.json as the source template for this automation.

  2. 2. Import the template into n8n

    Open n8n, import the downloaded JSON, and review each node before activating the workflow.

  3. 3. Configure credentials and variables

    Replace placeholder credentials, API keys, webhook URLs, account IDs, and environment-specific values with your own settings.

  4. 4. Test with sample data

    Run the workflow manually or in a staging workspace, inspect node output, and confirm downstream systems receive the expected data.

  5. 5. Activate and monitor

    Enable the workflow only after testing, then monitor executions, errors, and rate limits during the first production runs.

5. General Notes & Resources

Review imported nodes carefully before activation. This catalog entry is intended to help you inspect the workflow structure, understand required services, and find related templates faster.

Node names, credentials, schedules, webhook paths, and external service limits may need adjustment for your workspace.

Frequently asked questions

What does Chat with your email history using Telegram, Mistral and Pgvector for RAG do?

Who is this for? Everyone! Did you dream of asking an AI " what hotel did I stay in for holidays last summer? " or " what were my marks last semester like? ". Dream no more, as [vector similarity s...

What do I need before importing this workflow?

Review the workflow JSON, configure any required credentials in n8n, and test the automation in a safe workspace before using it in production.

Can I customize this workflow?

Yes. Use the block-by-block analysis and the downloadable JSON to inspect each node, then adjust credentials, prompts, schedules, filters, or destinations for your Personal Productivity, AI RAG use case.