{
  "nodes": [
    {
      "id": "e341815b-dceb-4904-85a9-dd69e206ad47",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1744,
        256
      ],
      "parameters": {
        "width": 480,
        "height": 896,
        "content": "## AI WhatsApp Sales Chatbot Template\n\n### How it works\n\nThis workflow acts as an AI-powered WhatsApp sales assistant. It receives inbound WhatsApp messages, filters them, uses an AI agent with CRM, memory, product catalog, and company profile context to craft a response, then logs the chat and replies to the customer.\n\n### Setup steps\n\n- Configure WhatsApp trigger and send-message credentials, including the correct business phone number and webhook settings.\n- Connect Google Gemini credentials for the chat model used by the AI agent.\n- Connect HubSpot credentials so the agent can search, create, or update contacts.\n- Connect Google Sheets credentials and select the spreadsheet used for the product catalog and chat log.\n- Connect Google Docs credentials and point the company profile tool to the correct document.\n\n### Customization\n\nUpdate the agent prompt, product catalog sheet, company profile document, and chat log columns to match your sales process, product details, and CRM data requirements."
      },
      "typeVersion": 1
    },
    {
      "id": "a8395cab-f16b-4c81-94d5-c00f670d9dd2",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        2304,
        576
      ],
      "parameters": {
        "color": 7,
        "width": 464,
        "height": 320,
        "content": "## WhatsApp intake filter\n\nReceives incoming WhatsApp messages and filters them so only valid inbound customer messages continue into the sales chatbot flow."
      },
      "typeVersion": 1
    },
    {
      "id": "1c4180b7-c395-4ffb-917e-d0a28e37534e",
      "name": "Sticky Note2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        2800,
        608
      ],
      "parameters": {
        "color": 7,
        "width": 992,
        "height": 560,
        "content": "## AI sales agent\n\nUses Gemini, short-term memory, HubSpot contact tools, and company/product knowledge sources to generate a context-aware sales response and manage customer details."
      },
      "typeVersion": 1
    },
    {
      "id": "61cbc4d6-8b53-43a8-b0fe-56f50c8d171c",
      "name": "Sticky Note3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        3920,
        576
      ],
      "parameters": {
        "color": 7,
        "width": 400,
        "height": 320,
        "content": "## Log and reply\n\nRecords the conversation outcome in Google Sheets, then sends the AI-generated response back to the customer through WhatsApp."
      },
      "typeVersion": 1
    },
    {
      "id": "0bc56d7c-2200-444b-9c12-8b8bc1527203",
      "name": "Filter Incoming Messages",
      "type": "n8n-nodes-base.filter",
      "position": [
        2624,
        736
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 3,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "loose"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "7149dde6-d320-4826-9f96-0cd5134c32ee",
              "operator": {
                "type": "array",
                "operation": "notEmpty",
                "singleValue": true
              },
              "leftValue": "={{ $json.messages }}",
              "rightValue": ""
            }
          ]
        },
        "looseTypeValidation": true
      },
      "typeVersion": 2.3
    },
    {
      "id": "868c4105-b900-4224-8b8a-b169dd9bee63",
      "name": "Memory Buffer",
      "type": "@n8n/n8n-nodes-langchain.memoryBufferWindow",
      "position": [
        3312,
        1008
      ],
      "parameters": {
        "sessionKey": "={{ $json.contacts[0].wa_id }}",
        "sessionIdType": "customKey"
      },
      "typeVersion": 1.4
    },
    {
      "id": "c9bba5f2-1c40-4f5a-b398-903b1dcd753f",
      "name": "Google Gemini Chatbot",
      "type": "@n8n/n8n-nodes-langchain.lmChatGoogleGemini",
      "position": [
        3152,
        1008
      ],
      "parameters": {
        "options": {}
      },
      "credentials": {
        "googlePalmApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.1
    },
    {
      "id": "8b2a94eb-9fba-415d-8f2f-5b67fba5de3f",
      "name": "Search HubSpot Contacts",
      "type": "n8n-nodes-base.hubspotTool",
      "position": [
        3472,
        1008
      ],
      "parameters": {
        "operation": "search",
        "authentication": "oAuth2",
        "filterGroupsUi": {
          "filterGroupsValues": [
            {
              "filtersUi": {
                "filterValues": [
                  {
                    "value": "={{ $json.contacts[0].wa_id }}"
                  }
                ]
              }
            }
          ]
        },
        "additionalFields": {}
      },
      "credentials": {
        "hubspotOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "652ef3eb-be3f-4d14-8b64-49b21b397d01",
      "name": "Manage HubSpot Contact",
      "type": "n8n-nodes-base.hubspotTool",
      "position": [
        3632,
        1008
      ],
      "parameters": {
        "email": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('email', 'Customer email address') }}",
        "options": {},
        "authentication": "oAuth2",
        "additionalFields": {
          "lastName": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Last_Name', ``, 'string') }}",
          "firstName": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('First_Name', ``, 'string') }}",
          "phoneNumber": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Phone_Number', ``, 'string') }}"
        }
      },
      "credentials": {
        "hubspotOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "188978d1-7c6b-480f-932e-1ff28568c09c",
      "name": "Retrieve Product Catalog",
      "type": "n8n-nodes-base.googleSheetsTool",
      "position": [
        3792,
        1008
      ],
      "parameters": {
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": "",
          "cachedResultUrl": "",
          "cachedResultName": ""
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": "",
          "cachedResultUrl": "",
          "cachedResultName": ""
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4.7
    },
    {
      "id": "5cff210e-4003-4141-991c-e3c17ad9077f",
      "name": "Fetch Company Profile",
      "type": "n8n-nodes-base.googleDocsTool",
      "position": [
        3968,
        1008
      ],
      "parameters": {
        "operation": "get",
        "documentURL": "url"
      },
      "credentials": {
        "googleDocsOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 2
    },
    {
      "id": "0b267153-b29a-4192-9557-0d1b25230879",
      "name": "Append to Chat Log in Sheets",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        3968,
        736
      ],
      "parameters": {
        "operation": "append",
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": "",
          "cachedResultUrl": "",
          "cachedResultName": ""
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": "",
          "cachedResultUrl": "",
          "cachedResultName": ""
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4.7
    },
    {
      "id": "90e0546c-c9e4-4273-8483-86029e04ac70",
      "name": "Sales Chatbot Agent",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        3200,
        736
      ],
      "parameters": {
        "text": "={{ $('WhatsApp Message Trigger').item.json.messages[0].text.body }}",
        "options": {
          "systemMessage": "# Role & Identity\nYou are a warm, consultative Sales Representative for BrightPath, interacting with customers on WhatsApp.\n\n# Core Directive\nGuide customers and answer inquiries using **EXCLUSIVELY** information retrieved from internal tools. Never invent details, guess prices, or assume policies.\n\n# Tools\n* `Get Company Profile`: Business overview, policies, FAQs, and general info.\n* `Get Product Catalog`: Product details, specs, stock availability, and pricing.\n* `Search Contacts in HubSpot`: Look up CRM records via phone number or WhatsApp ID.\n* `Create or Update Contact in HubSpot`: Add new customer entries or update existing CRM fields.\n\n# Standard Operating Procedure (SOP)\nExecute these steps internally before delivering your final message:\n1. **Identify & Sync:** Search for the customer in HubSpot using their WhatsApp ID/phone number. Create or update their profile with any new information.\n2. **Analyze Intent:** Identify what the customer is asking for or looking to buy.\n3. **Fetch Data:** Query `Get Product Catalog` for matching items and `Get Company Profile` for applicable store policies or FAQs.\n4. **Compose Message:** Synthesize the retrieved tool data into a WhatsApp-friendly reply.\n\n# Communication Guidelines (WhatsApp Style)\n* **Tone:** Helpful, professional, and warm.\n* **Formatting:** Keep paragraphs short (1\u20133 sentences). Use **bold text** sparingly for product names, key features, or prices.\n* **Emojis:** Include 1\u20133 tasteful emojis per message (e.g., \ud83d\udc4b, \u2728, \ud83d\udce6) to maintain a modern, friendly vibe.\n* **Missing Data:** If tools yield no answer, say: *\"I don't have those specific details on hand right now, but I can double-check with our team for you! \ud83d\udc4b\"*\n\n# Strict Constraints\n* **NO Internal Thoughts:** Do NOT output reasoning, tool execution logs, or preamble. Return ONLY the final message to be sent to the customer.\n* **NO Data Invention:** Every product detail, price, and policy mentioned MUST originate from a tool response."
        },
        "promptType": "define"
      },
      "typeVersion": 3.1
    },
    {
      "id": "8c7db20d-ab84-4714-9ac8-c188e72582c3",
      "name": "WhatsApp Message Trigger",
      "type": "n8n-nodes-base.whatsAppTrigger",
      "position": [
        2352,
        736
      ],
      "parameters": {
        "options": {},
        "updates": [
          "messages"
        ]
      },
      "credentials": {
        "whatsAppTriggerApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "1295585c-736e-48da-85fc-4d302acf827d",
      "name": "Send WhatsApp Reply",
      "type": "n8n-nodes-base.whatsApp",
      "position": [
        4176,
        736
      ],
      "parameters": {
        "textBody": "={{ $('Sales Chatbot Agent').item.json.output }}",
        "operation": "send",
        "phoneNumberId": "=",
        "additionalFields": {},
        "recipientPhoneNumber": "={{ $('Filter Incoming Messages').item.json.contacts[0].wa_id }}"
      },
      "credentials": {
        "whatsAppApi": {
          "name": "<your credential>"
        }
      },
      "executeOnce": false,
      "typeVersion": 1.1
    }
  ],
  "connections": {
    "Memory Buffer": {
      "ai_memory": [
        [
          {
            "node": "Sales Chatbot Agent",
            "type": "ai_memory",
            "index": 0
          }
        ]
      ]
    },
    "Sales Chatbot Agent": {
      "main": [
        [
          {
            "node": "Append to Chat Log in Sheets",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Fetch Company Profile": {
      "ai_tool": [
        [
          {
            "node": "Sales Chatbot Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Google Gemini Chatbot": {
      "ai_languageModel": [
        [
          {
            "node": "Sales Chatbot Agent",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Manage HubSpot Contact": {
      "ai_tool": [
        [
          {
            "node": "Sales Chatbot Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Search HubSpot Contacts": {
      "ai_tool": [
        [
          {
            "node": "Sales Chatbot Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Filter Incoming Messages": {
      "main": [
        [
          {
            "node": "Sales Chatbot Agent",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Retrieve Product Catalog": {
      "ai_tool": [
        [
          {
            "node": "Sales Chatbot Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "WhatsApp Message Trigger": {
      "main": [
        [
          {
            "node": "Filter Incoming Messages",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Append to Chat Log in Sheets": {
      "main": [
        [
          {
            "node": "Send WhatsApp Reply",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}