I want to discuss a task or project
Done! We will get back to you within one business day
Something went wrong. Please try again
Alexander Start:Duck 🦢
@olga_startduck
Write to Telegram
Назад
1k+ участников
Вступить в Telegram
n8n
05.09.2025

Telegram Chatbot via n8n - Smart sales consultant

Process description

This automation is an intelligent Telegram bot for an electronics store. The bot acts as a virtual consultant and seller that helps customers choose the right products, answers questions about features, provides information on availability and prices, and automatically notifies them of potential sales.

System architecture

MAIN COMPONENTS OF THE SYSTEM

1. AI Agent (Bot Core)

Purpose: The central intelligence of the system that processes customer requests

Connected components:

  • OpenAI Chat Model (gpt-4o-mini) - language model
  • Simple Memory - conversation memory
  • Supabase Vector Store - product database (tool: shop_storage)
  • Pinecone Vector Store - knowledge base (tool: Info)
  • GetLead - lead notifications

System prompt:

You're a virtual consultant and salesman in an electronics store.

You are polite, competent, friendly and always strive to help customers choose the right product.

You are connected to the Supabase database, which contains current product data:

name, category, specifications (including manufacturer, model, memory capacity, screen size, battery, connection type, etc.), price, availability, rating, product ID, link to photo.

Your task is:

- Find out the customer's needs and offer suitable products.

- Answer questions about the characteristics and differences between products.

- Report availability and price.

- Offer related products or alternatives if you don't have the right one.

- Always use information from the database (Supabase) — don't invent anything.

Examples of behavior:

If a user writes:

“I want a cheap smartphone with a good camera”

— Check your budget, ask what else is important (for example, brand or autonomy), and select 3 options from the database, briefly describing their advantages.

If it asks:

“How is this laptop different from that one?”

— Compare the characteristics from the database: screen, processor, memory, autonomy, etc.

If the item is out of stock:

— Report this and suggest similar alternatives.

Response format:

- Short and clear (1-2 paragraphs).

- Show price and availability.

- Provide a link to a photo or product card, if it is available in the database.

Communication style:

- Respectful but lively (like “you”, with a friendly tone).

- Not intrusive, but with easy sales elements: emphasize benefits, offer better options.

If the customer reaches the purchase stage and chooses something for themselves, use the GetLead tool to send a lead alert.

2. Memory System

Purpose: Ensures a contextual conversation

Simple Memory settings:

  • Session ID Type: Custom Key
  • Session Key: {{$json.message.chat.id}} (unique chat ID)
  • Context Window Length: 10 posts

Working principle:

  1. Each Telegram chat gets a unique session
  2. The bot remembers the last 10 messages from each customer
  3. Context is maintained between messages within the same chat
  4. The memory is cleared when the limit is reached (rolling window)

3. Vector Store Systems (Vector Knowledge Bases)

3.1 Supabase Vector Store - Product Database Purpose: Searching for and providing product information

Settings:

  • Mode: retrieve-as-tool (used as a tool)
  • Tool Name: “shop_storage”
  • Tool Description: “Store database”
  • Table Name: “products”
  • Embedding Model: OpenAI Embeddings

The structure of these goods:

  • Title - product name
  • Category - device type (smartphone, laptop, etc.)
  • Features - manufacturer, model, memory, screen, battery, connections
  • Price - product price
  • Availability - quantity in stock
  • Rating - product evaluation
  • Item ID - unique identifier
  • Link to the photo - Image URL
  • embedding

3.2 Pinecone Vector Store - Knowledgebase Purpose: Searching for general information about the store

Settings:

  • Mode: retrieve-as-tool
  • Tool Name: Info
  • Tool Description: “Working with general information about the store”
  • Index: “ope”
  • Embedding Model: OpenAI Embeddings

Knowledge base content:

  • Return and exchange policies
  • Delivery terms
  • Guarantee obligations
  • Promotions and discounts
  • Contact information
  • Service FAQ

MAIN WORK PROCESS

STEP 1: RECEIVE A MESSAGE

1.1 Telegram Trigger

Purpose: Receives incoming messages from users

Settings:

  • Updates: message (text messages only)
  • Webhook ID: unique to every bot
  • Credentials: Test Shop (Telegram API key)

What's going on:

  1. A user sends a message to a bot on Telegram
  2. Telegram sends webhook to n8n
  3. The trigger is activated and sends these messages

The structure of the data obtained:

{

“message”: {

“message_id”: 123,

“chat”: {

“id”: 987654321,

“type”: “private”

},

“text”: “I want to buy a smartphone”,

“from”: {

“id”: 987654321,

“username”: “user123"

}

}

}

STAGE 2: AI PROCESSING BY AN AGENT

2.1 Query analysis

What's going on:

  1. AI receives the message text: {{$json.message.text}}
  2. Loads context from Simple Memory via chat.id
  3. Analyzes user intent
  4. Determines whether databases need to be searched

2.2 Working with tools

Product search (shop_storage):

  • AI uses Supabase Vector Store for product inquiries
  • A semantic search is performed by description
  • The most relevant items are returned
  • AI analyzes features, prices, availability

Information search (Info):

  • AI uses Pinecone Vector Store when asking questions about the store
  • General Knowledge Base Search
  • Obtaining data on delivery, warranty, returns

Send a lead (GetLead):

  • When ready to buy, AI uses the GetLead tool
  • A notification is automatically sent to the manager
  • Includes information about the customer and the selected item

2.3 Response generation

AI creates a personalized response, taking into account:

  • The context of previous messages
  • Product information found
  • Customer needs
  • Communication style (polite, professional)

STEP 3: SEND A RESPONSE

3.1 Telegram Response

Purpose: Sends a response to the user

Settings:

  • Chat ID: {{$ ('Telegram Trigger') .item.json.message.chat.id}}
  • Text: {{$json.output}} (answer from AI Agent)
  • Additional Fields:
    • AppendAttribution: false (removes n8n signature)

Additional knowledge download system

STEP 4: UPDATING THE KNOWLEDGE BASE

4.1 Form Trigger - On form submission

Purpose: Uploading documents to the knowledge base

Settings:

  • Form Title: Knowledge Base
  • Form Description: “Upload a document”
  • Form Fields: File upload

4.2 Document Processing Pipeline

Document processing sequence:

Default Data Loader:

  • Data Type: binary (works with files)
  • Supported formats: PDF, DOC, TXT, etc.

Character Text Splitter:

  • Splits the document into fragments
  • Optimal size for vectorization
  • Maintains semantic coherence

Embeddings OpenAI1:

  • Creates vector representations of fragments
  • Uses the OpenAI model for embedding

Pinecone Vector Store1:

  • Mode: insert (add to database)
  • Index: “ope”
  • Saves vectors to Pinecone for searching

Detailed connection diagram

Main process (active):

  1. Telegram TriggerAI Agent
  2. AI AgentTelegram

AI components:

  • OpenAI Chat ModelAI Agent (language model)
  • Simple MemoryAI Agent (conversation memory)
  • Supabase Vector StoreAI Agent (product database as a tool)
  • Pinecone Vector StoreAI Agent (knowledge base as tool)
  • GetLeadAI Agent (notifications as a tool)

Vector search support:

  • OpenAI EmbeddingsSupabase Vector Store (product embeddings)
  • Embeddings OpenAI2Pinecone Vector Store (embeddings for knowledge)

Knowledge download system (disabled):

  1. On form submissionPinecone Vector Store1
  2. Default Data LoaderPinecone Vector Store1
  3. Character Text SplitterDefault Data Loader
  4. Embeddings OpenAI1Pinecone Vector Store1

Required services and settings

API keys and services:

  1. Telegram Bot Token - for integration with Telegram
  2. OpenAI API Key - for GPT-4O-mini and embeddings
  3. Supabase API Key - for the product database
  4. Pinecone API Key - for the knowledge base

Setting up Telegram bots:

  • Test Shop - the main bot for customers
  • Youtube transcribe - a bot for notifying managers

Product base structure (Supabase):

Pinecone setup:

  • Index name: “Any name”
  • Dimensions: 1536 (complies with OpenAI embeddings)
  • Metric: cosine similarity

System capabilities

Key features:

  • Product consulting - selection by parameters
  • Compare features - detailed comparison
  • Availability information - current warehouse data
  • Offering alternatives - if there is no product
  • Lead notifications - automatic transfer to managers

Intellectual capabilities:

  • Semantic search - understanding natural language
  • Contextual memory - recording previous messages
  • Personalization - adaptation to customer needs
  • Multi-level knowledge base - products+ general information

System advantages:

  • 24/7 availability - works around the clock
  • Instant answers - no queues and no waiting
  • Relevant information - direct connection to the product database
  • Automated lead qualification - manager notifications
  • Scalability - can serve multiple customers

Examples of use cases

Scenario 1: Smartphone selection

Client: “I want a cheap smartphone with a good camera”

The process:

  1. AI analyzes the request
  2. Search in Supabase by “low price"+"camera”
  3. Returns 3 options with features and prices
  4. Remembers Simple Memory preferences

Scenario 2: Product Comparison

Client: “How is the iPhone 15 different from the Samsung Galaxy S24?”

The process:

  1. Search for both models in the product database
  2. Extracting features (screen, processor, camera, battery)
  3. Structured comparison
  4. Requirement-based recommendation

Scenario 3: Shipping Information

Client: “What are your delivery terms?”

The process:

  1. Pinecone Vector Store Search (Knowledge Base)
  2. Retrieving shipping information
  3. Providing current conditions and tariffs

Scenario 4: Readiness to buy

Client: “I want to buy this laptop”

The process:

  1. AI determines purchase intent
  2. Uses the GetLead tool
  3. Sends a notification to the manager with details
  4. Provides the customer with information about the next steps

The result of the system

What happens is:

  • Smart consultant working 24/7
  • Qualified support based on current data
  • Automatic lead generation for the sales department
  • Personalized service with context memory
  • Scalable solution for business growth

Performance metrics:

  • Response speed - instant responses to requests
  • Accuracy of information - data directly from the product database
  • Conversion to leads - automatic identification of ready customers
  • Customer satisfaction - professional service

Application:

  • Online stores - sales automation
  • Retail chains - customer support
  • B2B sales - lead qualification
  • Tech support - solving typical issues

This system turns a simple Telegram bot into a full-fledged virtual sales consultant with access to a database of products and knowledge!

Читайте также

No items found.

write to us and we will show you the way to efficiency