{
  "name": "AI sales assistant: answer enquiries from your services sheet and log every lead",
  "nodes": [
    {
      "parameters": {
        "content": "## AI sales assistant\nA simplified version of the agent behind sixsol.co.uk/work/ai-sales-assistant/.\nPOST {\"message\", \"email\", \"name\"} to the webhook; the agent answers from your Services sheet and the lead is logged.\n1. Connect your chat model and Google Sheets\n2. Create sheets: Services, Leads\n\nBuilt by SixSol Technologies · sixsol.co.uk",
        "height": 320,
        "width": 460
      },
      "id": "d90edebc-a7a5-548b-bef2-02c6d14ad8d2",
      "name": "Read me",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        -100,
        -320
      ]
    },
    {
      "parameters": {
        "httpMethod": "POST",
        "path": "sales-enquiry",
        "responseMode": "responseNode",
        "options": {}
      },
      "id": "50973132-b656-51c1-82ea-9e2a4f363308",
      "name": "Enquiry webhook",
      "type": "n8n-nodes-base.webhook",
      "typeVersion": 2,
      "position": [
        0,
        80
      ],
      "webhookId": "9b9d912e-d428-5b9e-b80b-82a5dfa4f9e7"
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "loose"
          },
          "conditions": [
            {
              "id": "c1",
              "leftValue": "={{ ($json.body.message || '').length }}",
              "rightValue": 2,
              "operator": {
                "type": "number",
                "operation": "gt"
              }
            }
          ],
          "combinator": "and"
        },
        "options": {}
      },
      "id": "b3e36ffd-78da-5a5f-ac2f-c3f2f983e645",
      "name": "Has message?",
      "type": "n8n-nodes-base.if",
      "typeVersion": 2,
      "position": [
        200,
        80
      ]
    },
    {
      "parameters": {
        "promptType": "define",
        "text": "={{ $json.body.message }}",
        "options": {
          "systemMessage": "You are a helpful sales assistant for YOUR COMPANY. Use the services tool for offers and prices. Ask one qualifying question (budget, timeline or use case). Never invent prices."
        }
      },
      "id": "fa327bd3-8ca9-5d74-a4e1-f787e387f2d1",
      "name": "Sales agent",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "typeVersion": 1.7,
      "position": [
        440,
        0
      ]
    },
    {
      "parameters": {
        "model": {
          "__rl": true,
          "mode": "list",
          "value": "gpt-4o-mini"
        },
        "options": {}
      },
      "id": "59d9a968-9391-51fb-b61c-138e3ac63aa5",
      "name": "Chat model",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "typeVersion": 1.2,
      "position": [
        340,
        220
      ]
    },
    {
      "parameters": {
        "sessionIdType": "customKey",
        "sessionKey": "={{ $('Enquiry webhook').item.json.body.email || 'anonymous' }}",
        "contextWindowLength": 10
      },
      "id": "99c120f4-8c5b-5cd3-9244-c0b7dad50b27",
      "name": "Memory",
      "type": "@n8n/n8n-nodes-langchain.memoryBufferWindow",
      "typeVersion": 1.3,
      "position": [
        480,
        220
      ]
    },
    {
      "parameters": {
        "descriptionType": "manual",
        "toolDescription": "List of services with descriptions and starting prices.",
        "documentId": {
          "__rl": true,
          "mode": "url",
          "value": "https://docs.google.com/spreadsheets/d/YOUR_SHEET_ID/edit"
        },
        "sheetName": {
          "__rl": true,
          "mode": "name",
          "value": "Services"
        },
        "options": {}
      },
      "id": "f2b7049f-0da6-5d9b-9a9f-b3a73100331c",
      "name": "Services sheet",
      "type": "n8n-nodes-base.googleSheetsTool",
      "typeVersion": 4.5,
      "position": [
        620,
        220
      ]
    },
    {
      "parameters": {
        "operation": "appendOrUpdate",
        "documentId": {
          "__rl": true,
          "mode": "url",
          "value": "https://docs.google.com/spreadsheets/d/YOUR_SHEET_ID/edit"
        },
        "sheetName": {
          "__rl": true,
          "mode": "name",
          "value": "Leads"
        },
        "columns": {
          "mappingMode": "defineBelow",
          "value": {
            "email": "={{ $('Enquiry webhook').item.json.body.email }}",
            "name": "={{ $('Enquiry webhook').item.json.body.name }}",
            "last_message": "={{ $('Enquiry webhook').item.json.body.message }}",
            "last_reply": "={{ $json.output }}",
            "updated_at": "={{ $now.toISO() }}"
          },
          "matchingColumns": [
            "email"
          ],
          "schema": []
        },
        "options": {}
      },
      "id": "e8028f42-da57-5167-a609-e6f73b586d1b",
      "name": "Log lead",
      "type": "n8n-nodes-base.googleSheets",
      "typeVersion": 4.5,
      "position": [
        780,
        0
      ]
    },
    {
      "parameters": {
        "respondWith": "json",
        "responseBody": "={{ JSON.stringify({ reply: $('Sales agent').item.json.output }) }}",
        "options": {}
      },
      "id": "c799078c-473f-5fbf-9792-ac9a887f6967",
      "name": "Reply",
      "type": "n8n-nodes-base.respondToWebhook",
      "typeVersion": 1.1,
      "position": [
        1000,
        0
      ]
    },
    {
      "parameters": {
        "respondWith": "json",
        "responseBody": "={\"error\": \"message is required\"}",
        "options": {
          "responseCode": 400
        }
      },
      "id": "99344ae1-988a-5edf-8dd2-d0313d8569e3",
      "name": "Reply error",
      "type": "n8n-nodes-base.respondToWebhook",
      "typeVersion": 1.1,
      "position": [
        440,
        380
      ]
    }
  ],
  "connections": {
    "Enquiry webhook": {
      "main": [
        [
          {
            "node": "Has message?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Has message?": {
      "main": [
        [
          {
            "node": "Sales agent",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Reply error",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Sales agent": {
      "main": [
        [
          {
            "node": "Log lead",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Log lead": {
      "main": [
        [
          {
            "node": "Reply",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Chat model": {
      "ai_languageModel": [
        [
          {
            "node": "Sales agent",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Memory": {
      "ai_memory": [
        [
          {
            "node": "Sales agent",
            "type": "ai_memory",
            "index": 0
          }
        ]
      ]
    },
    "Services sheet": {
      "ai_tool": [
        [
          {
            "node": "Sales agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    }
  },
  "active": false,
  "settings": {
    "executionOrder": "v1"
  },
  "pinData": {},
  "meta": {
    "templateCredsSetupCompleted": false,
    "templateBy": "SixSol Technologies · https://www.sixsol.co.uk/n8n-templates/"
  },
  "tags": []
}