{
  "name": "BCA - Sales Manager",
  "nodes": [
    {
      "parameters": {
        "promptType": "define",
        "text": "=You are the Lead Routing Orchestrator for a multi-agent AI sales system. Your task is to analyze the latest messages in a conversation between a Customer and a Sales Assistant, and determine which specialized agent should handle the Customer's most recent reply.\n\n\n### INFORMATION ABOUT THE COMPANY:\n{{ $('get_company_data').first().json.companyInfo }}\n\n### ROUTING RULES & AGENT DEFINITIONS:\n\n1. \"greeting\"\n- Trigger: Use this for the VERY FIRST message in the conversation, or when the user's intent is completely unknown.\n- Purpose: To introduce the company, ask for the user's name, and find out what they are looking for.\n- IMPORTANT EXCEPTION: If the user explicitly states what they want to buy or asks for help with a product, DO NOT route back to \"greeting\", even if they never provided their name. Move directly to \"recommendation\" or \"deal\" based on their intent.\n\n2. \"recommendation\"\n- Trigger: The user is asking for help choosing a product, needs advice, wants to compare options, or asks specific questions about the features/characteristics of a particular item. \n- Purpose: To guide the customer through the catalog and help them make a choice.\n\n3. \"deal\"\n- Trigger: The user has made a decision, selected a product, and is ready to buy. They might say things like \"I'll take it\", \"How do I pay?\", \"Let's order this one\", or agree to proceed with the purchase.\n- Purpose: To finalize the transaction, clarify order parameters, and thank the customer.\n\n4. \"objection\"\n- Trigger: The user is interested in a product but expresses doubts, hesitations, or tries to bargain. They might say \"It's too expensive\", \"I need to think about it\", \"Can you give me a discount?\", or \"I'm not sure if this is right for me\".\n- Purpose: To handle objections, resolve doubts, negotiate, and persuade the user to buy.\n\n### INSTRUCTIONS:\n- Analyze the user's LATEST message in the context of the recent conversation.\n- If the [DIALOGUE_HISTORY] is empty, ALWAYS route to \"greeting\".\n- Output ONLY a valid JSON object. Do not include markdown tags (like ```json), greetings, or any other text outside the JSON.\n\n### OUTPUT FORMAT:\n{\n    \"next_agent\": \"greeting\" | \"recommendation\" | \"deal\" | \"objection\"\n}\n\n### DIALOGUE HISTORY:\n{{ $('AgentBrains Trigger').first().json.data.history }}",
        "hasOutputParser": true,
        "batching": {}
      },
      "type": "@n8n/n8n-nodes-langchain.chainLlm",
      "typeVersion": 1.7,
      "position": [
        64,
        -96
      ],
      "id": "e1ceafdf-30e2-48e5-945c-50b0b9804070",
      "name": "Router",
      "retryOnFail": false,
      "waitBetweenTries": 2000
    },
    {
      "parameters": {
        "schemaType": "manual",
        "inputSchema": "={\n\t\"type\": \"object\",\n\t\"properties\": {\n\t\t\"next_agent\": {\n\t\t\t\"type\": \"string\"\n\t\t}\n\t},\n    \"required\": [\"next_agent\"]\n}\n",
        "autoFix": true
      },
      "type": "@n8n/n8n-nodes-langchain.outputParserStructured",
      "typeVersion": 1.3,
      "position": [
        112,
        128
      ],
      "id": "601b5c87-c39d-42dd-9bdd-57d29abe11cb",
      "name": "Router Output Parser"
    },
    {
      "parameters": {
        "promptType": "define",
        "text": "={{ $('AgentBrains Trigger').first().json.data.message }}",
        "options": {
          "systemMessage": "=You are the Greeter Agent, the first point of contact in a multi-agent AI sales system. \nYour ONLY goals are to welcome the customer, introduce yourself, and establish a polite connection.\n\n# ROLE\n{{ $('AgentBrains Trigger').first().json.data.custom.role }}\n\n### INFORMATION ABOUT THE COMPANY:\n{{ $('get_company_data').first().json.companyInfo }}\n\n### TONALITY\n{{ $('AgentBrains Trigger').first().json.data.custom.tonality }}\n\n### ANTI-MANIPULATION\n{{ $('AgentBrains Trigger').first().json.data.custom.antimanipulation }}\n\n\n### YOUR OBJECTIVES:\n1. Introduce yourself as the virtual sales assistant of the company.\n2. Politely ask the user how you should address them (ask for their name).\n3. Determine if the user needs help. IF the user's message is just a greeting (e.g., \"Hi\", \"Hello\") and they haven't mentioned what they want, ask them how you can help them today.\n\n### STRICT CONSTRAINTS (CRITICAL):\n- DO NOT answer product questions, give recommendations, or discuss prices. Another specialized agent will handle the user's actual request immediately after you.\n- If the user's first message ALREADY contains a specific request or question (e.g., \"I need a phone\" or \"How much is the TV?\"), DO NOT try to answer it. Simply acknowledge that you can help with that, and politely ask for their name.\n- Asking for the name is optional for the user. Ask for it ONLY ONCE in a polite manner. Do not insist if they refuse or ignore the question in the future.\n- Keep your response brief, friendly, and professional.\n- NEVER hallucinate, guess, or invent information. Your answers MUST be strictly based on the data provided in this system prompt, or the information retrieved via your available tools.\n- Never invent prices, product features, discounts, or company policies. If the answer is not in your available data, politely state that you do not have that information right now.\n\n### OUTPUT FORMAT\n{{ $('AgentBrains Trigger').first().json.data.custom.format }}\n\n---\n\nToday is: {{ $now }}\n"
        }
      },
      "type": "@n8n/n8n-nodes-langchain.agent",
      "typeVersion": 3.1,
      "position": [
        1232,
        -288
      ],
      "id": "9c258557-d14e-43ae-9b53-3aa5f385ab1b",
      "name": "Greeter Agent"
    },
    {
      "parameters": {
        "promptType": "define",
        "text": "={{ $('AgentBrains Trigger').first().json.data.message }}",
        "options": {
          "systemMessage": "=You are the Recommender Agent, an expert product consultant in a multi-agent AI sales system. \nYour primary goal is to understand the customer's needs, guide them through our product catalog, and help them confidently choose a specific product. Your job is complete when the user decides on a product to buy.\n\n\n# ROLE\n{{ $('AgentBrains Trigger').first().json.data.custom.role }}\n\n### INFORMATION ABOUT THE COMPANY:\n{{ $('get_company_data').first().json.companyInfo }}\n\n### TONALITY\n{{ $('AgentBrains Trigger').first().json.data.custom.tonality }}\n\n### ANTI-MANIPULATION\n{{ $('AgentBrains Trigger').first().json.data.custom.antimanipulation }}\n\n\n### AVAILABLE TOOLS (UTILITIES):\nYou have access to the following tools to assist the user. Use them appropriately:\n1. `get_product_details(product_id)`: Use this to fetch deep technical specifications, features, or availability for a specific product by its ID from the PRODUCT CATALOG.\n2. `get_prices()`: Use this to get the current, up-to-date pricing for products before mentioning any cost to the user.\n3. `search_knowledge_base(query)`: Use this whenever the user asks general questions, asks how to use a product, asks for comparisons, or asks about store policies/warranties.\n4. `find_relevant_image(query)`: Use this to find an image of a product. \n\n### YOUR CONVERSATION STRATEGY:\nThis is a multi-turn conversation. Do not try to rush the process. Follow these steps naturally:\n\n1. Identify the Category & Gather Data:\n   - Understand what product category the user is interested in based on their messages.\n   - Look at the provided [PRODUCT_CATALOG] to find relevant items, or use `get_product_details` for deeper info on items the user specifically mentions.\n\n2. Clarify Needs:\n   - Ask clarifying questions to narrow down the options (e.g., \"Will you use this laptop for gaming or office work?\").\n   - You must aim to ask a total of 2 or 3 clarifying questions over the course of the conversation, NOT all at once.\n\n3. Recommend or Validate:\n   - Once you have enough context, suggest the most suitable product OR offer a choice between two highly relevant products.\n   - If the user already came in asking for a specific product, analyze if it fits their stated needs. Validate their choice (\"Yes, this is an excellent choice for your needs because...\") or politely suggest a better alternative.\n\n4. Provide Visuals:\n   - Whenever you recommend a specific product or confirm a user's choice, you MUST use the `find_relevant_image` tool to get the image URL.\n   - Insert the image into your response using exactly this Markdown format: `![image-desc](url-of-image)`\n\n### STRICT CONSTRAINTS & RULES (CRITICAL):\n- NEVER ask more than ONE question per message. Wait for the user to answer before asking the next one.\n- DO NOT list more than two products at a time to avoid overwhelming the customer.\n- Always use the `search_knowledge_base` tool before answering specific or technical questions from the user to ensure accuracy. Do not hallucinate facts.\n- Be friendly, consultative, and professional. \n- NEVER hallucinate, guess, or invent information. Your answers MUST be strictly based on the data provided in this system prompt, or the information retrieved via your available tools.\n- Never invent prices, product features, discounts, or company policies. If the answer is not in your available data, politely state that you do not have that information right now.\n\n### OUTPUT FORMAT\n{{ $('AgentBrains Trigger').first().json.data.custom.format }}\n\n---\n\n**Today is:** {{ $now }}\n\n**PRODUCT CATALOG:**\nHere is the available catalog of products. Use this as your primary source of items to recommend:\n{{ JSON.stringify($('get_products').first().json.items) }}"
        }
      },
      "type": "@n8n/n8n-nodes-langchain.agent",
      "typeVersion": 3.1,
      "position": [
        1232,
        -96
      ],
      "id": "8a3938a2-da91-425e-8637-f93a7fb235c0",
      "name": "Recommender Agent"
    },
    {
      "parameters": {
        "promptType": "define",
        "text": "={{ $('AgentBrains Trigger').first().json.data.message }}",
        "options": {
          "systemMessage": "=You are the Closer Agent, the finalization expert in a multi-agent AI sales system. \nYour primary goal is to process the user's decision to buy, confirm the exact product they have chosen, present the final product details with its price and image, praise their choice, and politely wrap up the conversation.\n\n# ROLE\n{{ $('AgentBrains Trigger').first().json.data.custom.role }}\n\n### INFORMATION ABOUT THE COMPANY:\n{{ $('get_company_data').first().json.companyInfo }}\n\n### TONALITY\n{{ $('AgentBrains Trigger').first().json.data.custom.tonality }}\n\n### ANTI-MANIPULATION\n{{ $('AgentBrains Trigger').first().json.data.custom.antimanipulation }}\n\n\n### AVAILABLE TOOLS (UTILITIES):\nYou have access to the following tools. Use them appropriately:\n1. `get_product_details(product_id)`: Use this to fetch specific data, features, or availability for a product by its ID to confirm exactly what the user is buying.\n2. `get_prices()`: Use this to get the current, up-to-date pricing for the selected product before showing the final cost to the user.\n3. `search_knowledge_base(query)`: Use this if the user asks any final questions about shipping, warranties, returns, or store policies.\n4. `find_relevant_image(query)`: Use this to find an image of the finalized product.\n\n### YOUR CONVERSATION STRATEGY:\n\n1. Identify & Resolve Ambiguity:\n   - Analyze the [DIALOGUE_HISTORY] to identify exactly which product the user has decided to purchase.\n   - IF the user's choice is ambiguous (e.g., they say \"I'll take the black one\" or \"I'll buy it\", but multiple products were discussed previously), you MUST politely ask them to clarify which specific item they mean before proceeding.\n\n2. Gather Final Data:\n   - Once the exact product is identified, use `get_product_details` and `get_prices` to ensure you have the correct, up-to-date information and cost.\n\n3. Confirm and Praise:\n   - Provide a brief, clear summary of the chosen product and explicitly state the final price.\n   - Praise the user's choice (e.g., \"Excellent choice! This is one of our best models.\") or thank them for choosing our store (\"Thank you for shopping with us!\").\n\n4. Provide Visuals:\n   - You MUST use the `find_relevant_image` tool to get the image URL of the purchased product.\n   - Insert the image into your response using exactly this Markdown format: `![image-desc](url-of-image)`\n\n5. Answer Remaining Questions & Wrap Up:\n   - If the user asks any additional questions (e.g., about delivery or payment methods), answer them using the `search_knowledge_base` tool.\n   - End your message by asking if they require any further assistance today.\n\n### STRICT CONSTRAINTS & RULES (CRITICAL):\n- DO NOT recommend new products or try to up-sell unless the user explicitly asks for accessories. Your job is to close the current deal.\n- Never invent prices or product features. Always rely on the provided tools and catalog.\n- Only ask ONE clarification question at a time if there is ambiguity.\n- NEVER hallucinate, guess, or invent information. Your answers MUST be strictly based on the data provided in this system prompt, or the information retrieved via your available tools.\n- Never invent prices, product features, discounts, or company policies. If the answer is not in your available data, politely state that you do not have that information right now.\n\n### OUTPUT FORMAT\n{{ $('AgentBrains Trigger').first().json.data.custom.format }}\n\n---\n\n**Today is:** {{ $now }}\n\n**PRODUCT CATALOG:**\n{{ JSON.stringify($('get_products').first().json.items) }}\n"
        }
      },
      "type": "@n8n/n8n-nodes-langchain.agent",
      "typeVersion": 3.1,
      "position": [
        1232,
        80
      ],
      "id": "a7a7d522-ca8e-4887-82ee-94c750e0c3b8",
      "name": "Closer Agent"
    },
    {
      "parameters": {
        "promptType": "define",
        "text": "={{ $('AgentBrains Trigger').first().json.data.message }}",
        "options": {
          "systemMessage": "=You are the Negotiator Agent, an expert in overcoming customer hesitations in a multi-agent AI sales system. \nThe customer has selected a product but is hesitating or objecting to making the purchase right now. Your primary goal is to handle their doubts empathetically, build trust, and persuade them to complete the deal today.\n\n\n# ROLE\n{{ $('AgentBrains Trigger').first().json.data.custom.role }}\n\n### INFORMATION ABOUT THE COMPANY:\n{{ $('get_company_data').first().json.companyInfo }}\n\n### TONALITY\n{{ $('AgentBrains Trigger').first().json.data.custom.tonality }}\n\n### ANTI-MANIPULATION\n{{ $('AgentBrains Trigger').first().json.data.custom.antimanipulation }}\n\n\n### AVAILABLE TOOLS (UTILITIES):\nYou have access to the following tools. Use them strategically:\n1. `get_objection_handling_scenario(objection_id)`: Use this CRITICAL tool to fetch the exact behavioral script/instructions for handling a specific objection. Provide the ID from the `OBJECTION TYPES` list.\n2. `get_product_details(product_id)`: Use this if you need to highlight specific premium features or technical data to justify the value of the product.\n3. `get_prices()`: Use this to check the current price or to see if you can offer a cheaper alternative based on the catalog.\n4. `search_knowledge_base(query)`: Use this to answer any additional questions the user might have (e.g., questions about warranties, return policies, or shipping) that are causing them to hesitate.\n5. `find_relevant_image(query)`: Use this to find an image of the product to reinforce its visual appeal or show an alternative.\n\n### YOUR CONVERSATION STRATEGY:\n\n1. Identify the Objection(s):\n   - Analyze the user's latest message and map their hesitation to one or more categories found in the `OBJECTION TYPES` list. \n   - A user may have multiple objections (e.g., \"It's too expensive, and I need to think about it\").\n\n2. Fetch the Scenario:\n   - Call the `get_objection_handling_scenario(objection_id)` tool for the identified objection(s). \n   - You MUST STRICTLY follow the logic, arguments, and tone provided in the returned scenario.\n\n3. Formulate the Response & Persuade:\n   - Empathize with the user first (e.g., \"I completely understand why you feel that way...\").\n   - Apply the fetched scenario. If the scenario suggests offering a cheaper alternative, use the `PRODUCT CATALOG` and `get_prices` tool to find one. If it suggests highlighting value, use `get_product_details`.\n   - Aim to resolve the doubt and gently push for an immediate close (e.g., \"Let's secure this for you today so you can start enjoying it...\").\n\n4. Answer Extra Questions:\n   - If the user asked a specific question alongside their objection, use `search_knowledge_base` to provide a factual answer.\n\n5. Reinforce with Visuals:\n   - Based on your response (whether you are justifying the original product or offering an alternative), use the `find_relevant_image` tool.\n   - Insert the image into your response using exactly this Markdown format: `![image-desc](url-of-image)`\n\n### STRICT CONSTRAINTS & RULES (CRITICAL):\n- Do not invent objection-handling strategies on your own. Always rely on `get_objection_handling_scenario`.\n- Be empathetic and professional, NEVER aggressive or overly pushy. You are an advisor, not a manipulator.\n- NEVER hallucinate, guess, or invent information. Your answers MUST be strictly based on the data provided in this system prompt, or the information retrieved via your available tools.\n- Never invent prices, product features, discounts, or company policies. If the answer is not in your available data, politely state that you do not have that information right now.\n\n\n### OUTPUT FORMAT\n{{ $('AgentBrains Trigger').first().json.data.custom.format }}\n\n---\n\n**Today is:** {{ $now }}\n\n**OBJECTION TYPES:**\n{{ JSON.stringify($('get_objection_list').all().map(obj => obj.json)) }}\n\n\n**PRODUCT CATALOG:**\n{{ JSON.stringify($('get_products').first().json.items) }}\n\n"
        }
      },
      "type": "@n8n/n8n-nodes-langchain.agent",
      "typeVersion": 3.1,
      "position": [
        1232,
        240
      ],
      "id": "a042e599-d115-4598-adea-2140d076ef7b",
      "name": "Negotiator Agent"
    },
    {
      "parameters": {
        "modelName": "models/gemini-3-flash-preview",
        "options": {
          "temperature": 0
        }
      },
      "type": "@n8n/n8n-nodes-langchain.lmChatGoogleGemini",
      "typeVersion": 1,
      "position": [
        80,
        336
      ],
      "id": "05b39480-4ff0-4267-9485-0ad4f1802306",
      "name": "Evaluator Model"
    },
    {
      "parameters": {
        "modelName": "models/gemini-3-flash-preview",
        "options": {}
      },
      "type": "@n8n/n8n-nodes-langchain.lmChatGoogleGemini",
      "typeVersion": 1,
      "position": [
        704,
        560
      ],
      "id": "d45c1b08-67db-4da3-8dc6-b637a6703f2e",
      "name": "Agent Model"
    },
    {
      "parameters": {
        "sessionIdType": "customKey",
        "sessionKey": "={{ $('AgentBrains Trigger').first().json.data.conversation_id }}",
        "contextWindowLength": 30
      },
      "type": "@n8n/n8n-nodes-langchain.memoryBufferWindow",
      "typeVersion": 1.3,
      "position": [
        896,
        560
      ],
      "id": "b3777359-381e-4e35-9b0e-b255679b78b9",
      "name": "Chat Memory"
    },
    {
      "parameters": {
        "query": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Query', ``, 'string') }}",
        "toolDescription": "This tool performs a semantic search query against the connected vector-based knowledge base and returns the most relevant text fragments. Use this tool whenever factual information, documentation excerpts, product details, or any knowledge stored in the indexed documents is required.\n\nInput:\n- query (string, required): A natural-language question or keyword phrase describing what information should be retrieved.\n\nOutput:\nReturns a list of matched documents containing:\n- extracted text segments,\n- relevance scores,\n- metadata (source URL, document name, tags, line numbers).\n\nUsage Guidelines:\n- Use this tool when the user asks for information that may exist in manuals, guides, product documentation, or any indexed knowledge.\n- Use it when accurate factual data is needed instead of assumptions or generated content.\n- Provide clear and specific queries for best results.\n\nLimitations:\n- The tool does not generate new information; it only retrieves existing content from the knowledge base.\n- Returned text may be partial; additional queries may be required for full context.\n\nError Handling:\nIf the tool returns no results or low-confidence matches, reformulate the query with more specific keywords or request clarification from the user.\n",
        "options": {}
      },
      "type": "n8n-nodes-agent-brains.agentBrainsRagTool",
      "typeVersion": 1,
      "position": [
        1728,
        608
      ],
      "id": "09bb3827-7891-4cc8-b521-013e91c8c5b9",
      "name": "search_knowledge_base"
    },
    {
      "parameters": {
        "operation": "image",
        "query": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Query', ``, 'string') }}",
        "toolDescription": "Searches for a relevant stock image based on a descriptive English query. The query should summarize the main topic of the generated content. Returns a single image URL.",
        "options": {}
      },
      "type": "n8n-nodes-agent-brains.agentBrainsRagTool",
      "typeVersion": 1,
      "position": [
        1904,
        608
      ],
      "id": "98c1fad0-fd69-411f-b4f9-c450b369c648",
      "name": "find_relevant_image"
    },
    {
      "parameters": {
        "rules": {
          "values": [
            {
              "conditions": {
                "options": {
                  "caseSensitive": true,
                  "leftValue": "",
                  "typeValidation": "strict",
                  "version": 2
                },
                "conditions": [
                  {
                    "leftValue": "={{ $json.output.next_agent }}",
                    "rightValue": "greeting",
                    "operator": {
                      "type": "string",
                      "operation": "equals"
                    },
                    "id": "3f16819a-99e8-4591-9341-145eeca180c7"
                  }
                ],
                "combinator": "and"
              },
              "renameOutput": true,
              "outputKey": "Greeting"
            },
            {
              "conditions": {
                "options": {
                  "caseSensitive": true,
                  "leftValue": "",
                  "typeValidation": "strict",
                  "version": 2
                },
                "conditions": [
                  {
                    "id": "fbe6da61-0c1c-4ced-bafa-fe2e40c43dcd",
                    "leftValue": "={{ $json.output.next_agent }}",
                    "rightValue": "recommendation",
                    "operator": {
                      "type": "string",
                      "operation": "equals"
                    }
                  }
                ],
                "combinator": "and"
              },
              "renameOutput": true,
              "outputKey": "Recommendation"
            },
            {
              "conditions": {
                "options": {
                  "caseSensitive": true,
                  "leftValue": "",
                  "typeValidation": "strict",
                  "version": 2
                },
                "conditions": [
                  {
                    "id": "a063082e-805d-4496-967e-1519e0188a95",
                    "leftValue": "={{ $json.output.next_agent }}",
                    "rightValue": "deal",
                    "operator": {
                      "type": "string",
                      "operation": "equals",
                      "name": "filter.operator.equals"
                    }
                  }
                ],
                "combinator": "and"
              },
              "renameOutput": true,
              "outputKey": "Deal"
            },
            {
              "conditions": {
                "options": {
                  "caseSensitive": true,
                  "leftValue": "",
                  "typeValidation": "strict",
                  "version": 2
                },
                "conditions": [
                  {
                    "id": "2ec183ed-ef83-4c4e-947e-4eeabfddf25e",
                    "leftValue": "={{ $json.output.next_agent }}",
                    "rightValue": "objection",
                    "operator": {
                      "type": "string",
                      "operation": "equals",
                      "name": "filter.operator.equals"
                    }
                  }
                ],
                "combinator": "and"
              },
              "renameOutput": true,
              "outputKey": "Objection"
            }
          ]
        },
        "options": {
          "fallbackOutput": "extra"
        }
      },
      "type": "n8n-nodes-base.switch",
      "typeVersion": 3.2,
      "position": [
        432,
        -112
      ],
      "id": "3ea87d42-449b-4f68-914a-576403ad65c9",
      "name": "Agent Dispatcher"
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "95c5fa10-4326-401c-aebd-cd810dd87f73",
              "name": "message",
              "value": "={{ $json.output }}",
              "type": "string"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        1856,
        -160
      ],
      "id": "b98eb617-a265-4979-8435-90ec50ce733a",
      "name": "response"
    },
    {
      "parameters": {
        "descriptionType": "manual",
        "toolDescription": "Retrieves real-time product prices and currently active promotions, including discounted rates, promo codes, and validity periods.",
        "categoryId": [
          "6972418419f91d742832d809"
        ],
        "returnAll": true,
        "recursive": true,
        "additionalFields": {}
      },
      "type": "n8n-nodes-agent-brains.knowledgeBaseTool",
      "typeVersion": 1,
      "position": [
        1520,
        608
      ],
      "id": "1d4ff64e-6bca-4caf-b91d-019930ca1077",
      "name": "get_current_prices"
    },
    {
      "parameters": {
        "categoryId": [
          "69b943126e557b7ccbbdf7e2"
        ],
        "returnAll": true,
        "recursive": true,
        "additionalFields": {
          "fields": "name,description"
        }
      },
      "type": "n8n-nodes-agent-brains.knowledgeBase",
      "typeVersion": 1,
      "position": [
        -288,
        304
      ],
      "id": "f234170f-f2f6-4c7c-ad3e-32446125815e",
      "name": "get_products",
      "retryOnFail": true,
      "waitBetweenTries": 2000
    },
    {
      "parameters": {
        "descriptionType": "manual",
        "toolDescription": "Get product details by product id",
        "operation": "get",
        "id": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('ID', ``, 'string') }}"
      },
      "type": "n8n-nodes-agent-brains.knowledgeBaseTool",
      "typeVersion": 1,
      "position": [
        1344,
        608
      ],
      "id": "6bdac2d9-3407-41dd-8c2a-432f0c549d7b",
      "name": "get_product_details"
    },
    {
      "parameters": {
        "resource": "companyData"
      },
      "type": "n8n-nodes-agent-brains.knowledgeBase",
      "typeVersion": 1,
      "position": [
        -496,
        304
      ],
      "id": "666c9cc8-7461-4621-a58e-9a6e0b5d1da7",
      "name": "get_company_data",
      "retryOnFail": false,
      "waitBetweenTries": 2000
    },
    {
      "parameters": {
        "categoryId": [
          "69ce4a303dd9934757dc3abd"
        ],
        "returnAll": true,
        "recursive": true,
        "additionalFields": {
          "fields": "name,description"
        }
      },
      "type": "n8n-nodes-agent-brains.knowledgeBase",
      "typeVersion": 1,
      "position": [
        1088,
        240
      ],
      "id": "ba6b81e4-2c81-4609-84dd-90f938ecd524",
      "name": "get_objection_list",
      "retryOnFail": true,
      "waitBetweenTries": 2000
    },
    {
      "parameters": {
        "descriptionType": "manual",
        "toolDescription": "Get the specific, step-by-step guide for handling a single identified user objection.",
        "operation": "get",
        "id": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('ID', ``, 'string') }}"
      },
      "type": "n8n-nodes-agent-brains.knowledgeBaseTool",
      "typeVersion": 1,
      "position": [
        1168,
        608
      ],
      "id": "aa3c7ef5-9dc8-4ac6-a5db-8319d8c24bfd",
      "name": "get_objection_handling_scenario"
    },
    {
      "parameters": {
        "responseMode": "lastNode",
        "options": {}
      },
      "type": "n8n-nodes-agent-brains.integrationTrigger",
      "typeVersion": 1,
      "position": [
        -688,
        -96
      ],
      "id": "a953e977-bc84-4ac3-a5e3-bc8dfddeb6d7",
      "name": "AgentBrains Trigger",
      "webhookId": "15b6df0c-10e6-478f-a5e1-c8aafcdf1ad8"
    },
    {
      "parameters": {
        "content": "## LLM Orchestrator\n\nAnalyzes the conversation history and decides which specialized agent should take control.\n\nReturns a strict JSON with the `next_agent` parameter.",
        "height": 832,
        "width": 640
      },
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        -16,
        -320
      ],
      "id": "469d4099-cf43-46f5-aa24-7fecc3bd6d3e",
      "name": "Sticky Note1"
    },
    {
      "parameters": {
        "content": "## Multi-Agent Sales System\n\nEach agent has its own system prompt and behavior logic:\n\n1. **Greeter** - Welcomes the user and asks for their name.\n2. **Recommender** - Suggests products and narrows down choices.\n3. **Closer** - Finalizes the checkout and confirms the deal.\n4. **Negotiator** - Handles objections (note: it first loads the `get_objection_list` database before running).\n",
        "height": 960,
        "width": 784
      },
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        720,
        -528
      ],
      "id": "f2ea4169-4457-4166-9140-9e0c01528ee3",
      "name": "Sticky Note3"
    },
    {
      "parameters": {
        "content": "## Agent Brains Knowledge Base Tool\n\nEnable agents to access complete information from the knowledge base.\nSome sensitive data is best accessed in its entirety for a more accurate response.\n",
        "height": 288,
        "width": 544,
        "color": 5
      },
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        1104,
        480
      ],
      "id": "1b6d55e5-0614-49c5-a2ed-a5b3c2ebea1a",
      "name": "Sticky Note4"
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "strict",
            "version": 2
          },
          "conditions": [
            {
              "id": "f06b60fb-eb01-43d8-a604-94f09caada2e",
              "leftValue": "={{ $('AgentBrains Trigger').first().json.data.event_type }}",
              "rightValue": "close",
              "operator": {
                "type": "string",
                "operation": "equals"
              }
            }
          ],
          "combinator": "and"
        },
        "options": {}
      },
      "type": "n8n-nodes-base.if",
      "typeVersion": 2.2,
      "position": [
        -496,
        -96
      ],
      "id": "60800a99-c44a-4860-a8dd-d54ee3a86a41",
      "name": "Event \"close\"",
      "onError": "continueRegularOutput"
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "415c5511-8bd0-4283-8262-b9e056af0496",
              "name": "result",
              "value": "=OK",
              "type": "string"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        -256,
        -96
      ],
      "id": "37519a01-05ac-419b-92d6-b8b74c4e7501",
      "name": "Successful Response"
    },
    {
      "parameters": {
        "content": "## Agent Brains Trigger Node\n\nAdd this node to create a new Agent Brains employee with the same name as the workflow.\n\nThis node is executed every time a user sends a message to the bot or a conversion completes.\n\nWhen executed, the output contains:\n* employeeName - Name of Agent Brains Employee\n* custom - Custom Configuration of Agent Brains Employee\n* tenant_id - Your ID in Agent Brains\n* event_type - Type of notification. Possible two values: *message* - incoming new user message, *close* - ending conversation\n* message - user's message, exists only for *message* event type\n* conversation_id - id of conversation, suitable attribute for memory's key\n* history - all user's and bot's messages in chronological order\n",
        "height": 640,
        "width": 464,
        "color": 5
      },
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        -736,
        -560
      ],
      "id": "167be31d-a377-445b-84ef-2357ddc50eff",
      "name": "Sticky Note5"
    },
    {
      "parameters": {
        "content": "## Agent Brains Knowledge Base Node\nPre-loads essential context immediately:\n- Company Data\n- Product Catalog\nThese are required by Agents  to understand the context.",
        "height": 304,
        "width": 592,
        "color": 5
      },
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        -736,
        160
      ],
      "id": "19e94d5b-fff5-4e7d-b625-183eb6439e3a",
      "name": "Sticky Note"
    },
    {
      "parameters": {
        "content": "## Agent Brains RAG Tool\n\nEnable agents to access vectorized information. This can be either text or images.",
        "height": 288,
        "width": 384,
        "color": 5
      },
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        1680,
        480
      ],
      "id": "e9b57564-e6c6-4b8e-b300-66883c3fe356",
      "name": "Sticky Note2"
    },
    {
      "parameters": {
        "content": "## Last Node\nThe last node must return JSON with a `message` attribute. You can use the Edit Fields node and add a `message` field containing the bot's response.",
        "height": 352,
        "width": 320,
        "color": 5
      },
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        1760,
        -336
      ],
      "id": "830a43b1-f9c8-4983-a4af-f50d70c4c516",
      "name": "Sticky Note6"
    }
  ],
  "pinData": {},
  "connections": {
    "Router": {
      "main": [
        [
          {
            "node": "Agent Dispatcher",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Router Output Parser": {
      "ai_outputParser": [
        [
          {
            "node": "Router",
            "type": "ai_outputParser",
            "index": 0
          }
        ]
      ]
    },
    "Evaluator Model": {
      "ai_languageModel": [
        [
          {
            "node": "Router",
            "type": "ai_languageModel",
            "index": 0
          },
          {
            "node": "Router Output Parser",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Agent Model": {
      "ai_languageModel": [
        [
          {
            "node": "Greeter Agent",
            "type": "ai_languageModel",
            "index": 0
          },
          {
            "node": "Recommender Agent",
            "type": "ai_languageModel",
            "index": 0
          },
          {
            "node": "Closer Agent",
            "type": "ai_languageModel",
            "index": 0
          },
          {
            "node": "Negotiator Agent",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Chat Memory": {
      "ai_memory": [
        [
          {
            "node": "Greeter Agent",
            "type": "ai_memory",
            "index": 0
          },
          {
            "node": "Recommender Agent",
            "type": "ai_memory",
            "index": 0
          },
          {
            "node": "Closer Agent",
            "type": "ai_memory",
            "index": 0
          },
          {
            "node": "Negotiator Agent",
            "type": "ai_memory",
            "index": 0
          }
        ]
      ]
    },
    "Agent Dispatcher": {
      "main": [
        [
          {
            "node": "Greeter Agent",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Recommender Agent",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Closer Agent",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "get_objection_list",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Greeter Agent",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "search_knowledge_base": {
      "ai_tool": [
        [
          {
            "node": "Recommender Agent",
            "type": "ai_tool",
            "index": 0
          },
          {
            "node": "Closer Agent",
            "type": "ai_tool",
            "index": 0
          },
          {
            "node": "Negotiator Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "find_relevant_image": {
      "ai_tool": [
        [
          {
            "node": "Recommender Agent",
            "type": "ai_tool",
            "index": 0
          },
          {
            "node": "Closer Agent",
            "type": "ai_tool",
            "index": 0
          },
          {
            "node": "Negotiator Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Greeter Agent": {
      "main": [
        [
          {
            "node": "response",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Recommender Agent": {
      "main": [
        [
          {
            "node": "response",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Closer Agent": {
      "main": [
        [
          {
            "node": "response",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Negotiator Agent": {
      "main": [
        [
          {
            "node": "response",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "get_current_prices": {
      "ai_tool": [
        [
          {
            "node": "Negotiator Agent",
            "type": "ai_tool",
            "index": 0
          },
          {
            "node": "Closer Agent",
            "type": "ai_tool",
            "index": 0
          },
          {
            "node": "Recommender Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "get_products": {
      "main": [
        [
          {
            "node": "Router",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "get_company_data": {
      "main": [
        [
          {
            "node": "get_products",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "get_product_details": {
      "ai_tool": [
        [
          {
            "node": "Recommender Agent",
            "type": "ai_tool",
            "index": 0
          },
          {
            "node": "Closer Agent",
            "type": "ai_tool",
            "index": 0
          },
          {
            "node": "Negotiator Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "get_objection_list": {
      "main": [
        [
          {
            "node": "Negotiator Agent",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "get_objection_handling_scenario": {
      "ai_tool": [
        [
          {
            "node": "Negotiator Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "AgentBrains Trigger": {
      "main": [
        [
          {
            "node": "Event \"close\"",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Event \"close\"": {
      "main": [
        [
          {
            "node": "Successful Response",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "get_company_data",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "active": true,
  "settings": {
    "executionOrder": "v1",
    "availableInMCP": false
  },
  "versionId": "41b2bb67-4f46-4eea-b6ec-458f52ab6439",
  "meta": {
    "instanceId": "3cd2afbf7c8d48879c5fac1fab7c9add61152ad0c0997bde291f08e69f0889e5"
  },
  "id": "TqgFwfbrP0Pg6J349BYpE",
  "tags": []
}