{
  "name": "CRM_Agent__PA_",
  "nodes": [
    {
      "parameters": {
        "promptType": "define",
        "text": "={{ $json.query }}",
        "options": {
          "systemMessage": "=# Overview\nYou are a contact management assistant. Your responsibilities include looking up contacts, adding new contacts, or updating a contact's information.\n\n**Contact Management**  \n   - Use \"Get Contacts\" to retrieve contact information. \n   - Use \"Add or Update Contact\" to store new contact information or modify existing entries. "
        }
      },
      "type": "@n8n/n8n-nodes-langchain.agent",
      "typeVersion": 1.7,
      "position": [
        -528,
        80
      ],
      "id": "c9957cc6-9b40-46df-baa6-ebcd756e04a2",
      "name": "Contact Agent",
      "onError": "continueErrorOutput"
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "4f360190-a717-4a93-8336-d03ea65975d5",
              "name": "response",
              "value": "={{ $json.output }}",
              "type": "string"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        0,
        0
      ],
      "id": "4992b1fc-ccc3-4f76-8990-26b4c9e871f3",
      "name": "Response"
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "4f360190-a717-4a93-8336-d03ea65975d5",
              "name": "response",
              "value": "An error occurred. Please try again.",
              "type": "string"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        0,
        192
      ],
      "id": "db3d51ae-e135-45e2-b4b7-b37d22e0933a",
      "name": "Try Again1"
    },
    {
      "parameters": {
        "inputSource": "passthrough"
      },
      "type": "n8n-nodes-base.executeWorkflowTrigger",
      "typeVersion": 1.1,
      "position": [
        -816,
        80
      ],
      "id": "29e0b846-8adb-4a44-8eb5-7e456b0ad96c",
      "name": "When Executed by Another Workflow"
    },
    {
      "parameters": {
        "operation": "get",
        "contactId": {
          "__rl": true,
          "mode": "list",
          "value": ""
        },
        "additionalFields": {}
      },
      "type": "n8n-nodes-base.hubspotTool",
      "typeVersion": 2.1,
      "position": [
        -496,
        384
      ],
      "id": "d06e62b6-0928-4b98-aa51-f611ec967346",
      "name": "Get a contact in HubSpot"
    },
    {
      "parameters": {
        "additionalFields": {},
        "options": {}
      },
      "type": "n8n-nodes-base.hubspotTool",
      "typeVersion": 2.1,
      "position": [
        -96,
        400
      ],
      "id": "7bdf015f-0130-4a31-9952-d3a95a54b537",
      "name": "Create or update a contact in HubSpot"
    },
    {
      "parameters": {
        "resource": "company",
        "operation": "get",
        "companyId": {
          "__rl": true,
          "mode": "list",
          "value": ""
        },
        "additionalFields": {}
      },
      "type": "n8n-nodes-base.hubspotTool",
      "typeVersion": 2.1,
      "position": [
        -320,
        432
      ],
      "id": "97a86643-3d2e-4c4f-b43e-efc93f45f847",
      "name": "Get a company in HubSpot"
    },
    {
      "parameters": {
        "model": {
          "__rl": true,
          "value": "gpt-5",
          "mode": "list",
          "cachedResultName": "gpt-5"
        },
        "options": {}
      },
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "typeVersion": 1.2,
      "position": [
        -640,
        304
      ],
      "id": "b6f6a664-9ea7-4989-8b67-d40e9ab46247",
      "name": "OpenAI Chat Model",
      "credentials": {
        "openAiApi": {
          "name": "<your credential>"
        }
      }
    }
  ],
  "connections": {
    "Contact Agent": {
      "main": [
        [
          {
            "node": "Response",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Try Again1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "When Executed by Another Workflow": {
      "main": [
        [
          {
            "node": "Contact Agent",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get a contact in HubSpot": {
      "ai_tool": [
        [
          {
            "node": "Contact Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Create or update a contact in HubSpot": {
      "ai_tool": [
        [
          {
            "node": "Contact Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Get a company in HubSpot": {
      "ai_tool": [
        [
          {
            "node": "Contact Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "Contact Agent",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    }
  },
  "active": false,
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "6230fbff-e879-463b-a032-ea787b963b46",
  "id": "xRBjTuJfhezlYg9X",
  "tags": [
    {
      "createdAt": "2025-08-12T15:50:45.123Z",
      "updatedAt": "2025-08-12T15:50:45.123Z",
      "id": "eOQkkG3KUt3wYBV4",
      "name": "AI Personal Assistant"
    }
  ]
}