{
  "name": "GHL AI Agent — CRM assistant (abuusof.com)",
  "nodes": [
    {
      "parameters": {
        "options": {}
      },
      "id": "5b5a6e54-5555-4e05-5a05-e5f6a7b8c901",
      "name": "When chat message received",
      "type": "@n8n/n8n-nodes-langchain.chatTrigger",
      "typeVersion": 1.1,
      "position": [0, 0],
      "webhookId": "ghl-agent-chat"
    },
    {
      "parameters": {
        "options": {
          "systemMessage": "You are the CRM assistant for a small business using GoHighLevel. You can look up contacts and tag them using your tools. Rules: 1) Always look up the contact before answering questions about them. 2) Never invent contact data — if the lookup returns nothing, say so. 3) You may add tags when asked, but never delete or modify anything else. 4) Keep answers short and factual."
        }
      },
      "id": "5b5a6e54-5555-4e05-5a05-e5f6a7b8c902",
      "name": "AI Agent",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "typeVersion": 1.7,
      "position": [260, 0]
    },
    {
      "parameters": {
        "model": {
          "__rl": true,
          "value": "gpt-4o-mini",
          "mode": "list"
        },
        "options": {}
      },
      "id": "5b5a6e54-5555-4e05-5a05-e5f6a7b8c903",
      "name": "OpenAI Chat Model",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "typeVersion": 1.2,
      "position": [140, 220]
    },
    {
      "parameters": {},
      "id": "5b5a6e54-5555-4e05-5a05-e5f6a7b8c904",
      "name": "Window Buffer Memory",
      "type": "@n8n/n8n-nodes-langchain.memoryBufferWindow",
      "typeVersion": 1.3,
      "position": [320, 220]
    },
    {
      "parameters": {
        "toolDescription": "Search GoHighLevel contacts by name, email or phone. Input: the search text. Returns matching contacts with their id, name, email, phone and tags.",
        "method": "GET",
        "url": "https://services.leadconnectorhq.com/contacts/",
        "sendQuery": true,
        "queryParameters": {
          "parameters": [
            { "name": "locationId", "value": "YOUR_LOCATION_ID" },
            { "name": "query", "value": "={placeholder}" }
          ]
        },
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            { "name": "Authorization", "value": "Bearer YOUR_PRIVATE_INTEGRATION_TOKEN" },
            { "name": "Version", "value": "2021-07-28" }
          ]
        },
        "placeholderDefinitions": {
          "values": [
            { "name": "placeholder", "description": "The name, email or phone number to search for" }
          ]
        }
      },
      "id": "5b5a6e54-5555-4e05-5a05-e5f6a7b8c905",
      "name": "Search GHL contacts",
      "type": "@n8n/n8n-nodes-langchain.toolHttpRequest",
      "typeVersion": 1.1,
      "position": [500, 220]
    },
    {
      "parameters": {
        "toolDescription": "Add a tag to a GoHighLevel contact. Inputs: contactId (from a previous search) and the tag to add.",
        "method": "POST",
        "url": "https://services.leadconnectorhq.com/contacts/{contactId}/tags",
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "{ \"tags\": [\"{tag}\"] }",
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            { "name": "Authorization", "value": "Bearer YOUR_PRIVATE_INTEGRATION_TOKEN" },
            { "name": "Version", "value": "2021-07-28" },
            { "name": "Content-Type", "value": "application/json" }
          ]
        },
        "placeholderDefinitions": {
          "values": [
            { "name": "contactId", "description": "The GHL contact id" },
            { "name": "tag", "description": "The tag to add, e.g. hot-lead" }
          ]
        }
      },
      "id": "5b5a6e54-5555-4e05-5a05-e5f6a7b8c906",
      "name": "Add tag to contact",
      "type": "@n8n/n8n-nodes-langchain.toolHttpRequest",
      "typeVersion": 1.1,
      "position": [680, 220]
    }
  ],
  "connections": {
    "When chat message received": { "main": [[{ "node": "AI Agent", "type": "main", "index": 0 }]] },
    "OpenAI Chat Model": { "ai_languageModel": [[{ "node": "AI Agent", "type": "ai_languageModel", "index": 0 }]] },
    "Window Buffer Memory": { "ai_memory": [[{ "node": "AI Agent", "type": "ai_memory", "index": 0 }]] },
    "Search GHL contacts": { "ai_tool": [[{ "node": "AI Agent", "type": "ai_tool", "index": 0 }]] },
    "Add tag to contact": { "ai_tool": [[{ "node": "AI Agent", "type": "ai_tool", "index": 0 }]] }
  },
  "pinData": {},
  "settings": { "executionOrder": "v1" },
  "meta": {
    "notes": "Add your OpenAI credential to the model node, replace YOUR_PRIVATE_INTEGRATION_TOKEN (scopes: contacts.readonly + contacts.write for tags only) and YOUR_LOCATION_ID. Test in the n8n chat panel: 'find jane@example.com and tag her hot-lead'. From abuusof.com/n8n-ai-agent-gohighlevel/"
  }
}
