{
  "name": "Freight Document Generation & Validation",
  "nodes": [
    {
      "parameters": {
        "pollTimes": {
          "item": [
            {
              "mode": "everyMinute"
            }
          ]
        },
        "documentId": {
          "__rl": true,
          "value": "1FdaaTU8TXMZGKV8w8QikhwLg5Vm0pZbQ8U4vtIWUhEM",
          "mode": "list",
          "cachedResultName": "Freight Documentation"
        },
        "sheetName": {
          "__rl": true,
          "value": "gid=0",
          "mode": "list",
          "cachedResultName": "Sheet1"
        },
        "event": "rowAdded",
        "options": {}
      },
      "type": "n8n-nodes-base.googleSheetsTrigger",
      "typeVersion": 1,
      "position": [
        -512,
        -16
      ],
      "id": "fde840a7-d65e-4c61-9832-46bf80ba2fab",
      "name": "Google Sheets Trigger",
      "credentials": {
        "googleSheetsTriggerOAuth2Api": {
          "id": "E6WQvM7hYnupdtJo",
          "name": "Google Sheets Trigger account"
        }
      }
    },
    {
      "parameters": {
        "options": {}
      },
      "type": "n8n-nodes-base.splitInBatches",
      "typeVersion": 3,
      "position": [
        -288,
        -16
      ],
      "id": "93adb687-8962-4663-a067-7a7639b18c1e",
      "name": "Loop Over Items"
    },
    {
      "parameters": {
        "model": {
          "__rl": true,
          "value": "gpt-4o",
          "mode": "list",
          "cachedResultName": "gpt-4o"
        },
        "options": {}
      },
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "typeVersion": 1.2,
      "position": [
        -128,
        224
      ],
      "id": "818c5ba5-a7ad-4533-a7b2-12a610a217a1",
      "name": "OpenAI Chat Model",
      "credentials": {
        "openAiApi": {
          "id": "UFoXLJTyZlrIERe4",
          "name": "OpenAI account"
        }
      }
    },
    {
      "parameters": {
        "jsonSchemaExample": "{\n  \"valid\": \"\",\n  \"reason\": \"\"\n}"
      },
      "type": "@n8n/n8n-nodes-langchain.outputParserStructured",
      "typeVersion": 1.3,
      "position": [
        192,
        224
      ],
      "id": "08acd1b9-c46f-4d7b-b3dc-7411c2b7ab5b",
      "name": "Structured Output Parser"
    },
    {
      "parameters": {
        "sendTo": "={{ $('Loop Over Items').item.json['Shipper email'] }}",
        "subject": "📦 Shipment Report",
        "emailType": "text",
        "message": "=Hello {{ $('Loop Over Items').item.json['Shipper / Sender Name & Address'] }},\n\n📦 Your shipment report is now available!  \nPlease use the link below to download the PDF:\n\n🔗 [View Shipment Report]:{{ $json.data.Files[0].Url }}\n\nShipment ID: {{ $('Loop Over Items').item.json['Shipment ID / Reference Number'] }}\nShipper: {{ $('Loop Over Items').item.json['Shipper / Sender Name & Address'] }}\nReceiver:{{ $('Loop Over Items').item.json['Receiver / Consignee Name & Address'] }}\n\nIf you have any questions, feel free to reply to this email.\n\nBest regards,  \nLogistics Team 🚚\n",
        "options": {
          "appendAttribution": false
        }
      },
      "type": "n8n-nodes-base.gmail",
      "typeVersion": 2.1,
      "position": [
        1088,
        -80
      ],
      "id": "d0febdc3-35dd-48c0-9da0-4fc8a4399685",
      "name": "Send Shipment PDF To Sender",
      "webhookId": "a15c7909-8275-4eac-bb1d-1d1143c160b3",
      "credentials": {
        "gmailOAuth2": {
          "id": "LBIbVskaBzVhN0SE",
          "name": "Gmail account"
        }
      }
    },
    {
      "parameters": {
        "sendTo": "={{ $('Loop Over Items').item.json['Receiver email'] }}",
        "subject": "📦 Shipment Report",
        "emailType": "text",
        "message": "=Hello {{ $('Loop Over Items').item.json['Receiver / Consignee Name & Address'] }},\n\n📦 Your shipment report is now available!  \nPlease use the link below to download the PDF:\n\n🔗 [View Shipment Report]:{{ $json.data.Files[0].Url }}\n\nShipment ID: {{ $('Loop Over Items').item.json['Shipment ID / Reference Number'] }}\nShipper: {{ $('Loop Over Items').item.json['Shipper / Sender Name & Address'] }}\nReceiver:{{ $('Loop Over Items').item.json['Receiver / Consignee Name & Address'] }}\n\nIf you have any questions, feel free to reply to this email.\n\nBest regards,  \nLogistics Team 🚚\n",
        "options": {
          "appendAttribution": false
        }
      },
      "type": "n8n-nodes-base.gmail",
      "typeVersion": 2.1,
      "position": [
        1296,
        -80
      ],
      "id": "38871285-7c34-4170-80fa-bb2f11da0549",
      "name": "Send Shipment PDF To Receiver",
      "webhookId": "a15c7909-8275-4eac-bb1d-1d1143c160b3",
      "credentials": {
        "gmailOAuth2": {
          "id": "LBIbVskaBzVhN0SE",
          "name": "Gmail account"
        }
      }
    },
    {
      "parameters": {
        "operation": "fromJson",
        "options": {}
      },
      "type": "n8n-nodes-base.extractFromFile",
      "typeVersion": 1,
      "position": [
        880,
        -80
      ],
      "id": "5e95eb3e-a79c-4887-aa23-2b03d465a0ed",
      "name": "Get PDF"
    },
    {
      "parameters": {
        "method": "POST",
        "url": "https://v2.convertapi.com/convert/html/to/pdf",
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "Authorization",
              "value": "Bearer api_key"
            }
          ]
        },
        "sendBody": true,
        "contentType": "multipart-form-data",
        "bodyParameters": {
          "parameters": [
            {
              "name": "StoreFile",
              "value": "true"
            },
            {
              "parameterType": "formBinaryData",
              "name": "File",
              "inputDataFieldName": "data"
            }
          ]
        },
        "options": {
          "response": {
            "response": {
              "responseFormat": "file"
            }
          }
        }
      },
      "id": "f1003ba6-23c3-4b85-9b65-0f57d696b797",
      "name": "PDF Generate",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        672,
        -80
      ],
      "notesInFlow": true,
      "typeVersion": 4.2
    },
    {
      "parameters": {
        "jsCode": "// Get the first item JSON\nconst item = $('Loop Over Items').first().json;\n\n// Create dynamic HTML content\nconst htmlContent = `\n<!DOCTYPE html>\n<html>\n<head>\n  <meta charset=\"UTF-8\">\n  <title>Shipment Report</title>\n  <style>\n    body {\n      font-family: 'Segoe UI', Arial, sans-serif;\n      margin: 30px;\n      color: #222;\n      background-color: #f4f7fb;\n    }\n\n    .header {\n      background: linear-gradient(135deg, #004aad, #007bff);\n      color: white;\n      padding: 25px;\n      text-align: center;\n      border-radius: 12px;\n      margin-bottom: 30px;\n      box-shadow: 0 4px 10px rgba(0,0,0,0.15);\n    }\n\n    .header h1 {\n      margin: 0;\n      font-size: 32px;\n      letter-spacing: 1px;\n    }\n\n    .section {\n      margin-bottom: 25px;\n      padding: 20px;\n      border: none;\n      border-radius: 12px;\n      background-color: white;\n      box-shadow: 0 4px 8px rgba(0,0,0,0.1);\n    }\n\n    .section h2 {\n      margin-top: 0;\n      color: #004aad;\n      font-size: 22px;\n      border-bottom: 2px solid #004aad;\n      padding-bottom: 8px;\n    }\n\n    table {\n      width: 100%;\n      border-collapse: separate;\n      border-spacing: 0;\n      margin-top: 15px;\n      font-size: 16px;\n    }\n\n    th, td {\n      border: 1px solid #ddd;\n      padding: 14px;\n      text-align: left;\n    }\n\n    th {\n      background-color: #004aad;\n      color: white;\n      font-weight: bold;\n      font-size: 16px;\n    }\n\n    tr:nth-child(even) {\n      background-color: #f9faff;\n    }\n\n    tr:hover {\n      background-color: #eef5ff;\n    }\n\n    .footer {\n      margin-top: 40px;\n      text-align: center;\n      font-size: 14px;\n      color: #555;\n      padding: 15px;\n      border-top: 2px solid #ddd;\n    }\n  </style>\n</head>\n<body>\n  <div class=\"header\">\n    <h1>📦 Shipment Report</h1>\n  </div>\n\n  <div class=\"section\">\n    <h2>Shipment Details</h2>\n    <p><strong>Shipment ID:</strong> ${item['Shipment ID / Reference Number']}</p>\n    <p><strong>Shipper:</strong> ${item['Shipper / Sender Name & Address']}</p>\n    <p><strong>Receiver:</strong> ${item['Receiver / Consignee Name & Address']}</p>\n  </div>\n\n  <div class=\"section\">\n    <h2>Goods Information</h2>\n    <table>\n      <tr>\n        <th>Item</th>\n        <th>Quantity</th>\n        <th>Weight</th>\n        <th>HS Code</th>\n      </tr>\n      <tr>\n        <td>${item['Description of Goods']}</td>\n        <td>${item['Quantity / Units']}</td>\n        <td>${item['Weight / Volume']}</td>\n        <td>${item['HS Codes']}</td>\n      </tr>\n    </table>\n  </div>\n\n  <div class=\"footer\">\n    🚢 Generated on <strong>${item['Carrier Name']}</strong> | Logistics System\n  </div>\n</body>\n</html>\n`;\n\n// Convert HTML to binary format for n8n\nconst buffer = Buffer.from(htmlContent, 'utf8');\nconst binaryData = {\n  data: buffer.toString('base64'),\n  mimeType: 'text/html',\n  fileName: 'Shipment_Report.html',\n};\n\n// Attach binary data to the first item\nitems[0].binary = { data: binaryData };\n\nreturn items;"
      },
      "id": "03658f3c-525c-429d-bc15-2d72a5c4b158",
      "name": "Set Shipment Data",
      "type": "n8n-nodes-base.code",
      "position": [
        480,
        -80
      ],
      "typeVersion": 2
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "strict",
            "version": 2
          },
          "conditions": [
            {
              "id": "2d3548fd-d02b-4fd3-b50f-d2944614cd45",
              "leftValue": "={{ $json.output.valid }}",
              "rightValue": "true",
              "operator": {
                "type": "string",
                "operation": "equals",
                "name": "filter.operator.equals"
              }
            }
          ],
          "combinator": "and"
        },
        "options": {}
      },
      "type": "n8n-nodes-base.if",
      "typeVersion": 2.2,
      "position": [
        272,
        0
      ],
      "id": "50c21491-94dc-4545-a86f-7608514ef3de",
      "name": "If Validate"
    },
    {
      "parameters": {
        "sendTo": "={{ $('Loop Over Items').item.json['Shipper email'] }}",
        "subject": "⚠️ Action Required: Shipment Item Mismatch Detected",
        "emailType": "text",
        "message": "=Dear {{ $('Loop Over Items').item.json['Shipper / Sender Name & Address'] }},\n\n\n**Issue Detected:**  \n{{ $json.output.reason }}\n\nPlease review the shipment details carefully and correct any errors to ensure smooth processing and compliance.\n\n**Shipment Details:**  \n- Receiver: {{ $('Loop Over Items').item.json['Receiver / Consignee Name & Address'] }}\n- Carrier: {{ $('Loop Over Items').item.json['Carrier Name'] }}\n- Port of Loading:  {{ $('Loop Over Items').item.json['Port of Loading / Export'] }}\n- Port of Discharge: {{ $('Loop Over Items').item.json['Port of Discharge / Import'] }}\n- Description of Goods:  {{ $('Loop Over Items').item.json['Description of Goods'] }}\n- Quantity / Units: {{ $('Loop Over Items').item.json['Quantity / Units'] }}\n- Weight / Volume: {{ $('Loop Over Items').item.json['Weight / Volume'] }}\n- HS Codes: {{ $('Loop Over Items').item.json['HS Codes'] }}\n\n⚠️ **Action Required:**  \nPlease verify and correct the shipment information as soon as possible to avoid delays.\n\nThank you for your prompt attention.\n\nBest regards,  \n**Team**  \n",
        "options": {
          "appendAttribution": false
        }
      },
      "type": "n8n-nodes-base.gmail",
      "typeVersion": 2.1,
      "position": [
        480,
        64
      ],
      "id": "834281c9-0209-42d5-b92a-fd65f5022f6e",
      "name": "Send Mismatch Items Details",
      "webhookId": "e755fae4-c575-4fcd-92c4-c4e37b31a9ad",
      "credentials": {
        "gmailOAuth2": {
          "id": "LBIbVskaBzVhN0SE",
          "name": "Gmail account"
        }
      }
    },
    {
      "parameters": {
        "operation": "appendOrUpdate",
        "documentId": {
          "__rl": true,
          "value": "1FdaaTU8TXMZGKV8w8QikhwLg5Vm0pZbQ8U4vtIWUhEM",
          "mode": "list",
          "cachedResultName": "Freight Documentation"
        },
        "sheetName": {
          "__rl": true,
          "value": "gid=0",
          "mode": "list",
          "cachedResultName": "Shipping Details"
        },
        "columns": {
          "mappingMode": "defineBelow",
          "value": {
            "Shipment ID / Reference Number": "={{ $('Loop Over Items').item.json[\"Shipment ID / Reference Number\"] }}",
            "State": "Mismatch_Details"
          },
          "matchingColumns": [
            "Shipment ID / Reference Number"
          ],
          "schema": [
            {
              "id": "Shipment ID / Reference Number",
              "displayName": "Shipment ID / Reference Number",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": false
            },
            {
              "id": "Shipper / Sender Name & Address",
              "displayName": "Shipper / Sender Name & Address",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": true
            },
            {
              "id": "Receiver / Consignee Name & Address",
              "displayName": "Receiver / Consignee Name & Address",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": true
            },
            {
              "id": "Carrier Name",
              "displayName": "Carrier Name",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": true
            },
            {
              "id": "Port of Loading / Export",
              "displayName": "Port of Loading / Export",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": true
            },
            {
              "id": "Port of Discharge / Import",
              "displayName": "Port of Discharge / Import",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": true
            },
            {
              "id": "Description of Goods",
              "displayName": "Description of Goods",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": true
            },
            {
              "id": "Quantity / Units",
              "displayName": "Quantity / Units",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": true
            },
            {
              "id": "Weight / Volume",
              "displayName": "Weight / Volume",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": true
            },
            {
              "id": "HS Codes",
              "displayName": "HS Codes",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": true
            },
            {
              "id": "Shipper email",
              "displayName": "Shipper email",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": true
            },
            {
              "id": "Receiver email",
              "displayName": "Receiver email",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": true
            },
            {
              "id": "State",
              "displayName": "State",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": false
            }
          ],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {}
      },
      "type": "n8n-nodes-base.googleSheets",
      "typeVersion": 4.7,
      "position": [
        672,
        64
      ],
      "id": "b024b4b2-c934-45d7-91c5-758425827cab",
      "name": "Update State",
      "credentials": {
        "googleSheetsOAuth2Api": {
          "id": "9rJzpmHDDKlqEEe9",
          "name": "Google Sheets account"
        }
      }
    },
    {
      "parameters": {
        "operation": "appendOrUpdate",
        "documentId": {
          "__rl": true,
          "value": "1FdaaTU8TXMZGKV8w8QikhwLg5Vm0pZbQ8U4vtIWUhEM",
          "mode": "list",
          "cachedResultName": "Freight Documentation"
        },
        "sheetName": {
          "__rl": true,
          "value": "gid=0",
          "mode": "list",
          "cachedResultName": "Shipping Details"
        },
        "columns": {
          "mappingMode": "defineBelow",
          "value": {
            "State": "shipment_pdf_dispatch",
            "Shipment ID / Reference Number": "={{ $('Loop Over Items').item.json[\"Shipment ID / Reference Number\"] }}",
            "Drive_link": "={{ $json.webViewLink }}"
          },
          "matchingColumns": [
            "Shipment ID / Reference Number"
          ],
          "schema": [
            {
              "id": "Shipment ID / Reference Number",
              "displayName": "Shipment ID / Reference Number",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": false
            },
            {
              "id": "Shipper / Sender Name & Address",
              "displayName": "Shipper / Sender Name & Address",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": true
            },
            {
              "id": "Receiver / Consignee Name & Address",
              "displayName": "Receiver / Consignee Name & Address",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": true
            },
            {
              "id": "Carrier Name",
              "displayName": "Carrier Name",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": true
            },
            {
              "id": "Port of Loading / Export",
              "displayName": "Port of Loading / Export",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": true
            },
            {
              "id": "Port of Discharge / Import",
              "displayName": "Port of Discharge / Import",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": true
            },
            {
              "id": "Description of Goods",
              "displayName": "Description of Goods",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": true
            },
            {
              "id": "Quantity / Units",
              "displayName": "Quantity / Units",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": true
            },
            {
              "id": "Weight / Volume",
              "displayName": "Weight / Volume",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": true
            },
            {
              "id": "HS Codes",
              "displayName": "HS Codes",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": true
            },
            {
              "id": "Shipper email",
              "displayName": "Shipper email",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": true
            },
            {
              "id": "Receiver email",
              "displayName": "Receiver email",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": true
            },
            {
              "id": "State",
              "displayName": "State",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Drive_link",
              "displayName": "Drive_link",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": false
            }
          ],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {}
      },
      "type": "n8n-nodes-base.googleSheets",
      "typeVersion": 4.7,
      "position": [
        880,
        64
      ],
      "id": "67b76a93-e6af-4a80-992b-12759818aa73",
      "name": "Append or update row in sheet",
      "credentials": {
        "googleSheetsOAuth2Api": {
          "id": "9rJzpmHDDKlqEEe9",
          "name": "Google Sheets account"
        }
      }
    },
    {
      "parameters": {
        "promptType": "define",
        "text": "=You are an AI assistant for Freight Documentation.\n\nYou are given the following shipment data:\n\nShipment ID:{{ $json['Shipment ID / Reference Number'] }}\nShipper / Sender Name & Address: {{ $json['Shipper / Sender Name & Address'] }}\nReceiver / Consignee Name & Address: {{ $json['Receiver / Consignee Name & Address'] }}\nCarrier Name: {{ $json['Carrier Name'] }}\nPort of Loading / Export: {{ $json['Port of Loading / Export'] }}\nPort of Discharge / Import: {{ $json['Port of Discharge / Import'] }}\nDescription of Goods: {{ $json['Description of Goods'] }}\nQuantity / Units: {{ $json['Quantity / Units'] }}\nWeight / Volume: {{ $json['Weight / Volume'] }}\nHS Codes: {{ $json['HS Codes'] }}\n\nYour task:\n1. Validate all fields for accuracy and compliance according to the following rules:\n   - Shipment ID must be properly formatted.\n   - Sender and Receiver addresses must be complete.\n   - Carrier Name must exist in the \"carrier_Details\" reference list.\n   - Ports must be valid Format..\n   - Description of Goods must match the HS Codes.\n   - Quantity and Weight must be positive numbers and consistent.\n   - HSN Codes must be valid for export/import compliance.\n2. Output **only a JSON object** in the following format:\n\n{\n  \"valid\": true/false,\n  \"reason\": \"Explain the first error found if any; leave empty if all fields are valid.\"\n}\n\nDo not generate any documents or additional explanations. Only return the JSON.\n",
        "hasOutputParser": true,
        "options": {}
      },
      "type": "@n8n/n8n-nodes-langchain.agent",
      "typeVersion": 2.2,
      "position": [
        -48,
        0
      ],
      "id": "6198fcce-47bc-40fa-8cd2-dc0ca6d73653",
      "name": "Validate Shipment details"
    },
    {
      "parameters": {
        "content": "## Data Setup\nCreate your own spreadsheet with these tabs/columns, then select it in the Google Sheets nodes:\n- **Freight Documentation → Sheet1**: _(columns as used in the nodes)_\n- **Freight Documentation → Shipping Details**: `Shipment ID / Reference Number`, `State`, `Drive_link`\n- **Freight Documentation → Carrier Details**: `Status`",
        "height": 128,
        "width": 448
      },
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -512,
        -208
      ],
      "typeVersion": 1,
      "id": "b7da144a-7ee1-452e-b59d-67ab5db7c760",
      "name": "Sticky Note"
    },
    {
      "parameters": {
        "name": "={{ $('Loop Over Items').item.json[\"Shipment ID / Reference Number\"] }}",
        "driveId": {
          "__rl": true,
          "mode": "list",
          "value": "My Drive"
        },
        "folderId": {
          "__rl": true,
          "value": "16aQLw-neIIeWXyFFj8UyPEam7xbrby5G",
          "mode": "list",
          "cachedResultName": "Freight Documentation"
        },
        "options": {}
      },
      "type": "n8n-nodes-base.googleDrive",
      "typeVersion": 3,
      "position": [
        1696,
        -80
      ],
      "id": "7df32303-f810-49e3-83a4-f6e1fff6be0d",
      "name": "Upload file",
      "credentials": {
        "googleDriveOAuth2Api": {
          "id": "l2hNJyVE2LZJtuCV",
          "name": "Google Drive account"
        }
      }
    },
    {
      "parameters": {
        "url": "={{ $('Get PDF').item.json.data.Files[0].Url }}",
        "options": {}
      },
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        1504,
        -80
      ],
      "id": "738b3c7f-a3ad-4982-8af0-a64312d4cdcf",
      "name": "Download File"
    },
    {
      "parameters": {
        "documentId": {
          "__rl": true,
          "value": "1FdaaTU8TXMZGKV8w8QikhwLg5Vm0pZbQ8U4vtIWUhEM",
          "mode": "list",
          "cachedResultName": "Freight Documentation"
        },
        "sheetName": {
          "__rl": true,
          "value": 839895459,
          "mode": "list",
          "cachedResultName": "Carrier Details"
        },
        "filtersUI": {
          "values": [
            {
              "lookupColumn": "Status",
              "lookupValue": "Active"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.googleSheetsTool",
      "typeVersion": 4.7,
      "position": [
        32,
        224
      ],
      "id": "75540e54-8d7f-4663-a50a-9c76d6c022da",
      "name": "Carrier Details",
      "credentials": {
        "googleSheetsOAuth2Api": {
          "id": "9rJzpmHDDKlqEEe9",
          "name": "Google Sheets account"
        }
      }
    }
  ],
  "pinData": {},
  "connections": {
    "Google Sheets Trigger": {
      "main": [
        [
          {
            "node": "Loop Over Items",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Loop Over Items": {
      "main": [
        [],
        [
          {
            "node": "Validate Shipment details",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "Validate Shipment details",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Structured Output Parser": {
      "ai_outputParser": [
        [
          {
            "node": "Validate Shipment details",
            "type": "ai_outputParser",
            "index": 0
          }
        ]
      ]
    },
    "Get PDF": {
      "main": [
        [
          {
            "node": "Send Shipment PDF To Sender",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "PDF Generate": {
      "main": [
        [
          {
            "node": "Get PDF",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Set Shipment Data": {
      "main": [
        [
          {
            "node": "PDF Generate",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "If Validate": {
      "main": [
        [
          {
            "node": "Set Shipment Data",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Send Mismatch Items Details",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Send Mismatch Items Details": {
      "main": [
        [
          {
            "node": "Update State",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Send Shipment PDF To Sender": {
      "main": [
        [
          {
            "node": "Send Shipment PDF To Receiver",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Send Shipment PDF To Receiver": {
      "main": [
        [
          {
            "node": "Download File",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Update State": {
      "main": [
        [
          {
            "node": "Loop Over Items",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Append or update row in sheet": {
      "main": [
        [
          {
            "node": "Loop Over Items",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Validate Shipment details": {
      "main": [
        [
          {
            "node": "If Validate",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Upload file": {
      "main": [
        [
          {
            "node": "Append or update row in sheet",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Download File": {
      "main": [
        [
          {
            "node": "Upload file",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Carrier Details": {
      "ai_tool": [
        [
          {
            "node": "Validate Shipment details",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    }
  },
  "active": false,
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "f9c7a7fb-3d9f-460a-bd07-06507e88d242",
  "meta": {
    "templateCredsSetupCompleted": true,
    "instanceId": "f1c26778ec36097a9722a22c47c5e9c01f00b8862dadd0121ec118026a370fa6"
  },
  "id": "laomFIws7hChWoKQ",
  "tags": []
}