{
  "name": "Trevilo: quote request to a draft deal",
  "nodes": [
    {
      "parameters": {
        "content": "## Trevilo: quote request to a draft deal\n\n1. Open **Trevilo enquiry**, copy the **Production URL**.\n2. In **Trevilo enquiry**, create a **Header Auth** credential: name `X-Webhook-Key`, value a long random key.\n3. In Trevilo, add a rule about \"A new enquiry or quote\" and send it to an n8n connection with that URL. Set its login to **API key in a header**, header name `X-Webhook-Key`, and the same key.\n4. In both HubSpot steps, create a **HubSpot App Token** credential from a HubSpot private app.\n5. In **Create draft deal**, choose your draft stage (Stage) and replace the reviewer's owner ID (Deal Owner).\n6. Publish, then send a test quote request. The draft deal appears with the reviewer; nothing is sent to the customer.",
        "height": 420,
        "width": 460
      },
      "id": "0cee8bf2-a468-56c2-908e-d4beca2c13a3",
      "name": "Setup",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        -560,
        -280
      ]
    },
    {
      "parameters": {
        "httpMethod": "POST",
        "path": "trevilo-quote-draft",
        "authentication": "headerAuth",
        "options": {}
      },
      "id": "4942c6f6-8258-5a50-bf54-5aee09052e11",
      "name": "Trevilo enquiry",
      "type": "n8n-nodes-base.webhook",
      "typeVersion": 2.2,
      "position": [
        0,
        0
      ],
      "webhookId": "ab6bbf47-a009-5808-b763-a3e6c247769a"
    },
    {
      "parameters": {
        "operation": "removeItemsSeenInPreviousExecutions",
        "dedupeValue": "={{ $('Trevilo enquiry').item.json.headers['idempotency-key'] }}",
        "options": {}
      },
      "id": "75464d88-7531-59ad-8eda-e725fe3135ae",
      "name": "Skip repeat deliveries",
      "type": "n8n-nodes-base.removeDuplicates",
      "typeVersion": 2,
      "position": [
        220,
        0
      ]
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "strict",
            "version": 2
          },
          "conditions": [
            {
              "id": "baf2deca-299f-52c7-a2fe-610bf10c28f7",
              "leftValue": "={{ [null, 'inquiry'].includes($('Trevilo enquiry').item.json.body.enquiry?.intent ?? null) && Boolean($('Trevilo enquiry').item.json.body.contact?.email) }}",
              "rightValue": "",
              "operator": {
                "type": "boolean",
                "operation": "true",
                "singleValue": true
              }
            }
          ],
          "combinator": "and"
        },
        "options": {}
      },
      "id": "4e1e6bc1-5515-5869-9372-53298bf1cfa8",
      "name": "Quote request with email?",
      "type": "n8n-nodes-base.if",
      "typeVersion": 2.2,
      "position": [
        440,
        0
      ]
    },
    {
      "parameters": {
        "authentication": "appToken",
        "resource": "contact",
        "operation": "upsert",
        "email": "={{ $('Trevilo enquiry').item.json.body.contact.email }}",
        "additionalFields": {
          "firstName": "={{ ($('Trevilo enquiry').item.json.body.enquiry?.name || '').split(' ')[0] }}",
          "lastName": "={{ ($('Trevilo enquiry').item.json.body.enquiry?.name || '').split(' ').slice(1).join(' ') }}",
          "phoneNumber": "={{ $('Trevilo enquiry').item.json.body.contact?.phone || '' }}",
          "message": "={{ $('Trevilo enquiry').item.json.body.enquiry?.message || '' }}"
        },
        "options": {}
      },
      "id": "17a96b63-c22d-5aaf-86cd-f86effc27f3e",
      "name": "Create or update contact",
      "type": "n8n-nodes-base.hubspot",
      "typeVersion": 2.2,
      "position": [
        660,
        -100
      ]
    },
    {
      "parameters": {
        "authentication": "appToken",
        "resource": "deal",
        "operation": "create",
        "stage": "appointmentscheduled",
        "additionalFields": {
          "dealName": "=Quote: {{ $('Trevilo enquiry').item.json.body.enquiry?.name || $('Trevilo enquiry').item.json.body.contact.email }}",
          "description": "={{ $('Trevilo enquiry').item.json.body.enquiry?.message || '' }}\n\nPage: {{ $('Trevilo enquiry').item.json.body.source?.url || '' }}",
          "associatedVids": "={{ [$json.vid] }}",
          "dealOwner": {
            "__rl": true,
            "value": "REPLACE_WITH_REVIEWER_OWNER_ID",
            "mode": "id"
          }
        }
      },
      "id": "e8d50835-8a44-5521-ad7e-431e9ca4f4ac",
      "name": "Create draft deal",
      "type": "n8n-nodes-base.hubspot",
      "typeVersion": 2.2,
      "position": [
        880,
        -100
      ]
    }
  ],
  "connections": {
    "Trevilo enquiry": {
      "main": [
        [
          {
            "node": "Skip repeat deliveries",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Skip repeat deliveries": {
      "main": [
        [
          {
            "node": "Quote request with email?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Quote request with email?": {
      "main": [
        [
          {
            "node": "Create or update contact",
            "type": "main",
            "index": 0
          }
        ],
        []
      ]
    },
    "Create or update contact": {
      "main": [
        [
          {
            "node": "Create draft deal",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "settings": {
    "executionOrder": "v1"
  },
  "pinData": {},
  "meta": {
    "templateCredsSetupCompleted": false
  }
}
