{
  "meta": {
    "instanceId": "c8c9ba5d3eb26ae47a06d24ff164a01c0d73ed4753a74903c2bb609d434a0f6b",
    "templateCredsSetupCompleted": true
  },
  "nodes": [
    {
      "id": "62cd6216-1bd6-4553-9684-c3a7b2df6fc6",
      "name": "When Chat Message Received from User",
      "type": "@n8n/n8n-nodes-langchain.chatTrigger",
      "position": [
        0,
        0
      ],
      "webhookId": "5ce1ba44-8c43-47bf-85e8-67ecad77b2de",
      "parameters": {
        "options": {}
      },
      "typeVersion": 1.4
    },
    {
      "id": "2f316528-ac2b-4106-a5a3-4a596ee96e98",
      "name": "HubSpot Contact Management Agent",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        208,
        0
      ],
      "parameters": {
        "options": {}
      },
      "typeVersion": 3
    },
    {
      "id": "7b189f06-6351-4cfc-9575-df8c283cc969",
      "name": "OpenAI Chat Model",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "position": [
        80,
        208
      ],
      "parameters": {
        "model": {
          "__rl": true,
          "mode": "list",
          "value": "gpt-5.2",
          "cachedResultName": "gpt-5.2"
        },
        "options": {},
        "builtInTools": {}
      },
      "credentials": {
        "openAiApi": {
          "id": "IscXryYQZrfSUSkH",
          "name": "OpenAi account"
        }
      },
      "typeVersion": 1.3
    },
    {
      "id": "0af6c915-73a7-4383-9c76-7fb16ffb82f3",
      "name": "Chat Conversation Memory",
      "type": "@n8n/n8n-nodes-langchain.memoryBufferWindow",
      "position": [
        224,
        208
      ],
      "parameters": {},
      "typeVersion": 1.3
    },
    {
      "id": "d672b884-00f9-41c1-9593-0a1281848350",
      "name": "Create or update a contact in HubSpot",
      "type": "n8n-nodes-base.hubspotTool",
      "position": [
        608,
        192
      ],
      "parameters": {
        "email": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Email', ``, 'string') }}",
        "options": {},
        "authentication": "appToken",
        "additionalFields": {
          "lastName": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Last_Name', ``, 'string') }}",
          "firstName": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('First_Name', ``, 'string') }}",
          "companyName": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Company_Name', ``, 'string') }}"
        }
      },
      "credentials": {
        "hubspotAppToken": {
          "id": "vQ1hgJJHWpA1Imcz",
          "name": "HubSpot account"
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "3e76b70b-fed5-4437-9457-dca5a0a692f4",
      "name": "Find Contact by Company Name",
      "type": "n8n-nodes-base.hubspotTool",
      "position": [
        464,
        224
      ],
      "parameters": {
        "operation": "search",
        "returnAll": true,
        "authentication": "appToken",
        "filterGroupsUi": {
          "filterGroupsValues": [
            {
              "filtersUi": {
                "filterValues": [
                  {
                    "value": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('filterGroupsValues0_filterValues0_Value', ``, 'string') }}",
                    "operator": "CONTAINS_TOKEN",
                    "propertyName": "company|string"
                  }
                ]
              }
            }
          ]
        },
        "additionalFields": {}
      },
      "credentials": {
        "hubspotAppToken": {
          "id": "vQ1hgJJHWpA1Imcz",
          "name": "HubSpot account"
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "a139f8ad-d7e3-4d84-b6ea-20f71308ece4",
      "name": "Search contacts in HubSpot",
      "type": "n8n-nodes-base.hubspotTool",
      "position": [
        368,
        208
      ],
      "parameters": {
        "operation": "search",
        "returnAll": true,
        "authentication": "appToken",
        "filterGroupsUi": {
          "filterGroupsValues": [
            {
              "filtersUi": {
                "filterValues": [
                  {
                    "value": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('filterGroupsValues0_filterValues0_Value', ``, 'string') }}",
                    "operator": "CONTAINS_TOKEN",
                    "propertyName": "email|string"
                  }
                ]
              }
            }
          ]
        },
        "additionalFields": {}
      },
      "credentials": {
        "hubspotAppToken": {
          "id": "vQ1hgJJHWpA1Imcz",
          "name": "HubSpot account"
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "doc-note-1771263655471",
      "name": "Workflow Description",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -700,
        -150
      ],
      "parameters": {
        "width": 600,
        "height": 829,
        "content": "## Workflow Overview\n\nThis workflow creates an intelligent AI assistant that can manage your HubSpot contacts through natural conversation. Simply chat with the agent to search for contacts, add new leads, or update existing records—no need to navigate the HubSpot interface directly.\n\n### First Setup\n\n**HubSpot Configuration:**\n1. Create a developer account at `developers.hubspot.com`\n2. Navigate to **Legacy Apps** and create a new **private app**\n3. Add the following scopes under the **Scopes** tab:\n   - `crm.objects.contacts.read`\n   - `crm.objects.contacts.write`\n4. Copy the **Access token** from the **Auth** tab\n5. In n8n, create a HubSpot credential using the **APP Token** method and paste your token\n\n**OpenAI Configuration:**\n- Ensure you have an OpenAI API account and valid credentials configured in n8n\n\n### Configuration\n\n- **AI Model**: The workflow uses GPT-5.2, but you can select any compatible OpenAI model based on your needs and budget\n- **HubSpot Tools**: Three tools are configured:\n  - Search contacts by email\n  - Search contacts by company name\n  - Create or update a contact\n- The AI automatically determines which tool to use based on your chat input"
      },
      "typeVersion": 1
    },
    {
      "id": "video-note-1771263723267",
      "name": "Video Walkthrough",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -520,
        -500
      ],
      "parameters": {
        "width": 420,
        "height": 340,
        "content": "# Video Walkthrough\n[![image.png](https://vasarmilan-public.s3.us-east-1.amazonaws.com/blog_thumbnails/thumbnail_reczH8mtRj3GIIRiU.jpg)](https://youtu.be/GBKXYh2j74o)"
      },
      "typeVersion": 1
    }
  ],
  "pinData": {},
  "connections": {
    "OpenAI Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "HubSpot Contact Management Agent",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Chat Conversation Memory": {
      "ai_memory": [
        [
          {
            "node": "HubSpot Contact Management Agent",
            "type": "ai_memory",
            "index": 0
          }
        ]
      ]
    },
    "Search contacts in HubSpot": {
      "ai_tool": [
        [
          {
            "node": "HubSpot Contact Management Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Find Contact by Company Name": {
      "ai_tool": [
        [
          {
            "node": "HubSpot Contact Management Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "When Chat Message Received from User": {
      "main": [
        [
          {
            "node": "HubSpot Contact Management Agent",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Create or update a contact in HubSpot": {
      "ai_tool": [
        [
          {
            "node": "HubSpot Contact Management Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    }
  }
}