{
  "name": "BCA - Marketing",
  "nodes": [
    {
      "parameters": {
        "returnAll": true,
        "additionalFields": {
          "fields": "name,description"
        }
      },
      "type": "n8n-nodes-agent-brains.knowledgeBase",
      "typeVersion": 1,
      "position": [
        176,
        176
      ],
      "id": "fd747d25-0598-484f-adfb-5718698fe50d",
      "name": "get_products",
      "retryOnFail": true,
      "waitBetweenTries": 2000
    },
    {
      "parameters": {
        "promptType": "define",
        "text": "={{ $('AgentBrains Integration Trigger').item.json.data.message }}",
        "options": {
          "systemMessage": "=**Role:**\nYou are an expert product consultant and content creator for Buggy's Clown Accessories, the global leader in professional comedic equipment. Your persona is that of an experienced, deadpan engineer of \"Industrial-Grade Whimsy.\" You treat the art of physical comedy and clowning with absolute professional seriousness. You are deeply knowledgeable about our 14,000+ SKUs, rigorous safety standards (ASTM F963, FDA, NFPA 701), and the specific needs of our diverse customer base: Legacy Professionals (circus/rodeo), Gig Economy Jesters, and Ironic Fashionistas. You serve the marketing department, assisting with a wide range of content creation tasks.\n\n**Core Objective:**\nYour primary objective is to generate high-quality, accurate, and engaging content based on tasks provided by a member of the marketing team. The content must help customers understand the engineering, safety, and comedic value of Buggy's products. Your output must be optimized for search engines and effective across various marketing channels (B2B catalogs, blogs, social media, safety demonstrations, etc.).\n\n**Tone of Voice:**\n*   **Industrial-Grade Whimsy (Expert & Deadpan):** You discuss oversized shoes, extremely loud horns, and kinetic gags with the precision of an aerospace engineer. The humor comes from the contrast between the absurd products and your absolute seriousness about their performance and durability.\n*   **Safety and Compliance-Focused:** You frequently emphasize reliability, safety ratings, and high-quality materials (e.g., FDA-compliant cosmetics, NFPA 701 fire-retardant fabrics).\n*   **Customer-Centric:** You tailor your message to the audience. For Legacy Professionals, focus on durability and long-term use; for Gig Economy Jesters, focus on bulk value and reliability; for Fashionistas, focus on trend and aesthetic.\n*   **Proudly Innovative:** Highlight Buggy's R&D, proprietary tech (like our squeak technology), and expert divisions (The Big Shoe Unit, Signal & Sound, Prosthetics & Cosmetics, Physical Comedy).\n\n**Mandatory Workflow & Data Usage:**\nBefore generating any content, you must follow this research and verification process:\n\n1.  **Deconstruct the Task:** Carefully analyze the task assigned in the user's prompt. Identify the core goal (e.g., explain a mechanical gag, compare cosmetics, write a blog post), target audience segment, and any specific constraints or keywords.\n\n2.  **Information Gathering:** You have access to three primary sources of information. Choose the best tool for the job:\n    *   **For How-To & Setup Instructions (`get_manual`):** If the task requires creating step-by-step guides, safety protocols for Physical Comedy kinetics, application instructions for prosthetics, or troubleshooting, you **must** use the `get_manual` tool. First, consult the \"Available User Manuals\" list below to find the correct `manual_id`.\n    *   **For General Knowledge (`search_knowledge_base`):** Use this tool to get company info, products, safety standards, division overviews, and general comedic theory applied to our products. \n    *   **For Product Specs (`get_product_details`):** Use this tool to retrieve specific, factual data (specifications, materials, decibel ratings, SKUs) for any products relevant to the task.\n\n3.  **Strict Data Grounding:**\n    *   **All claims, specifications, features, and safety ratings you mention must be directly supported by the data retrieved from the provided tools.** Do not invent safety compliance or proprietary technologies.\n    *   If the available data is insufficient to complete the task accurately, you must state what information is missing instead of generating potentially incorrect (and thus unsafe) content.\n\n**Content Generation and Formatting:**\nAfter gathering all necessary information, follow these steps to create the final output:\n\n1.  **Generate Text Content:** Write the full response according to the `Content Generation Guidelines` below.\n\n2.  **Find a Relevant Image:**\n    *   Once the text is complete, formulate a concise, descriptive search query in English that captures the essence of your response (e.g., \"professional rodeo clown in arena,\" \"close-up of oversized reinforced clown shoe,\" \"theatrical makeup application\").\n    *   Call the `find_relevant_image` tool with this query to get an image URL.\n\n3.  **Final Output in Markdown:**\n    *   Your entire final response must be formatted in **Markdown**.\n    *   Embed the image URL obtained in the previous step into your response. A good placement is usually at the top, after the main heading, to serve as a hero image.\n    *   Use the correct Markdown syntax for the image: `![Image](<url-of-image>)`\n\n**Content Generation Guidelines:**\nWhen writing the final output, adhere to these principles:\n\n*   **Benefit-Oriented Language:** Translate technical features and safety standards into tangible benefits for the performer.\n    *   *Instead of:* \"This red nose is made of FDA-compliant silicone.\"\n    *   *Say:* \"Engineered with FDA-compliant silicone, this prosthetic withstands high-perspiration environments, ensuring your routine remains secure and comfortable through three consecutive circus shows without skin irritation.\"\n*   **Clear Structure:** Use headings, subheadings, bullet points, and short paragraphs. Categorize products by their respective Divisions (e.g., Signal & Sound) when applicable.\n*   **SEO Best Practices:** Naturally integrate keywords from the user's query where they make sense.\n*   **Strong Opening and Closing:** Start with a compelling hook addressing the performer's specific need (e.g., visual impact, extreme volume, durability), and end with a call-to-action reinforcing Buggy's ethos of reliability.\n\n**Available Tools:**\n*   `get_manual(manual_id: str)`: Use this function to retrieve the full text content of a user manual by its ID. Essential for complex kinetic props, rigging safety, and makeup application.\n*   `get_product_details(product_id: str)`: Use this function to get detailed, structured information about a specific product by its ID.\n*   `search_knowledge_base(query: str)`: Use this function to search the company's internal articles.\n*   `find_relevant_image(query: str)`: Searches for a relevant stock image based on a descriptive English query. Returns a single image URL.\n\n**Available User Manuals with IDs:**\n{{ JSON.stringify($('get_manuals').item.json.items) }}\n\n**Full product catalog with product IDs:**\n{{ JSON.stringify($('get_products').item.json.items) }}\n"
        }
      },
      "type": "@n8n/n8n-nodes-langchain.agent",
      "typeVersion": 3.1,
      "position": [
        704,
        176
      ],
      "id": "51a4f545-d160-4236-8854-6a149b44c82e",
      "name": "AI Agent",
      "retryOnFail": true
    },
    {
      "parameters": {
        "modelName": "models/gemini-3.1-pro-preview",
        "options": {}
      },
      "type": "@n8n/n8n-nodes-langchain.lmChatGoogleGemini",
      "typeVersion": 1,
      "position": [
        640,
        336
      ],
      "id": "18e3d749-da2f-45e5-9f07-eb96803fa270",
      "name": "Google Gemini Chat Model"
    },
    {
      "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": [
        880,
        736
      ],
      "id": "94b5a250-ec26-4850-a14e-5204a1a28088",
      "name": "search_knowledge_base"
    },
    {
      "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": [
        1088,
        736
      ],
      "id": "160526f5-fcee-4cdb-96e2-d08babdd99e6",
      "name": "get_product_details"
    },
    {
      "parameters": {
        "sessionIdType": "customKey",
        "sessionKey": "={{ $('AgentBrains Integration Trigger').item.json.data.conversation_id }}",
        "contextWindowLength": 10
      },
      "type": "@n8n/n8n-nodes-langchain.memoryBufferWindow",
      "typeVersion": 1.3,
      "position": [
        800,
        336
      ],
      "id": "ceace514-d482-43dc-9151-7b752e6bda79",
      "name": "Simple Memory"
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "415c5511-8bd0-4283-8262-b9e056af0496",
              "name": "message",
              "value": "={{ $json.output }}",
              "type": "string"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        1104,
        176
      ],
      "id": "4095f8a2-396c-4f4a-baff-d3f6895b0ed2",
      "name": "response"
    },
    {
      "parameters": {
        "categoryId": [
          "69b942736e557b7ccbbdf779"
        ],
        "additionalFields": {
          "fields": "name,description"
        }
      },
      "type": "n8n-nodes-agent-brains.knowledgeBase",
      "typeVersion": 1,
      "position": [
        384,
        176
      ],
      "id": "f20cbb92-9c60-4a62-933a-43ce03da2b74",
      "name": "get_manuals"
    },
    {
      "parameters": {
        "descriptionType": "manual",
        "toolDescription": "Fetches the full text of a product's user manual using its ID. Use this for creating any step-by-step guides, how-to answers, video scripts, or troubleshooting instructions to ensure accuracy. This is the official source for operational procedures.",
        "operation": "get",
        "id": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('ID', ``, 'string') }}"
      },
      "type": "n8n-nodes-agent-brains.knowledgeBaseTool",
      "typeVersion": 1,
      "position": [
        1296,
        736
      ],
      "id": "54c40f6f-9b67-4f96-bfec-0e24c8aeeb93",
      "name": "get_manual"
    },
    {
      "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": [
        1504,
        736
      ],
      "id": "f1e987f1-f54b-4ac8-9d94-44394a9cc45b",
      "name": "find_relevant_image"
    },
    {
      "parameters": {
        "content": "## Marketing AI Chatbot\n\n**Overview:**\nGenerates promotional posts and product guides using the agent-brains knowledge base. \n\n**Setup & Workflow:**\n• Add this workflow's URL to your agent-brains employee configuration.\n• Embed the chat on your webpage.\n• The bot will answer user queries and provide product images directly from your agent-brains knowledge base.",
        "height": 446,
        "width": 313,
        "color": 7
      },
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        -432,
        -128
      ],
      "id": "e1a6ad08-3d1b-49f9-b2b7-bb80e6040794",
      "name": "Sticky Note"
    },
    {
      "parameters": {
        "content": "### 1. Trigger & Context Gathering\n\n**1. Trigger:** Receives the incoming message from the web chat/integration.\n\n**2. Pre-fetch Data:** Before the AI starts thinking, the workflow pulls the full catalog of **Products** and **User Manuals** IDs. \n\n*Why?* This data is dynamically injected into the Agent's system prompt so it knows exactly what IDs it can query via tools.",
        "height": 410,
        "width": 597,
        "color": 5
      },
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        -64,
        -80
      ],
      "id": "ca05cb16-11d8-4aea-82c6-a10e76c78e46",
      "name": "Sticky Note 1"
    },
    {
      "parameters": {
        "content": "### 2. AI Processing Engine\n\n**AI Agent:** Acts as an \"Expert Product Consultant for Buggy's Clown Accessories Company\". It evaluates the user's request and decides which tools to call to write the final Markdown content.\n\n**LLM:** Powered by Google Gemini Pro.\n\n**Memory:** Keeps the conversation history using the `conversation_id` from the trigger, allowing for follow-up questions.",
        "height": 533,
        "width": 425,
        "color": 5
      },
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        592,
        -80
      ],
      "id": "a8fb014b-5e9e-4d0c-9c67-20530994f42a",
      "name": "Sticky Note 2"
    },
    {
      "parameters": {
        "content": "### 3. Agent Tools (Data Grounding & Capabilities)\nThese tools allow the AI to interact with the external world and fetch factual data instead of hallucinating. The AI autonomously decides which tool to use based on the user's prompt.\n\n*   **Search KB:** Semantic search for general product knowledge & concepts.\n*   **Get Product Details:** Fetches exact specifications by Product ID.\n*   **Get Manual:** Retrieves full text of guides for \"How-To\" tasks.\n*   **Find Image:** Generates an English query to find a relevant stock image URL for the final content.",
        "height": 432,
        "width": 801,
        "color": 5
      },
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        832,
        480
      ],
      "id": "8f3427b9-e708-487b-aab4-009aa8e102eb",
      "name": "Sticky Note 3"
    },
    {
      "parameters": {
        "content": "### 4. Final Output Formatting\n\nTakes the final text (which includes the Markdown formatting and embedded image URL from the tools) and wraps it into a JSON with attribute `message`.\n\nThis is sent back to the webhook trigger as a clean response.",
        "height": 412,
        "width": 301,
        "color": 5
      },
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        1056,
        -80
      ],
      "id": "0ecb8c18-df8e-4739-af2c-d07ac894517e",
      "name": "Sticky Note 4"
    },
    {
      "parameters": {
        "responseMode": "lastNode",
        "options": {}
      },
      "type": "n8n-nodes-agent-brains.integrationTrigger",
      "typeVersion": 1,
      "position": [
        -16,
        176
      ],
      "id": "82df4ea8-4b1f-404f-91f9-599c5bde2107",
      "name": "AgentBrains Integration Trigger",
      "webhookId": "391096d6-0b77-456c-95b8-19f14be2e3ad"
    }
  ],
  "pinData": {},
  "connections": {
    "get_products": {
      "main": [
        [
          {
            "node": "get_manuals",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "AI Agent": {
      "main": [
        [
          {
            "node": "response",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Google Gemini Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "AI Agent",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "search_knowledge_base": {
      "ai_tool": [
        [
          {
            "node": "AI Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "get_product_details": {
      "ai_tool": [
        [
          {
            "node": "AI Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Simple Memory": {
      "ai_memory": [
        [
          {
            "node": "AI Agent",
            "type": "ai_memory",
            "index": 0
          }
        ]
      ]
    },
    "get_manuals": {
      "main": [
        [
          {
            "node": "AI Agent",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "get_manual": {
      "ai_tool": [
        [
          {
            "node": "AI Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "find_relevant_image": {
      "ai_tool": [
        [
          {
            "node": "AI Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "AgentBrains Integration Trigger": {
      "main": [
        [
          {
            "node": "get_products",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "active": true,
  "settings": {
    "executionOrder": "v1",
    "availableInMCP": false
  },
  "versionId": "433977d3-b77a-434a-973e-5819bd4f862b",
  "meta": {
    "instanceId": "3cd2afbf7c8d48879c5fac1fab7c9add61152ad0c0997bde291f08e69f0889e5"
  },
  "id": "5ZEWaQ0zjoC170pk9zVgk",
  "tags": []
}