AutomationFlowsAI & RAG › Customer Support & Lead Collection Chatbot with Rag, Gpt-4o, Sheets & Telegram

Customer Support & Lead Collection Chatbot with Rag, Gpt-4o, Sheets & Telegram

ByKarol Otręba @smart-camp-ai on n8n.io

Who’s it for

Chat trigger trigger★★★★☆ complexityAI-powered14 nodesChat TriggerAgentMemory Buffer WindowTool Vector StorePinecone Vector StoreOpenAI EmbeddingsTelegram ToolGoogle Sheets Tool
AI & RAG Trigger: Chat trigger Nodes: 14 Complexity: ★★★★☆ AI nodes: yes Added:

This workflow corresponds to n8n.io template #9234 — we link there as the canonical source.

This workflow follows the Agent → Chat Trigger recipe pattern — see all workflows that pair these two integrations.

The workflow JSON

Copy or download the full n8n JSON below. Paste it into a new n8n workflow, add your credentials, activate. Full import guide →

Download .json
{
  "id": "gH7TgPzRzkONOivn",
  "meta": {
    "templateCredsSetupCompleted": true
  },
  "name": "Customer Support & Lead Collection Chatbot with RAG, GPT-4o & Telegram",
  "tags": [
    {
      "id": "AOZlNztgqiOQKd6j",
      "name": "n8n Creators",
      "createdAt": "2025-09-28T11:02:15.227Z",
      "updatedAt": "2025-09-28T11:02:15.227Z"
    }
  ],
  "nodes": [
    {
      "id": "0cd4236d-fa91-405f-bbd9-a816098202f5",
      "name": "When chat message received",
      "type": "@n8n/n8n-nodes-langchain.chatTrigger",
      "position": [
        0,
        0
      ],
      "parameters": {
        "options": {}
      },
      "typeVersion": 1.3
    },
    {
      "id": "da8b3e29-20c2-4f16-a01e-b7ae45bb0efa",
      "name": "AI Agent",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        384,
        0
      ],
      "parameters": {
        "options": {
          "systemMessage": "=## Role:\nYou are a friendly assistant for a company named **[INSERT_YOUR_COMPANY_NAME_HERE]**.\n\n## Task:\nYou answer questions about the business.\n\n## Details:\nYou have access to various tools, which you use correctly.\n\n## Tools:\n- **Company Q&A**  \n  Use this tool to answer questions with knowledge about the company.\n\n- **Google Sheets Agentic Tool**  \n  Use this tool to store contact information such as name, email, interested in and phone number.\n\n- **Telegram Agentic Tool**\n  Use this tool to send a notification with the user's contact information and a summary of the conversation.\n\nAfter a customer asks about opening hours, products, location, or business information, ask them for their name, email, specific interests and phone number."
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "33f3d156-d41d-44e2-af46-d29cb9fe7832",
      "name": "Conversation Memory",
      "type": "@n8n/n8n-nodes-langchain.memoryBufferWindow",
      "position": [
        368,
        224
      ],
      "parameters": {
        "contextWindowLength": 12
      },
      "typeVersion": 1.3
    },
    {
      "id": "d205da7f-7acc-4709-9878-331a70218ce7",
      "name": "Company Q&A",
      "type": "@n8n/n8n-nodes-langchain.toolVectorStore",
      "position": [
        432,
        400
      ],
      "parameters": {
        "description": "Gives answers related to the company."
      },
      "typeVersion": 1.1
    },
    {
      "id": "ab524ffa-cce1-4dee-938e-fbdee31b353c",
      "name": "Pinecone Vector Store (Company KB)",
      "type": "@n8n/n8n-nodes-langchain.vectorStorePinecone",
      "position": [
        384,
        560
      ],
      "parameters": {
        "options": {
          "pineconeNamespace": "Q&A"
        },
        "pineconeIndex": {
          "__rl": true,
          "mode": "list",
          "value": "company",
          "cachedResultName": "company"
        }
      },
      "credentials": {
        "pineconeApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.3
    },
    {
      "id": "28bd6bd0-bedc-47a0-b345-a18f7d2e7831",
      "name": "Generate Embeddings (OpenAI)",
      "type": "@n8n/n8n-nodes-langchain.embeddingsOpenAi",
      "position": [
        464,
        704
      ],
      "parameters": {
        "options": {}
      },
      "credentials": {
        "openAiApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "98dcb3ff-693a-47d3-9031-502dfe49becf",
      "name": "Trigger \u2013 How to Publish",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -96,
        -144
      ],
      "parameters": {
        "width": 256,
        "height": 304,
        "content": "## Trigger\n\nYou can switch to Publicly Available to be able to share this chatbot interface with a link. \n"
      },
      "typeVersion": 1
    },
    {
      "id": "55791e26-65d8-4af8-ad8b-d321044583de",
      "name": "AI Agent \u2013 Flow",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        176,
        -240
      ],
      "parameters": {
        "width": 736,
        "height": 608,
        "content": "## AI Agent\n\nPowered with OpenAI API (GPT-4o) -- you can replace it with your favourite LLM.\n\nThe agent, after providing information requested by the user, asks for contact information and stores it in Google Sheets. \n\nThen sends a notification to Telegram with the contact information and a summary of the conversation.\n\n"
      },
      "typeVersion": 1
    },
    {
      "id": "d71bbe39-776a-465d-a463-84d6fcaa6f70",
      "name": "RAG Database \u2013 Setup",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        256,
        384
      ],
      "parameters": {
        "width": 656,
        "height": 592,
        "content": "\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n## RAG Database\n\nConnect a Pinecone RAG database with knowledge about your company. An OpenAI text-embedding-3-small model handles data retrieval.\n"
      },
      "typeVersion": 1
    },
    {
      "id": "f9e798e4-771f-47f6-8fc6-87379e5c388c",
      "name": "Send Lead to Telegram",
      "type": "n8n-nodes-base.telegramTool",
      "position": [
        624,
        224
      ],
      "parameters": {
        "text": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Text', ``, 'string') }}",
        "chatId": "[INSERT_YOUR_CHAT_ID]",
        "additionalFields": {
          "appendAttribution": false
        }
      },
      "credentials": {
        "telegramApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "f045418b-84c6-4476-8a06-0538fe7eb191",
      "name": "Save Lead to Google Sheets",
      "type": "n8n-nodes-base.googleSheetsTool",
      "position": [
        768,
        224
      ],
      "parameters": {
        "columns": {
          "value": {
            "Name": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Name', ``, 'string') }}",
            "Email": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Email', ``, 'string') }}",
            "Phone": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Phone', ``, 'string') }}",
            "Interested in": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Interested_in', ``, 'string') }}"
          },
          "schema": [
            {
              "id": "Name",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Name",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Phone",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Phone",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Email",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Email",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Interested in",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Interested in",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            }
          ],
          "mappingMode": "defineBelow",
          "matchingColumns": [],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {},
        "operation": "append",
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": "gid=0",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1ccKn1a35BDW3Vqe6cCjoiWlDTl5XIY48PUFYUREVZeM/edit#gid=0",
          "cachedResultName": "Sheet1"
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": "1ccKn1a35BDW3Vqe6cCjoiWlDTl5XIY48PUFYUREVZeM",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1ccKn1a35BDW3Vqe6cCjoiWlDTl5XIY48PUFYUREVZeM/edit?usp=drivesdk",
          "cachedResultName": "NovaCore Solutions Leads"
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4.7
    },
    {
      "id": "c08fa915-6a60-453b-a663-058c92c1355f",
      "name": "Company Answering Model",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "position": [
        672,
        608
      ],
      "parameters": {
        "model": {
          "__rl": true,
          "mode": "list",
          "value": "gpt-4o",
          "cachedResultName": "gpt-4o"
        },
        "options": {}
      },
      "credentials": {
        "openAiApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "54007e6f-bf76-4811-950e-b2bd316d75c1",
      "name": "Main Chat Model",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "position": [
        224,
        224
      ],
      "parameters": {
        "model": {
          "__rl": true,
          "mode": "list",
          "value": "gpt-4o",
          "cachedResultName": "gpt-4o"
        },
        "options": {}
      },
      "credentials": {
        "openAiApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "guide-sticky-001",
      "name": "Template Guide",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        960,
        -160
      ],
      "parameters": {
        "width": 736,
        "height": 736,
        "content": "## Template Guide (Overview, Prerequisites & Customization)\n\n**What it does:** This workflow delivers a production-ready customer support and lead collection chatbot.\nIt answers company questions using Retrieval-Augmented Generation (RAG) and then captures lead details\n(name, email, phone, interest) to Google Sheets, while instantly notifying your team on Telegram with a\nshort summary of the conversation.\n\n**Target audience:** SMBs, startups, agencies and internal teams that want a 24/7 assistant which reduces\nrepetitive Q&A, improves response time and centralizes leads for follow-up.\n\n**How it works (high level):**\n1) A visitor sends a message to the chat interface (Trigger).\n2) The **Main Chat Model (GPT\u20114o)** manages the conversation and tool usage.\n3) For company facts, the agent calls **Company Q&A**, which performs RAG over your **Pinecone Vector Store**.\n4) After answering, the agent politely asks for **Name / Email / Phone / Interested in**.\n5) The lead is appended to **Google Sheets** and your team receives a Telegram notification.\n6) **Conversation Memory** keeps short-term context for a smoother chat experience.\n\n**Prerequisites:**\n- OpenAI API key (GPT\u20114o + text-embedding-3\u2011small for retrieval)\n- Pinecone project/index with your company knowledge (FAQs, docs, pricing, policies)\n- Google account with a Sheet for storing leads (columns: Name, Email, Phone, Interested in)\n- Telegram Bot Token and chat/group ID for notifications\n\n**Customization:**\n- Replace `[INSERT_YOUR_COMPANY_NAME_HERE]` in the Agent\u2019s system message.\n- Point the Pinecone node to your index/namespace.\n- Update the Google Sheets node to your Sheet ID and tab.\n- Set your Telegram `chatId`.\n- Adjust the **context window** and **prompt tone** to match your brand.\n\n**Notes & tips:**\n- Keep your knowledge base concise and up to date to improve RAG accuracy.\n- Use validation in Sheets (optional) to ensure clean lead data.\n- Consider adding duplicate checks, CRM sync, or email follow-ups as next steps."
      },
      "typeVersion": 1
    }
  ],
  "active": false,
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "d216f344-bdc5-4b44-916f-8eaec439de1f",
  "connections": {
    "AI Agent": {
      "main": [
        []
      ]
    },
    "Company Q&A": {
      "ai_tool": [
        [
          {
            "node": "AI Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Main Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "AI Agent",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Conversation Memory": {
      "ai_memory": [
        [
          {
            "node": "AI Agent",
            "type": "ai_memory",
            "index": 0
          }
        ]
      ]
    },
    "Send Lead to Telegram": {
      "ai_tool": [
        [
          {
            "node": "AI Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Company Answering Model": {
      "ai_languageModel": [
        [
          {
            "node": "Company Q&A",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Save Lead to Google Sheets": {
      "ai_tool": [
        [
          {
            "node": "AI Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "When chat message received": {
      "main": [
        [
          {
            "node": "AI Agent",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Generate Embeddings (OpenAI)": {
      "ai_embedding": [
        [
          {
            "node": "Pinecone Vector Store (Company KB)",
            "type": "ai_embedding",
            "index": 0
          }
        ]
      ]
    },
    "Pinecone Vector Store (Company KB)": {
      "ai_vectorStore": [
        [
          {
            "node": "Company Q&A",
            "type": "ai_vectorStore",
            "index": 0
          }
        ]
      ]
    }
  }
}

Credentials you'll need

Each integration node will prompt for credentials when you import. We strip credential IDs before publishing — you'll add your own.

Pro

For the full experience including quality scoring and batch install features for each workflow upgrade to Pro

About this workflow

Who’s it for

Source: https://n8n.io/workflows/9234/ — original creator credit. Request a take-down →

More AI & RAG workflows → · Browse all categories →

Related workflows

Workflows that share integrations, category, or trigger type with this one. All free to copy and import.

AI & RAG

This workflow acts as a 24/7 sales agent, engaging leads across WhatsApp, Instagram, Facebook, Telegram, and your website. It intelligently transcribes audio messages, answers questions using a knowle

Chat Trigger, Memory Postgres Chat, Tool Workflow +20
AI & RAG

Advanced Ai Demo Presented At Ai Developers 14 Meetup. Uses slack, stickyNote, textSplitterRecursiveCharacterTextSplitter, embeddingsOpenAi. Chat trigger; 39 nodes.

Slack, Text Splitter Recursive Character Text Splitter, OpenAI Embeddings +14
AI & RAG

Advanced Ai Demo (Presented At Ai Developers #14 Meetup). Uses slack, stickyNote, textSplitterRecursiveCharacterTextSplitter, embeddingsOpenAi. Chat trigger; 39 nodes.

Slack, Text Splitter Recursive Character Text Splitter, OpenAI Embeddings +14
AI & RAG

Workflow 2358. Uses slack, textSplitterRecursiveCharacterTextSplitter, embeddingsOpenAi, documentDefaultDataLoader. Chat trigger; 39 nodes.

Slack, Text Splitter Recursive Character Text Splitter, OpenAI Embeddings +14
AI & RAG

2358. Uses slack, textSplitterRecursiveCharacterTextSplitter, embeddingsOpenAi, documentDefaultDataLoader. Chat trigger; 39 nodes.

Slack, Text Splitter Recursive Character Text Splitter, OpenAI Embeddings +14