{
  "meta": {
    "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
      ],
      "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": {
          "name": "<your credential>"
        }
      },
      "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": {
          "name": "<your credential>"
        }
      },
      "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": {
          "name": "<your credential>"
        }
      },
      "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": {
          "name": "<your credential>"
        }
      },
      "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\u2014no 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": "contact-note-1771263708644",
      "name": "Creator Contact Info",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -700,
        -610
      ],
      "parameters": {
        "color": 5,
        "width": 600,
        "height": 440,
        "content": "# Contact Us:\n## Milan @ SmoothWork - [Book a Free Consulting Call](https://smoothwork.ai/book-a-call/)\n![Milan](https://gravatar.com/avatar/95700d17ba300a9f14c1b8cacf933df7720027b3adda9cbe6183d89142925422?r=pg&d=retro&size=100)\n\n\n### We help businesses eliminate busywork by building compact business tools tailored to your process.\n### Contact us for customizing this, or building similar automations.\n\n\ud83d\udce7 hello@smoothwork.ai\n\u25b6\ufe0f [Check us on YouTube](https://www.youtube.com/@vasarmilan)\n\ud83d\udcde [Book a Free Consulting Call](https://smoothwork.ai/book-a-call/)\n\ud83d\udcbc [Add me on Linkedin](https://www.linkedin.com/in/mil%C3%A1n-v%C3%A1s%C3%A1rhelyi-3a9985123/)\n"
      },
      "typeVersion": 1
    },
    {
      "id": "video-note-1771324743907",
      "name": "Video Walkthrough",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -90,
        -610
      ],
      "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
    }
  ],
  "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
          }
        ]
      ]
    }
  }
}