{
  "name": "REVOPS-LI-007 | 06 | HubSpot proposal recovery property setup",
  "nodes": [
    {
      "parameters": {},
      "id": "0e9890b0-8738-4a3f-91d6-af9ddc61bfbb",
      "name": "Setup Deal Properties",
      "type": "n8n-nodes-base.manualTrigger",
      "typeVersion": 1,
      "position": [
        0,
        0
      ]
    },
    {
      "parameters": {
        "mode": "runOnceForAllItems",
        "jsCode": "return [{\"name\":\"revops_proposal_sent_at\",\"label\":\"RevOps Proposal Sent At\",\"type\":\"datetime\",\"fieldType\":\"date\",\"groupName\":\"dealinformation\",\"description\":\"REVOPS-LI-007 proposal recovery\"},{\"name\":\"revops_proposal_status\",\"label\":\"RevOps Proposal Status\",\"type\":\"enumeration\",\"fieldType\":\"select\",\"groupName\":\"dealinformation\",\"description\":\"REVOPS-LI-007 proposal recovery\",\"options\":[{\"label\":\"SENT\",\"value\":\"SENT\",\"displayOrder\":0,\"hidden\":false},{\"label\":\"VIEWED\",\"value\":\"VIEWED\",\"displayOrder\":1,\"hidden\":false},{\"label\":\"ACCEPTED\",\"value\":\"ACCEPTED\",\"displayOrder\":2,\"hidden\":false},{\"label\":\"DECLINED\",\"value\":\"DECLINED\",\"displayOrder\":3,\"hidden\":false},{\"label\":\"EXPIRED\",\"value\":\"EXPIRED\",\"displayOrder\":4,\"hidden\":false}]},{\"name\":\"revops_proposal_link\",\"label\":\"RevOps Proposal Link\",\"type\":\"string\",\"fieldType\":\"text\",\"groupName\":\"dealinformation\",\"description\":\"REVOPS-LI-007 proposal recovery\"},{\"name\":\"revops_proposal_value\",\"label\":\"RevOps Proposal Value\",\"type\":\"number\",\"fieldType\":\"number\",\"groupName\":\"dealinformation\",\"description\":\"REVOPS-LI-007 proposal recovery\"},{\"name\":\"revops_proposal_summary\",\"label\":\"Proposal Summary\",\"type\":\"string\",\"fieldType\":\"textarea\",\"groupName\":\"dealinformation\",\"description\":\"REVOPS-LI-007 proposal recovery\"},{\"name\":\"revops_service_proposed\",\"label\":\"Service or Product Proposed\",\"type\":\"string\",\"fieldType\":\"textarea\",\"groupName\":\"dealinformation\",\"description\":\"REVOPS-LI-007 proposal recovery\"},{\"name\":\"revops_main_pain_point\",\"label\":\"Main Pain Point\",\"type\":\"string\",\"fieldType\":\"textarea\",\"groupName\":\"dealinformation\",\"description\":\"REVOPS-LI-007 proposal recovery\"},{\"name\":\"revops_expected_next_step\",\"label\":\"Expected Next Step\",\"type\":\"string\",\"fieldType\":\"textarea\",\"groupName\":\"dealinformation\",\"description\":\"REVOPS-LI-007 proposal recovery\"},{\"name\":\"revops_salesperson_notes\",\"label\":\"Salesperson Notes\",\"type\":\"string\",\"fieldType\":\"textarea\",\"groupName\":\"dealinformation\",\"description\":\"REVOPS-LI-007 proposal recovery\"},{\"name\":\"revops_previous_objections\",\"label\":\"Previous Objections\",\"type\":\"string\",\"fieldType\":\"textarea\",\"groupName\":\"dealinformation\",\"description\":\"REVOPS-LI-007 proposal recovery\"},{\"name\":\"revops_past_communication_summary\",\"label\":\"Past Communication Summary\",\"type\":\"string\",\"fieldType\":\"textarea\",\"groupName\":\"dealinformation\",\"description\":\"REVOPS-LI-007 proposal recovery\"},{\"name\":\"revops_salesperson_name\",\"label\":\"Salesperson Name\",\"type\":\"string\",\"fieldType\":\"textarea\",\"groupName\":\"dealinformation\",\"description\":\"REVOPS-LI-007 proposal recovery\"},{\"name\":\"revops_proposal_channel\",\"label\":\"Proposal Channel\",\"type\":\"enumeration\",\"fieldType\":\"select\",\"groupName\":\"dealinformation\",\"description\":\"REVOPS-LI-007 proposal recovery\",\"options\":[{\"label\":\"email\",\"value\":\"email\",\"displayOrder\":0,\"hidden\":false},{\"label\":\"crm email\",\"value\":\"crm email\",\"displayOrder\":1,\"hidden\":false},{\"label\":\"linkedin\",\"value\":\"linkedin\",\"displayOrder\":2,\"hidden\":false},{\"label\":\"whatsapp\",\"value\":\"whatsapp\",\"displayOrder\":3,\"hidden\":false},{\"label\":\"sms\",\"value\":\"sms\",\"displayOrder\":4,\"hidden\":false},{\"label\":\"manual\",\"value\":\"manual\",\"displayOrder\":5,\"hidden\":false}]},{\"name\":\"revops_ghosting_status\",\"label\":\"Proposal Ghosting Status\",\"type\":\"enumeration\",\"fieldType\":\"select\",\"groupName\":\"dealinformation\",\"description\":\"REVOPS-LI-007 proposal recovery\",\"options\":[{\"label\":\"READY\",\"value\":\"READY\",\"displayOrder\":0,\"hidden\":false},{\"label\":\"APPROVAL_PENDING\",\"value\":\"APPROVAL_PENDING\",\"displayOrder\":1,\"hidden\":false},{\"label\":\"MANUAL_REVIEW\",\"value\":\"MANUAL_REVIEW\",\"displayOrder\":2,\"hidden\":false},{\"label\":\"SENDING\",\"value\":\"SENDING\",\"displayOrder\":3,\"hidden\":false},{\"label\":\"FOLLOWED_UP\",\"value\":\"FOLLOWED_UP\",\"displayOrder\":4,\"hidden\":false},{\"label\":\"RE_ENGAGED\",\"value\":\"RE_ENGAGED\",\"displayOrder\":5,\"hidden\":false},{\"label\":\"RECENT_ACTIVITY_FOUND\",\"value\":\"RECENT_ACTIVITY_FOUND\",\"displayOrder\":6,\"hidden\":false},{\"label\":\"MISSING_PROPOSAL_DATE\",\"value\":\"MISSING_PROPOSAL_DATE\",\"displayOrder\":7,\"hidden\":false}]},{\"name\":\"revops_followup_status\",\"label\":\"Proposal Follow-Up Status\",\"type\":\"enumeration\",\"fieldType\":\"select\",\"groupName\":\"dealinformation\",\"description\":\"REVOPS-LI-007 proposal recovery\",\"options\":[{\"label\":\"DRAFTED\",\"value\":\"DRAFTED\",\"displayOrder\":0,\"hidden\":false},{\"label\":\"APPROVAL_PENDING\",\"value\":\"APPROVAL_PENDING\",\"displayOrder\":1,\"hidden\":false},{\"label\":\"SENT\",\"value\":\"SENT\",\"displayOrder\":2,\"hidden\":false},{\"label\":\"REPLIED\",\"value\":\"REPLIED\",\"displayOrder\":3,\"hidden\":false},{\"label\":\"MANUAL_TASK\",\"value\":\"MANUAL_TASK\",\"displayOrder\":4,\"hidden\":false},{\"label\":\"FAILED\",\"value\":\"FAILED\",\"displayOrder\":5,\"hidden\":false}]},{\"name\":\"revops_followup_sent_at\",\"label\":\"revops_followup_sent_at\",\"type\":\"datetime\",\"fieldType\":\"date\",\"groupName\":\"dealinformation\",\"description\":\"REVOPS-LI-007 proposal recovery\"},{\"name\":\"revops_last_automated_followup_at\",\"label\":\"revops_last_automated_followup_at\",\"type\":\"datetime\",\"fieldType\":\"date\",\"groupName\":\"dealinformation\",\"description\":\"REVOPS-LI-007 proposal recovery\"},{\"name\":\"revops_next_review_at\",\"label\":\"revops_next_review_at\",\"type\":\"datetime\",\"fieldType\":\"date\",\"groupName\":\"dealinformation\",\"description\":\"REVOPS-LI-007 proposal recovery\"},{\"name\":\"revops_reply_detected_at\",\"label\":\"revops_reply_detected_at\",\"type\":\"datetime\",\"fieldType\":\"date\",\"groupName\":\"dealinformation\",\"description\":\"REVOPS-LI-007 proposal recovery\"},{\"name\":\"revops_last_reply_at\",\"label\":\"revops_last_reply_at\",\"type\":\"datetime\",\"fieldType\":\"date\",\"groupName\":\"dealinformation\",\"description\":\"REVOPS-LI-007 proposal recovery\"},{\"name\":\"revops_reply_detected\",\"label\":\"revops_reply_detected\",\"type\":\"bool\",\"fieldType\":\"booleancheckbox\",\"groupName\":\"dealinformation\",\"description\":\"REVOPS-LI-007 proposal recovery\",\"options\":[{\"label\":\"true\",\"value\":\"true\",\"displayOrder\":0,\"hidden\":false},{\"label\":\"false\",\"value\":\"false\",\"displayOrder\":1,\"hidden\":false}]},{\"name\":\"revops_manual_action_required\",\"label\":\"revops_manual_action_required\",\"type\":\"bool\",\"fieldType\":\"booleancheckbox\",\"groupName\":\"dealinformation\",\"description\":\"REVOPS-LI-007 proposal recovery\",\"options\":[{\"label\":\"true\",\"value\":\"true\",\"displayOrder\":0,\"hidden\":false},{\"label\":\"false\",\"value\":\"false\",\"displayOrder\":1,\"hidden\":false}]},{\"name\":\"revops_followup_channel\",\"label\":\"Follow-Up Channel\",\"type\":\"string\",\"fieldType\":\"text\",\"groupName\":\"dealinformation\",\"description\":\"REVOPS-LI-007 proposal recovery\"},{\"name\":\"revops_followup_message\",\"label\":\"Follow-Up Message\",\"type\":\"string\",\"fieldType\":\"textarea\",\"groupName\":\"dealinformation\",\"description\":\"REVOPS-LI-007 proposal recovery\"},{\"name\":\"revops_followup_run_id\",\"label\":\"Follow-Up Run ID\",\"type\":\"string\",\"fieldType\":\"text\",\"groupName\":\"dealinformation\",\"description\":\"REVOPS-LI-007 proposal recovery\"},{\"name\":\"revops_reply_summary\",\"label\":\"Reply Summary\",\"type\":\"string\",\"fieldType\":\"textarea\",\"groupName\":\"dealinformation\",\"description\":\"REVOPS-LI-007 proposal recovery\"}].map(property=>({json:{property}}));"
      },
      "id": "f7fa8638-7f0f-435b-8652-0af73af2ee97",
      "name": "Definitions",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        270,
        0
      ]
    },
    {
      "parameters": {
        "method": "GET",
        "url": "={{ 'https://api.hubapi.com/crm/v3/properties/deals/'+$json.property.name }}",
        "authentication": "genericCredentialType",
        "genericAuthType": "httpHeaderAuth",
        "options": {
          "timeout": 30000,
          "response": {
            "response": {
              "fullResponse": true,
              "neverError": true,
              "responseFormat": "json"
            }
          }
        }
      },
      "id": "fc013cc1-f37a-4823-89e5-a5c5658f7153",
      "name": "Read Deal Property",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        540,
        0
      ],
      "credentials": {
        "httpHeaderAuth": {
          "id": "REPLACE_HUBSPOT_CREDENTIAL",
          "name": "ATTRIBUTION HubSpot"
        }
      }
    },
    {
      "parameters": {
        "mode": "runOnceForAllItems",
        "jsCode": "const defs=$('Definitions').all();return $input.all().map((item,i)=>{const p=defs[i].json.property,r=item.json;if(![200,404].includes(r.statusCode))throw new Error('Property lookup failed '+p.name);if(r.statusCode===200&&(r.body.type!==p.type||r.body.fieldType!==p.fieldType))throw new Error('Incompatible property '+p.name);return {json:{property:p,missing:r.statusCode===404},pairedItem:{item:i}}});"
      },
      "id": "2bc1af9f-383d-4771-9a2a-f4c42d115d35",
      "name": "Check Property Compatibility",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        810,
        0
      ]
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "strict",
            "version": 2
          },
          "conditions": [
            {
              "id": "e6fa57c4-5237-4962-9c68-61b685cea974",
              "leftValue": "={{ $json.missing === true }}",
              "rightValue": true,
              "operator": {
                "type": "boolean",
                "operation": "true",
                "singleValue": true
              }
            }
          ],
          "combinator": "and"
        },
        "options": {}
      },
      "id": "02d959c7-7d42-408b-9c94-b96db32ae6ea",
      "name": "Property Missing?",
      "type": "n8n-nodes-base.if",
      "typeVersion": 2.2,
      "position": [
        1080,
        0
      ]
    },
    {
      "parameters": {
        "method": "POST",
        "url": "https://api.hubapi.com/crm/v3/properties/deals",
        "authentication": "genericCredentialType",
        "genericAuthType": "httpHeaderAuth",
        "sendBody": true,
        "contentType": "json",
        "specifyBody": "json",
        "jsonBody": "={{ $json.property }}",
        "options": {
          "timeout": 30000
        }
      },
      "id": "d482a8b5-4b6f-4366-be9a-74c6290fca2e",
      "name": "Create Deal Property",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        1350,
        0
      ],
      "credentials": {
        "httpHeaderAuth": {
          "id": "REPLACE_HUBSPOT_CREDENTIAL",
          "name": "ATTRIBUTION HubSpot"
        }
      }
    },
    {
      "parameters": {
        "content": "## One-time HubSpot setup\nCreates missing REVOPS-LI-007 deal properties and refuses incompatible existing definitions.\nMap the proposal-sending process to populate proposal sent date, channel, context, and salesperson fields before activating the scanner.",
        "width": 700,
        "height": 220
      },
      "id": "1a62ba8d-45fc-461a-a53a-b3916b0e87b5",
      "name": "Workflow Guide",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        0,
        -270
      ]
    }
  ],
  "connections": {
    "Setup Deal Properties": {
      "main": [
        [
          {
            "node": "Definitions",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Definitions": {
      "main": [
        [
          {
            "node": "Read Deal Property",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Read Deal Property": {
      "main": [
        [
          {
            "node": "Check Property Compatibility",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Check Property Compatibility": {
      "main": [
        [
          {
            "node": "Property Missing?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Property Missing?": {
      "main": [
        [
          {
            "node": "Create Deal Property",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "settings": {
    "executionOrder": "v1",
    "timezone": "Asia/Tbilisi",
    "saveExecutionProgress": true
  },
  "active": false,
  "pinData": {},
  "tags": []
}
