{
  "apiVersion": 63,
  "status": "Active",
  "label": "HubSpot Converted Opportunity → Deal Writeback",
  "description": "After an inbound-origin Lead is converted, pushes the converted Opportunity to HubSpot as a deal. This uses the Opportunity deal contract so Lead.HubSpot_Id__c remains a contact id and the returned deal id writes back to Opportunity.HubSpot_Id__c.",
  "runAtomically": false,
  "start": {
    "locationX": 40,
    "locationY": 0,
    "triggerType": "RecordAfterSave",
    "recordTriggerType": "Update",
    "object": "Lead",
    "filterLogic": "1 AND 2 AND 3",
    "filters": [
      {
        "field": "HubSpot_Sync_Enabled__c",
        "operator": "EqualTo",
        "value": true
      },
      {
        "field": "IsConverted",
        "operator": "EqualTo",
        "value": true
      },
      {
        "field": "ConvertedOpportunityId",
        "operator": "IsNotBlank"
      }
    ],
    "connector": {
      "targetReference": "GetConvertedOpportunity"
    }
  },
  "recordLookups": [
    {
      "name": "GetConvertedOpportunity",
      "label": "Get converted Opportunity",
      "locationX": 40,
      "locationY": 120,
      "object": "Opportunity",
      "filters": [
        {
          "field": "Id",
          "operator": "EqualTo",
          "value": {
            "elementReference": "$Record.ConvertedOpportunityId"
          }
        }
      ],
      "outputReference": "$convertedOpportunity",
      "getFirstRecordOnly": true,
      "connector": {
        "targetReference": "MaybePushConvertedOpportunity"
      }
    }
  ],
  "decisions": [
    {
      "name": "MaybePushConvertedOpportunity",
      "label": "Push only sync-enabled converted Opportunities",
      "locationX": 40,
      "locationY": 240,
      "rules": [
        {
          "name": "ConvertedOpportunitySyncEnabled",
          "conditionLogic": "and",
          "conditions": [
            {
              "leftValueReference": "$convertedOpportunity.Id",
              "operator": "IsNotBlank"
            },
          {
            "leftValueReference": "$convertedOpportunity.HubSpot_Sync_Enabled__c",
            "operator": "EqualTo",
            "rightValue": true
          }
        ],
        "connector": {
          "targetReference": "TouchConvertedOpportunityForDealOutbound"
        }
      }
    ]
  }
  ],
  "recordUpdates": [
    {
      "name": "TouchConvertedOpportunityForDealOutbound",
      "label": "Touch converted Opportunity to trigger deal outbound",
      "locationX": 40,
      "locationY": 360,
      "object": "Opportunity",
      "filterLogic": "and",
      "filters": [
        {
          "field": "Id",
          "operator": "EqualTo",
          "value": {
            "elementReference": "$convertedOpportunity.Id"
          }
        }
      ],
      "inputAssignments": [
        {
          "field": "HubSpot_Sync_Enabled__c",
          "value": {
            "booleanValue": true
          }
        }
      ]
    }
  ]
}
