{
  "name": "Discount Approval — HubSpot → Slack",
  "nodes": [
    {
      "parameters": {
        "eventsUi": {
          "eventValues": [
            {
              "name": "deal.propertyChange",
              "value": "discount_percent"
            }
          ]
        }
      },
      "id": "hubspot-trigger",
      "name": "HubSpot Trigger",
      "type": "n8n-nodes-base.hubspotTrigger",
      "typeVersion": 1,
      "position": [0, 0],
      "webhookId": "hubspot-discount-change",
      "credentials": {
        "hubspotDeveloperApi": {
          "id": "credential-id",
          "name": "HubSpot Developer API"
        }
      }
    },
    {
      "parameters": {
        "method": "GET",
        "url": "=https://api.hubapi.com/crm/v3/objects/deals/{{ $json.objectId }}",
        "authentication": "predefinedCredentialType",
        "nodeCredentialType": "hubspotApi",
        "sendQuery": true,
        "queryParameters": {
          "parameters": [
            {
              "name": "properties",
              "value": "dealname,amount,discount_percent,hubspot_owner_id,dealstage"
            }
          ]
        },
        "options": {}
      },
      "id": "fetch-deal",
      "name": "Fetch Deal",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [220, 0],
      "credentials": {
        "hubspotApi": {
          "id": "credential-id",
          "name": "HubSpot API"
        }
      }
    },
    {
      "parameters": {
        "conditions": {
          "number": [
            {
              "value1": "={{ parseFloat($json.properties.discount_percent || '0') }}",
              "operation": "larger",
              "value2": 15
            }
          ]
        }
      },
      "id": "check-threshold",
      "name": "Discount > 15%?",
      "type": "n8n-nodes-base.if",
      "typeVersion": 2,
      "position": [440, 0]
    },
    {
      "parameters": {
        "select": "channel",
        "channelId": {
          "__rl": true,
          "value": "deal-desk",
          "mode": "name"
        },
        "messageType": "block",
        "blocksUi": "={\n  \"blocks\": [\n    {\n      \"type\": \"section\",\n      \"text\": {\n        \"type\": \"mrkdwn\",\n        \"text\": \":label: *Discount Approval Needed*\\n\\n*Deal:* \" + $json.properties.dealname + \"\\n*Amount:* $\" + parseFloat($json.properties.amount).toLocaleString() + \"\\n*Discount:* \" + $json.properties.discount_percent + \"%\\n*Rep:* Owner ID \" + $json.properties.hubspot_owner_id + \"\\n\\nApprove or deny this discount request.\"\n      }\n    }\n  ]\n}",
        "operation": "sendAndWait",
        "otherOptions": {
          "unfurl_links": false
        }
      },
      "id": "send-and-wait",
      "name": "Send & Wait for Approval",
      "type": "n8n-nodes-base.slack",
      "typeVersion": 2.3,
      "position": [660, 0],
      "credentials": {
        "slackApi": {
          "id": "credential-id",
          "name": "Slack API"
        }
      }
    },
    {
      "parameters": {
        "conditions": {
          "string": [
            {
              "value1": "={{ $json.response }}",
              "operation": "equals",
              "value2": "approved"
            }
          ]
        }
      },
      "id": "check-response",
      "name": "Approved?",
      "type": "n8n-nodes-base.if",
      "typeVersion": 2,
      "position": [880, 0]
    },
    {
      "parameters": {
        "method": "PATCH",
        "url": "=https://api.hubapi.com/crm/v3/objects/deals/{{ $json.dealId }}",
        "authentication": "predefinedCredentialType",
        "nodeCredentialType": "hubspotApi",
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={\"properties\": {\"discount_approval\": \"Approved\"}}",
        "options": {}
      },
      "id": "update-approved",
      "name": "Update HubSpot — Approved",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [1100, -100],
      "credentials": {
        "hubspotApi": {
          "id": "credential-id",
          "name": "HubSpot API"
        }
      }
    },
    {
      "parameters": {
        "method": "PATCH",
        "url": "=https://api.hubapi.com/crm/v3/objects/deals/{{ $json.dealId }}",
        "authentication": "predefinedCredentialType",
        "nodeCredentialType": "hubspotApi",
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={\"properties\": {\"discount_approval\": \"Denied\"}}",
        "options": {}
      },
      "id": "update-denied",
      "name": "Update HubSpot — Denied",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [1100, 100],
      "credentials": {
        "hubspotApi": {
          "id": "credential-id",
          "name": "HubSpot API"
        }
      }
    }
  ],
  "connections": {
    "HubSpot Trigger": {
      "main": [
        [
          {
            "node": "Fetch Deal",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Fetch Deal": {
      "main": [
        [
          {
            "node": "Discount > 15%?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Discount > 15%?": {
      "main": [
        [
          {
            "node": "Send & Wait for Approval",
            "type": "main",
            "index": 0
          }
        ],
        []
      ]
    },
    "Send & Wait for Approval": {
      "main": [
        [
          {
            "node": "Approved?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Approved?": {
      "main": [
        [
          {
            "node": "Update HubSpot — Approved",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Update HubSpot — Denied",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "pinData": {},
  "settings": {
    "executionOrder": "v1"
  },
  "staticData": null,
  "tags": [],
  "triggerCount": 0,
  "active": false,
  "meta": {
    "instanceId": "",
    "templateId": "revi-discount-approval"
  }
}
