{
  "name": "VIP Escalation — Zendesk Trigger → Slack Alert",
  "nodes": [
    {
      "parameters": {
        "event": "ticketCreated"
      },
      "id": "zendesk-trigger",
      "name": "Zendesk Trigger",
      "type": "n8n-nodes-base.zendeskTrigger",
      "typeVersion": 1,
      "position": [0, 0],
      "credentials": {
        "zendeskApi": {
          "id": "credential-id",
          "name": "Zendesk API"
        }
      }
    },
    {
      "parameters": {
        "conditions": {
          "number": [
            {
              "value1": "={{ $json.organization_id }}",
              "operation": "isNotEmpty"
            }
          ]
        }
      },
      "id": "has-org",
      "name": "Has Org?",
      "type": "n8n-nodes-base.if",
      "typeVersion": 2,
      "position": [220, 0]
    },
    {
      "parameters": {
        "method": "GET",
        "url": "=https://YOUR_SUBDOMAIN.zendesk.com/api/v2/organizations/{{ $('Zendesk Trigger').item.json.organization_id }}.json",
        "authentication": "predefinedCredentialType",
        "nodeCredentialType": "zendeskApi",
        "options": {}
      },
      "id": "fetch-org",
      "name": "Fetch Organization",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [440, 0],
      "credentials": {
        "zendeskApi": {
          "id": "credential-id",
          "name": "Zendesk API"
        }
      }
    },
    {
      "parameters": {
        "mode": "runOnceForAllItems",
        "jsCode": "const org = $input.first().json.organization;\nconst orgTags = org?.tags || [];\nconst isVip = orgTags.includes('vip');\n\nreturn [{\n  json: {\n    isVip,\n    orgName: org?.name || 'Unknown',\n    orgTags,\n  }\n}];"
      },
      "id": "check-vip",
      "name": "Check VIP Tag",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [660, 0]
    },
    {
      "parameters": {
        "conditions": {
          "boolean": [
            {
              "value1": "={{ $json.isVip }}",
              "value2": true
            }
          ]
        }
      },
      "id": "is-vip",
      "name": "Is VIP?",
      "type": "n8n-nodes-base.if",
      "typeVersion": 2,
      "position": [880, 0]
    },
    {
      "parameters": {
        "method": "PUT",
        "url": "=https://YOUR_SUBDOMAIN.zendesk.com/api/v2/tickets/{{ $('Zendesk Trigger').item.json.id }}.json",
        "authentication": "predefinedCredentialType",
        "nodeCredentialType": "zendeskApi",
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "{\n  \"ticket\": {\n    \"tags\": [\"vip\"],\n    \"priority\": \"urgent\",\n    \"group_id\": \"VIP_GROUP_ID\"\n  }\n}",
        "options": {}
      },
      "id": "update-ticket",
      "name": "Tag & Escalate Ticket",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [1100, 0],
      "credentials": {
        "zendeskApi": {
          "id": "credential-id",
          "name": "Zendesk API"
        }
      }
    },
    {
      "parameters": {
        "select": "channel",
        "channelId": {
          "__rl": true,
          "value": "support-vip",
          "mode": "name"
        },
        "messageType": "block",
        "blocksUi": "={\n  \"blocks\": [\n    {\n      \"type\": \"header\",\n      \"text\": {\n        \"type\": \"plain_text\",\n        \"text\": \"VIP Customer Ticket\",\n        \"emoji\": true\n      }\n    },\n    {\n      \"type\": \"section\",\n      \"fields\": [\n        {\n          \"type\": \"mrkdwn\",\n          \"text\": \"*Ticket:* #\" + $('Zendesk Trigger').item.json.id\n        },\n        {\n          \"type\": \"mrkdwn\",\n          \"text\": \"*Subject:* \" + $('Zendesk Trigger').item.json.subject\n        },\n        {\n          \"type\": \"mrkdwn\",\n          \"text\": \"*Customer:* \" + ($('Zendesk Trigger').item.json.requester?.name || 'Unknown')\n        },\n        {\n          \"type\": \"mrkdwn\",\n          \"text\": \"*Organization:* \" + $('Check VIP Tag').item.json.orgName\n        }\n      ]\n    },\n    {\n      \"type\": \"section\",\n      \"fields\": [\n        {\n          \"type\": \"mrkdwn\",\n          \"text\": \"*Priority:* Urgent\"\n        },\n        {\n          \"type\": \"mrkdwn\",\n          \"text\": \"*Status:* Escalated to VIP Support\"\n        }\n      ]\n    },\n    {\n      \"type\": \"actions\",\n      \"elements\": [\n        {\n          \"type\": \"button\",\n          \"text\": {\n            \"type\": \"plain_text\",\n            \"text\": \"View Ticket\"\n          },\n          \"url\": \"https://YOUR_SUBDOMAIN.zendesk.com/agent/tickets/\" + $('Zendesk Trigger').item.json.id,\n          \"style\": \"primary\"\n        }\n      ]\n    }\n  ]\n}",
        "otherOptions": {
          "unfurl_links": false
        }
      },
      "id": "post-slack",
      "name": "Post Slack Alert",
      "type": "n8n-nodes-base.slack",
      "typeVersion": 2.3,
      "position": [1320, 0],
      "credentials": {
        "slackApi": {
          "id": "credential-id",
          "name": "Slack API"
        }
      }
    }
  ],
  "connections": {
    "Zendesk Trigger": {
      "main": [
        [
          {
            "node": "Has Org?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Has Org?": {
      "main": [
        [
          {
            "node": "Fetch Organization",
            "type": "main",
            "index": 0
          }
        ],
        []
      ]
    },
    "Fetch Organization": {
      "main": [
        [
          {
            "node": "Check VIP Tag",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Check VIP Tag": {
      "main": [
        [
          {
            "node": "Is VIP?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Is VIP?": {
      "main": [
        [
          {
            "node": "Tag & Escalate Ticket",
            "type": "main",
            "index": 0
          }
        ],
        []
      ]
    },
    "Tag & Escalate Ticket": {
      "main": [
        [
          {
            "node": "Post Slack Alert",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "pinData": {},
  "settings": {
    "executionOrder": "v1"
  },
  "staticData": null,
  "tags": [],
  "triggerCount": 0,
  "active": false,
  "meta": {
    "instanceId": "",
    "templateId": "revi-zendesk-vip-escalation"
  }
}
