{
  "name": "Email Lead to ServiceM8 (parsed form body + AI + branded reply)",
  "nodes": [
    {
      "id": "sticky-setup",
      "name": "Setup notes",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        -280,
        -120
      ],
      "parameters": {
        "width": 560,
        "height": 680,
        "color": 4,
        "content": "## Email Lead -> ServiceM8\n\nWatches a Gmail inbox for web-form lead notifications (filtered by subject), parses the lead out of the email body, then builds the client, both contacts and the job in ServiceM8, downloads and attaches any photos the customer uploaded, writes a tidy job description with AI, and emails the customer a branded confirmation that plays their submission back to them.\n\n**Before you run this:**\n\n1. **Gmail credential** on the *Gmail Trigger* AND *Send Confirmation* (same account). The trigger is filtered to the lead-form subject; change it to match yours.\n2. **ServiceM8 API key.** Settings -> API Keys. Make one **Header Auth** credential named `ServiceM8 API Key`: Name `X-API-Key`, Value = your key.\n3. **OpenAI credential** on *Generate Description*.\n4. **Tune the parser + category** in *Normalize Lead* (it parses the form's HTML table, label -> value). Set the `categoryName` constant to a job category that exists in your account.\n\n**Try it now:** the *Gmail Trigger* has pinned sample data, so you can hit Test and watch the whole flow run without a live email.\n\n**Note on attachments:** this form lists uploaded files as *download links in the body*, so we fetch each link and upload it.\n\n**Style:** every ServiceM8 call uses *Send Body -> Using Fields Below* and *Send Query Parameters*, as you'd fill them in by hand."
      }
    },
    {
      "id": "gmail-trigger",
      "name": "Gmail Trigger",
      "type": "n8n-nodes-base.gmailTrigger",
      "typeVersion": 1.3,
      "position": [
        340,
        240
      ],
      "parameters": {
        "pollTimes": {
          "item": [
            {
              "mode": "everyMinute"
            }
          ]
        },
        "simple": false,
        "filters": {
          "q": "subject:\"Plumber Lead Form\""
        },
        "options": {}
      },
      "credentials": {
        "gmailOAuth2": {
          "id": "REPLACE_GMAIL_CRED",
          "name": "Gmail account"
        }
      }
    },
    {
      "id": "code-normalize",
      "name": "Normalize Lead",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        560,
        240
      ],
      "parameters": {
        "mode": "runOnceForAllItems",
        "language": "javaScript",
        "jsCode": "// Parse the lead out of the HTML table in the email body (a web-form / LeadConnector\n// notification). The From and Subject are just the notification wrapper. This node is\n// pure data extraction; the confirmation email is assembled later in \"Build Email\".\nconst email = $input.first().json;\nconst html = email.html || email.textAsHtml || '';\n\nconst rows = {};\nconst trRe = /<tr[^>]*>([\\s\\S]*?)<\\/tr>/gi;\nconst tdRe = /<td[^>]*>([\\s\\S]*?)<\\/td>/gi;\nconst clean = (s) => s\n  .replace(/<[^>]+>/g, ' ')\n  .replace(/&nbsp;/g, ' ')\n  .replace(/&amp;/g, '&')\n  .replace(/&#x27;|&apos;|&#39;/g, \"'\")\n  .replace(/&quot;/g, '\"')\n  .replace(/&lt;/g, '<')\n  .replace(/&gt;/g, '>')\n  .replace(/\\s+/g, ' ')\n  .trim();\n\nlet tr;\nwhile ((tr = trRe.exec(html)) !== null) {\n  const cells = [];\n  let td;\n  tdRe.lastIndex = 0;\n  while ((td = tdRe.exec(tr[1])) !== null) cells.push(clean(td[1]));\n  if (cells.length >= 2 && cells[0]) rows[cells[0].toLowerCase()] = cells[1];\n}\n\n// Find a value by matching ALL given keywords against the row label.\nconst pick = (...words) => {\n  const k = Object.keys(rows).find((key) => words.every((w) => key.includes(w)));\n  return k ? rows[k] : '';\n};\n\nconst fullName = pick('full', 'name') || pick('name');\nconst parts = fullName.split(/\\s+/).filter(Boolean);\nconst addressFull = rows['address'] || pick('street', 'address');\nconst serviceNeeded = pick('type', 'service') + (pick('other') ? ' (' + pick('other') + ')' : '');\n\n// The form lists uploaded photos/docs as comma-separated links in the body.\nconst attachmentUrls = (pick('attach') || '')\n  .split(/[\\s,]+/)\n  .map((s) => s.trim())\n  .filter((s) => /^https?:\\/\\//i.test(s));\n\n// A tidy block the AI node turns into the job description.\nconst enquiry = [\n  ['Service needed', serviceNeeded],\n  ['Issue', pick('description')],\n  ['Property type', pick('residential')],\n  ['Access notes', pick('accessibility')],\n  ['Address', addressFull],\n  ['Heard about us', pick('how', 'hear')],\n].filter((r) => r[1] && r[1].trim()).map((r) => r[0] + ': ' + r[1]).join('\\n');\n\n// Styled summary rows (label -> value) reused in the confirmation email.\nconst esc = (s) => String(s == null ? '' : s)\n  .replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;');\nconst detailsHtml = [\n  ['Name', fullName],\n  ['Phone', pick('phone')],\n  ['Email', pick('email')],\n  ['Address', addressFull],\n  ['Service needed', serviceNeeded],\n  ['Description', pick('description')],\n  ['Property type', pick('residential')],\n  ['Access notes', pick('accessibility')],\n].filter((r) => r[1] && String(r[1]).trim())\n  .map((r) => '<tr>'\n    + '<td style=\"padding:10px 16px;color:#6B7096;font-size:13px;border-bottom:1px solid #eef0f8;width:38%;vertical-align:top;\">' + esc(r[0]) + '</td>'\n    + '<td style=\"padding:10px 16px;color:#2B2E4A;font-size:13px;border-bottom:1px solid #eef0f8;\">' + esc(r[1]) + '</td>'\n    + '</tr>')\n  .join('');\n\nreturn [{\n  json: {\n    clientName: fullName || 'Website Lead',\n    firstName: parts[0] || 'there',\n    lastName: parts.slice(1).join(' '),\n    email: pick('email'),\n    phone: pick('phone'),\n    addressFull,\n    street: pick('street', 'address'),\n    city: pick('city'),\n    state: pick('state'),\n    postcode: pick('postal'),\n    country: pick('country'),\n    serviceType: pick('type', 'service'),\n    enquiry,\n    detailsHtml,\n    attachmentUrls,\n    // Change this to a job category that exists in your ServiceM8 account:\n    categoryName: 'Service Call',\n  },\n}];"
      }
    },
    {
      "id": "http-create-client",
      "name": "Create Client",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.4,
      "position": [
        780,
        240
      ],
      "parameters": {
        "url": "https://api.servicem8.com/api_1.0/company.json",
        "authentication": "genericCredentialType",
        "genericAuthType": "httpHeaderAuth",
        "method": "POST",
        "sendBody": true,
        "contentType": "json",
        "specifyBody": "keypair",
        "bodyParameters": {
          "parameters": [
            {
              "name": "name",
              "value": "={{ $('Normalize Lead').item.json.clientName }}"
            },
            {
              "name": "address",
              "value": "={{ $('Normalize Lead').item.json.addressFull }}"
            },
            {
              "name": "address_street",
              "value": "={{ $('Normalize Lead').item.json.street }}"
            },
            {
              "name": "address_city",
              "value": "={{ $('Normalize Lead').item.json.city }}"
            },
            {
              "name": "address_state",
              "value": "={{ $('Normalize Lead').item.json.state }}"
            },
            {
              "name": "address_postcode",
              "value": "={{ $('Normalize Lead').item.json.postcode }}"
            },
            {
              "name": "address_country",
              "value": "={{ $('Normalize Lead').item.json.country }}"
            },
            {
              "name": "active",
              "value": "1"
            }
          ]
        },
        "options": {
          "response": {
            "response": {
              "fullResponse": true
            }
          }
        }
      },
      "credentials": {
        "httpHeaderAuth": {
          "id": "REPLACE_SM8_CRED",
          "name": "ServiceM8 API Key"
        }
      }
    },
    {
      "id": "http-create-contact",
      "name": "Create Company Contact",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.4,
      "position": [
        1000,
        240
      ],
      "parameters": {
        "url": "https://api.servicem8.com/api_1.0/companycontact.json",
        "authentication": "genericCredentialType",
        "genericAuthType": "httpHeaderAuth",
        "method": "POST",
        "sendBody": true,
        "contentType": "json",
        "specifyBody": "keypair",
        "bodyParameters": {
          "parameters": [
            {
              "name": "company_uuid",
              "value": "={{ $('Create Client').item.json.headers['x-record-uuid'] }}"
            },
            {
              "name": "first",
              "value": "={{ $('Normalize Lead').item.json.firstName }}"
            },
            {
              "name": "last",
              "value": "={{ $('Normalize Lead').item.json.lastName }}"
            },
            {
              "name": "email",
              "value": "={{ $('Normalize Lead').item.json.email }}"
            },
            {
              "name": "mobile",
              "value": "={{ $('Normalize Lead').item.json.phone }}"
            },
            {
              "name": "is_primary_contact",
              "value": "1"
            }
          ]
        },
        "options": {}
      },
      "credentials": {
        "httpHeaderAuth": {
          "id": "REPLACE_SM8_CRED",
          "name": "ServiceM8 API Key"
        }
      }
    },
    {
      "id": "http-find-category",
      "name": "Look Up Category",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.4,
      "position": [
        1220,
        240
      ],
      "parameters": {
        "url": "https://api.servicem8.com/api_1.0/category.json",
        "authentication": "genericCredentialType",
        "genericAuthType": "httpHeaderAuth",
        "sendQuery": true,
        "queryParameters": {
          "parameters": [
            {
              "name": "$filter",
              "value": "=name eq '{{ $('Normalize Lead').item.json.categoryName }}'"
            }
          ]
        },
        "options": {
          "response": {
            "response": {
              "fullResponse": true
            }
          }
        }
      },
      "credentials": {
        "httpHeaderAuth": {
          "id": "REPLACE_SM8_CRED",
          "name": "ServiceM8 API Key"
        }
      }
    },
    {
      "id": "openai-description",
      "name": "Generate Description",
      "type": "@n8n/n8n-nodes-langchain.openAi",
      "typeVersion": 1.8,
      "position": [
        1440,
        240
      ],
      "parameters": {
        "modelId": {
          "__rl": true,
          "mode": "list",
          "value": "gpt-4o-mini",
          "cachedResultName": "gpt-4o-mini"
        },
        "messages": {
          "values": [
            {
              "role": "user",
              "content": "=You are an assistant for an Australian trades business. Turn the lead details below into a clear, professional job description for our job-management system. Plain text only, no markdown, 2 to 4 short sentences. Lead with what the customer needs, then the useful detail (location, access, urgency). Do not invent anything that isn't given.\n\nCustomer: {{ $('Normalize Lead').item.json.firstName }} {{ $('Normalize Lead').item.json.lastName }}\nPhone: {{ $('Normalize Lead').item.json.phone }}\nEmail: {{ $('Normalize Lead').item.json.email }}\n\n{{ $('Normalize Lead').item.json.enquiry }}"
            }
          ]
        },
        "simplify": true,
        "options": {}
      },
      "credentials": {
        "openAiApi": {
          "id": "REPLACE_OPENAI_CRED",
          "name": "OpenAI account"
        }
      }
    },
    {
      "id": "http-create-job",
      "name": "Create Job",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.4,
      "position": [
        1660,
        240
      ],
      "parameters": {
        "url": "https://api.servicem8.com/api_1.0/job.json",
        "authentication": "genericCredentialType",
        "genericAuthType": "httpHeaderAuth",
        "method": "POST",
        "sendBody": true,
        "contentType": "json",
        "specifyBody": "keypair",
        "bodyParameters": {
          "parameters": [
            {
              "name": "company_uuid",
              "value": "={{ $('Create Client').item.json.headers['x-record-uuid'] }}"
            },
            {
              "name": "status",
              "value": "Work Order"
            },
            {
              "name": "category_uuid",
              "value": "={{ $('Look Up Category').item.json.body[0]?.uuid || '' }}"
            },
            {
              "name": "job_address",
              "value": "={{ $('Normalize Lead').item.json.addressFull }}"
            },
            {
              "name": "job_description",
              "value": "={{ $('Generate Description').item.json.message?.content || $('Generate Description').item.json.content || $('Normalize Lead').item.json.enquiry }}"
            }
          ]
        },
        "options": {
          "response": {
            "response": {
              "fullResponse": true
            }
          }
        }
      },
      "credentials": {
        "httpHeaderAuth": {
          "id": "REPLACE_SM8_CRED",
          "name": "ServiceM8 API Key"
        }
      }
    },
    {
      "id": "http-get-job",
      "name": "Get Job",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.4,
      "position": [
        1880,
        240
      ],
      "parameters": {
        "url": "=https://api.servicem8.com/api_1.0/job/{{ $('Create Job').item.json.headers['x-record-uuid'] }}.json",
        "authentication": "genericCredentialType",
        "genericAuthType": "httpHeaderAuth",
        "options": {}
      },
      "credentials": {
        "httpHeaderAuth": {
          "id": "REPLACE_SM8_CRED",
          "name": "ServiceM8 API Key"
        }
      }
    },
    {
      "id": "http-create-jobcontact",
      "name": "Create Job Contact",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.4,
      "position": [
        2100,
        240
      ],
      "parameters": {
        "url": "https://api.servicem8.com/api_1.0/jobcontact.json",
        "authentication": "genericCredentialType",
        "genericAuthType": "httpHeaderAuth",
        "method": "POST",
        "sendBody": true,
        "contentType": "json",
        "specifyBody": "keypair",
        "bodyParameters": {
          "parameters": [
            {
              "name": "job_uuid",
              "value": "={{ $('Create Job').item.json.headers['x-record-uuid'] }}"
            },
            {
              "name": "first",
              "value": "={{ $('Normalize Lead').item.json.firstName }}"
            },
            {
              "name": "last",
              "value": "={{ $('Normalize Lead').item.json.lastName }}"
            },
            {
              "name": "email",
              "value": "={{ $('Normalize Lead').item.json.email }}"
            },
            {
              "name": "mobile",
              "value": "={{ $('Normalize Lead').item.json.phone }}"
            },
            {
              "name": "type",
              "value": "JOB"
            }
          ]
        },
        "options": {}
      },
      "credentials": {
        "httpHeaderAuth": {
          "id": "REPLACE_SM8_CRED",
          "name": "ServiceM8 API Key"
        }
      }
    },
    {
      "id": "code-build-email",
      "name": "Build Email",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        2320,
        240
      ],
      "parameters": {
        "mode": "runOnceForAllItems",
        "language": "javaScript",
        "jsCode": "// Assemble the full branded confirmation email. Runs after the job exists, so the\n// job number is real. Pulls the lead fields + summary table from \"Normalize Lead\"\n// and the job number from \"Get Job\". The Gmail node just sends $json.emailHtml.\nconst lead = $('Normalize Lead').item.json;\nconst jobNumber = $('Get Job').item.json.generated_job_id || '';\n\nconst emailHtml = `<div style=\"font-family:Arial,Helvetica,sans-serif;max-width:580px;margin:0 auto;color:#2B2E4A;border:1px solid #E3E6F2;border-radius:10px;overflow:hidden;\">\n<div style=\"text-align:center;padding:26px 0;border-bottom:3px solid #2b7cc9;background:#ffffff;\">\n<img src=\"https://assets.cdn.filesafe.space/LPq9mg1sSqzaWgooDMyh/media/6913eb1b9e0b184935e307cd.png\" alt=\"PlumTEC\" width=\"220\" style=\"max-width:220px;height:auto;\"></div>\n<div style=\"padding:30px 26px;\">\n<p style=\"font-size:16px;margin:0 0 14px;\">Hi ${lead.firstName},</p>\n<p style=\"font-size:15px;line-height:1.6;margin:0 0 22px;\">Thanks very much for getting in touch. We've received your enquiry and it's now in our system, so it won't get lost. One of our team will be following up with you in due course.</p>\n<div style=\"background:#f1f5fb;border-left:4px solid #2b7cc9;padding:16px 20px;margin:0 0 26px;border-radius:0 6px 6px 0;\">\n<div style=\"font-size:12px;letter-spacing:0.08em;text-transform:uppercase;color:#6B7096;\">Your job number</div>\n<div style=\"font-size:24px;font-weight:bold;color:#2b7cc9;\">${jobNumber}</div></div>\n<p style=\"font-size:12px;letter-spacing:0.08em;text-transform:uppercase;color:#6B7096;font-weight:bold;margin:0 0 10px;\">What you sent us</p>\n<table style=\"width:100%;border-collapse:collapse;border:1px solid #E3E6F2;border-radius:8px;overflow:hidden;margin:0 0 24px;\">${lead.detailsHtml}</table>\n<p style=\"font-size:15px;line-height:1.6;margin:0 0 18px;\">If any of that looks off, or you'd like to add a detail or a photo, just reply to this email and it'll reach us.</p>\n<p style=\"font-size:15px;margin:24px 0 0;\">Kind regards,<br><strong>The PlumTEC Team</strong></p></div>\n<div style=\"text-align:center;padding:18px;font-size:12px;color:#9096B6;border-top:1px solid #E3E6F2;\">PlumTEC &middot; Plumbing done properly</div></div>`;\n\nreturn [{ json: { emailHtml, jobNumber } }];"
      }
    },
    {
      "id": "gmail-confirm",
      "name": "Send Confirmation",
      "type": "n8n-nodes-base.gmail",
      "typeVersion": 2.2,
      "position": [
        2540,
        80
      ],
      "parameters": {
        "resource": "message",
        "operation": "send",
        "sendTo": "={{ $('Normalize Lead').item.json.email }}",
        "subject": "=We've received your enquiry, {{ $('Normalize Lead').item.json.firstName }} (Job #{{ $('Build Email').item.json.jobNumber }})",
        "emailType": "html",
        "message": "={{ $('Build Email').item.json.emailHtml }}",
        "options": {
          "appendAttribution": false
        }
      },
      "credentials": {
        "gmailOAuth2": {
          "id": "REPLACE_GMAIL_CRED",
          "name": "Gmail account"
        }
      }
    },
    {
      "id": "code-split-attachments",
      "name": "Split Attachment URLs",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        2540,
        420
      ],
      "parameters": {
        "mode": "runOnceForAllItems",
        "language": "javaScript",
        "jsCode": "// The uploaded files arrive as document links in the form body, not as email\n// attachments. Turn each link into its own item so we can download then upload it.\nfunction uuidv4() {\n  if (typeof crypto !== 'undefined' && crypto.randomUUID) return crypto.randomUUID();\n  return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, (c) => {\n    const r = Math.random() * 16 | 0;\n    return (c === 'x' ? r : (r & 0x3 | 0x8)).toString(16);\n  });\n}\nconst urls = $('Normalize Lead').first().json.attachmentUrls || [];\nconst jobUuid = $('Create Job').first().json.headers['x-record-uuid'];\nreturn urls.map((url, i) => ({\n  json: { job_uuid: jobUuid, attachment_uuid: uuidv4(), url, index: i + 1 },\n}));"
      }
    },
    {
      "id": "http-download-file",
      "name": "Download File",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.4,
      "position": [
        2760,
        420
      ],
      "parameters": {
        "url": "={{ $json.url }}",
        "options": {
          "response": {
            "response": {
              "responseFormat": "file",
              "outputPropertyName": "data"
            }
          }
        }
      }
    },
    {
      "id": "http-create-attachment",
      "name": "Create Attachment Record",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.4,
      "position": [
        2980,
        320
      ],
      "parameters": {
        "url": "https://api.servicem8.com/api_1.0/attachment.json",
        "authentication": "genericCredentialType",
        "genericAuthType": "httpHeaderAuth",
        "method": "POST",
        "sendBody": true,
        "contentType": "json",
        "specifyBody": "keypair",
        "bodyParameters": {
          "parameters": [
            {
              "name": "uuid",
              "value": "={{ $('Split Attachment URLs').item.json.attachment_uuid }}"
            },
            {
              "name": "related_object",
              "value": "job"
            },
            {
              "name": "related_object_uuid",
              "value": "={{ $('Split Attachment URLs').item.json.job_uuid }}"
            },
            {
              "name": "attachment_name",
              "value": "={{ $binary?.data?.fileName || ('lead-attachment-' + $('Split Attachment URLs').item.json.index) }}"
            },
            {
              "name": "file_type",
              "value": "={{ '.' + ($binary?.data?.fileExtension || ($binary?.data?.mimeType || 'image/jpeg').split('/')[1] || 'jpg') }}"
            },
            {
              "name": "active",
              "value": "1"
            }
          ]
        },
        "options": {}
      },
      "credentials": {
        "httpHeaderAuth": {
          "id": "REPLACE_SM8_CRED",
          "name": "ServiceM8 API Key"
        }
      }
    },
    {
      "id": "merge-attachment",
      "name": "Wait for Record",
      "type": "n8n-nodes-base.merge",
      "typeVersion": 3.2,
      "position": [
        3200,
        420
      ],
      "parameters": {
        "mode": "combine",
        "combineBy": "combineByPosition",
        "options": {}
      }
    },
    {
      "id": "http-upload-file",
      "name": "Upload File",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.4,
      "position": [
        3420,
        420
      ],
      "parameters": {
        "url": "=https://api.servicem8.com/api_1.0/attachment/{{ $('Split Attachment URLs').item.json.attachment_uuid }}.file",
        "authentication": "genericCredentialType",
        "genericAuthType": "httpHeaderAuth",
        "method": "POST",
        "sendBody": true,
        "contentType": "binaryData",
        "inputDataFieldName": "data",
        "options": {}
      },
      "credentials": {
        "httpHeaderAuth": {
          "id": "REPLACE_SM8_CRED",
          "name": "ServiceM8 API Key"
        }
      }
    }
  ],
  "connections": {
    "Gmail Trigger": {
      "main": [
        [
          {
            "node": "Normalize Lead",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Normalize Lead": {
      "main": [
        [
          {
            "node": "Create Client",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Create Client": {
      "main": [
        [
          {
            "node": "Create Company Contact",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Create Company Contact": {
      "main": [
        [
          {
            "node": "Look Up Category",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Look Up Category": {
      "main": [
        [
          {
            "node": "Generate Description",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Generate Description": {
      "main": [
        [
          {
            "node": "Create Job",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Create Job": {
      "main": [
        [
          {
            "node": "Get Job",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get Job": {
      "main": [
        [
          {
            "node": "Create Job Contact",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Create Job Contact": {
      "main": [
        [
          {
            "node": "Build Email",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Build Email": {
      "main": [
        [
          {
            "node": "Send Confirmation",
            "type": "main",
            "index": 0
          },
          {
            "node": "Split Attachment URLs",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Split Attachment URLs": {
      "main": [
        [
          {
            "node": "Download File",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Download File": {
      "main": [
        [
          {
            "node": "Create Attachment Record",
            "type": "main",
            "index": 0
          },
          {
            "node": "Wait for Record",
            "type": "main",
            "index": 1
          }
        ]
      ]
    },
    "Create Attachment Record": {
      "main": [
        [
          {
            "node": "Wait for Record",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Wait for Record": {
      "main": [
        [
          {
            "node": "Upload File",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "active": false,
  "settings": {
    "executionOrder": "v1"
  },
  "pinData": {
    "Gmail Trigger": [
      {
        "json": {
          "id": "demo000generic001",
          "threadId": "demo000generic001",
          "labelIds": [
            "IMPORTANT",
            "CATEGORY_UPDATES",
            "INBOX"
          ],
          "subject": "Plumber Lead Form",
          "html": "<h3>You have received a form submission. Please review the form details below.</h3><table style=\"border:1px solid lightgray;width:100%;border-collapse:collapse;background:#fff;font-family:Arial,sans-serif;\"><tbody><tr><td style=\"color:#666;border:1px solid lightgray;padding:8px 12px;background-color:#f7f7f7;\">Full Name</td><td style=\"color:black;border:1px solid lightgray;padding:8px 12px;\">Jane Citizen</td></tr><tr><td style=\"color:#666;border:1px solid lightgray;padding:8px 12px;background-color:#f7f7f7;\">Phone</td><td style=\"color:black;border:1px solid lightgray;padding:8px 12px;\">+61 400 000 000</td></tr><tr><td style=\"color:#666;border:1px solid lightgray;padding:8px 12px;background-color:#f7f7f7;\">Street Address</td><td style=\"color:black;border:1px solid lightgray;padding:8px 12px;\">1 Example Street</td></tr><tr><td style=\"color:#666;border:1px solid lightgray;padding:8px 12px;background-color:#f7f7f7;\">City</td><td style=\"color:black;border:1px solid lightgray;padding:8px 12px;\">Sydney</td></tr><tr><td style=\"color:#666;border:1px solid lightgray;padding:8px 12px;background-color:#f7f7f7;\">Postal code</td><td style=\"color:black;border:1px solid lightgray;padding:8px 12px;\">2000</td></tr><tr><td style=\"color:#666;border:1px solid lightgray;padding:8px 12px;background-color:#f7f7f7;\">State</td><td style=\"color:black;border:1px solid lightgray;padding:8px 12px;\">NSW</td></tr><tr><td style=\"color:#666;border:1px solid lightgray;padding:8px 12px;background-color:#f7f7f7;\">Email</td><td style=\"color:black;border:1px solid lightgray;padding:8px 12px;\">jane.citizen@example.com</td></tr><tr><td style=\"color:#666;border:1px solid lightgray;padding:8px 12px;background-color:#f7f7f7;\">Address</td><td style=\"color:black;border:1px solid lightgray;padding:8px 12px;\">1 Example Street, Sydney NSW 2000</td></tr><tr><td style=\"color:#666;border:1px solid lightgray;padding:8px 12px;background-color:#f7f7f7;\">Country</td><td style=\"color:black;border:1px solid lightgray;padding:8px 12px;\">AU</td></tr><tr><td style=\"color:#666;border:1px solid lightgray;padding:8px 12px;background-color:#f7f7f7;\">Type of Service Needed</td><td style=\"color:black;border:1px solid lightgray;padding:8px 12px;\">Plumbing Repair</td></tr><tr><td style=\"color:#666;border:1px solid lightgray;padding:8px 12px;background-color:#f7f7f7;\">Other (Please specify):</td><td style=\"color:black;border:1px solid lightgray;padding:8px 12px;\">Leaking kitchen tap</td></tr><tr><td style=\"color:#666;border:1px solid lightgray;padding:8px 12px;background-color:#f7f7f7;\">Description of the Issue:</td><td style=\"color:black;border:1px solid lightgray;padding:8px 12px;\">My kitchen tap has been dripping for about a week and it&#x27;s getting worse. Keen to have someone take a look soon.</td></tr><tr><td style=\"color:#666;border:1px solid lightgray;padding:8px 12px;background-color:#f7f7f7;\">Is this a residential or commercial property?</td><td style=\"color:black;border:1px solid lightgray;padding:8px 12px;\">Residential</td></tr><tr><td style=\"color:#666;border:1px solid lightgray;padding:8px 12px;background-color:#f7f7f7;\">How did you hear about us?</td><td style=\"color:black;border:1px solid lightgray;padding:8px 12px;\">Google</td></tr><tr><td style=\"color:#666;border:1px solid lightgray;padding:8px 12px;background-color:#f7f7f7;\">Are there any accessibility issues for our team (e.g., locked gates, pets)?</td><td style=\"color:black;border:1px solid lightgray;padding:8px 12px;\">None</td></tr></tbody></table>",
          "from": {
            "value": [
              {
                "address": "noreply@leadform.example.com",
                "name": "Website Lead Form"
              }
            ],
            "text": "\"Website Lead Form\" <noreply@leadform.example.com>"
          },
          "to": {
            "value": [
              {
                "address": "leads@yourbusiness.com.au",
                "name": ""
              }
            ],
            "text": "leads@yourbusiness.com.au"
          },
          "messageId": "<demo000generic001@mail>"
        }
      }
    ]
  },
  "meta": {
    "templateCredsSetupCompleted": true
  },
  "tags": [
    {
      "name": "Trade Magnet"
    }
  ]
}
