{
  "name": "HubSpot to Slack: New Deal Alerts",
  "nodes": [
    {
      "parameters": {
        "httpMethod": "POST",
        "path": "hubspot-deal",
        "responseMode": "onReceived",
        "options": {}
      },
      "id": "webhook-trigger",
      "name": "HubSpot Webhook",
      "type": "n8n-nodes-base.webhook",
      "typeVersion": 1.1,
      "position": [0, 0],
      "webhookId": "hubspot-new-deal"
    },
    {
      "parameters": {
        "resource": "deal",
        "operation": "get",
        "dealId": "={{ $json.body[0].objectId }}",
        "additionalFields": {
          "propertiesCollection": {
            "propertiesValues": {
              "properties": [
                "dealname",
                "amount",
                "dealstage",
                "pipeline",
                "hubspot_owner_id",
                "closedate",
                "createdate"
              ]
            }
          }
        }
      },
      "id": "hubspot-get-deal",
      "name": "Get Deal Details",
      "type": "n8n-nodes-base.hubspot",
      "typeVersion": 2,
      "position": [260, 0],
      "credentials": {
        "hubspotAppToken": {
          "id": "{{HUBSPOT_PRIVATE_APP_CREDENTIAL_ID}}",
          "name": "HubSpot Private App Token"
        }
      }
    },
    {
      "parameters": {
        "mode": "manual",
        "duplicateItem": false,
        "assignments": {
          "assignments": [
            {
              "id": "field-deal-name",
              "name": "dealName",
              "value": "={{ $json.properties.dealname || 'Untitled deal' }}",
              "type": "string"
            },
            {
              "id": "field-deal-amount",
              "name": "dealAmount",
              "value": "={{ $json.properties.amount ? '$' + Number($json.properties.amount).toLocaleString() : 'No amount' }}",
              "type": "string"
            },
            {
              "id": "field-deal-stage",
              "name": "dealStage",
              "value": "={{ $json.properties.dealstage }}",
              "type": "string"
            },
            {
              "id": "field-deal-link",
              "name": "dealLink",
              "value": "=https://app.hubspot.com/contacts/{{ $('HubSpot Webhook').item.json.body[0].portalId }}/deal/{{ $('HubSpot Webhook').item.json.body[0].objectId }}",
              "type": "string"
            },
            {
              "id": "field-slack-text",
              "name": "slackText",
              "value": "=:money_with_wings: New deal created in HubSpot\n*{{ $json.properties.dealname || 'Untitled deal' }}*\nAmount: {{ $json.properties.amount ? '$' + Number($json.properties.amount).toLocaleString() : 'No amount set' }}\nStage: {{ $json.properties.dealstage }}\n<https://app.hubspot.com/contacts/{{ $('HubSpot Webhook').item.json.body[0].portalId }}/deal/{{ $('HubSpot Webhook').item.json.body[0].objectId }}|Open in HubSpot>",
              "type": "string"
            }
          ]
        },
        "options": {}
      },
      "id": "format-message",
      "name": "Format Slack Message",
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [520, 0]
    },
    {
      "parameters": {
        "resource": "message",
        "operation": "post",
        "select": "channel",
        "channelId": {
          "__rl": true,
          "value": "{{SLACK_CHANNEL_ID}}",
          "mode": "list"
        },
        "text": "={{ $json.slackText }}",
        "otherOptions": {}
      },
      "id": "slack-post",
      "name": "Post to Slack",
      "type": "n8n-nodes-base.slack",
      "typeVersion": 2.2,
      "position": [780, 0],
      "credentials": {
        "slackApi": {
          "id": "{{SLACK_CREDENTIAL_ID}}",
          "name": "Slack API"
        }
      }
    }
  ],
  "connections": {
    "HubSpot Webhook": {
      "main": [
        [
          {
            "node": "Get Deal Details",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get Deal Details": {
      "main": [
        [
          {
            "node": "Format Slack Message",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Format Slack Message": {
      "main": [
        [
          {
            "node": "Post to Slack",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "settings": {
    "executionOrder": "v1"
  },
  "pinData": {},
  "staticData": null,
  "tags": [
    { "name": "hubspot" },
    { "name": "slack" },
    { "name": "crm" }
  ],
  "meta": {
    "templateCredsSetupCompleted": false
  },
  "versionId": "1"
}
