{
  "name": "Logistics Freight Documentation",
  "nodes": [
    {
      "parameters": {
        "pollTimes": {
          "item": [
            {
              "mode": "everyMinute"
            }
          ]
        },
        "documentId": {
          "__rl": true,
          "value": "1FdaaTU8TXMZGKV8w8QikhwLg5Vm0pZbQ8U4vtIWUhEM",
          "mode": "list",
          "cachedResultName": "Freight Documentation",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1FdaaTU8TXMZGKV8w8QikhwLg5Vm0pZbQ8U4vtIWUhEM/edit?usp=drivesdk"
        },
        "sheetName": {
          "__rl": true,
          "value": "gid=0",
          "mode": "list",
          "cachedResultName": "Sheet1",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1FdaaTU8TXMZGKV8w8QikhwLg5Vm0pZbQ8U4vtIWUhEM/edit#gid=0"
        },
        "event": "rowAdded",
        "options": {}
      },
      "type": "n8n-nodes-base.googleSheetsTrigger",
      "typeVersion": 1,
      "position": [
        -512,
        -16
      ],
      "id": "94c26893-5bf4-48ce-8cc1-e399706d3caa",
      "name": "Google Sheets Trigger",
      "credentials": {
        "googleSheetsTriggerOAuth2Api": {
          "id": "sIu8fTsRgLzzSxHV",
          "name": "Google Sheets Trigger account"
        }
      }
    },
    {
      "parameters": {
        "options": {}
      },
      "type": "n8n-nodes-base.splitInBatches",
      "typeVersion": 3,
      "position": [
        -288,
        -16
      ],
      "id": "b0c9db02-9a20-4041-8d75-3524ec005e90",
      "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": "c1d07c60-9526-4f75-9bf1-99d3b24529c4",
      "name": "OpenAI Chat Model",
      "credentials": {
        "openAiApi": {
          "id": "mXmp9rMNs1e1paxm",
          "name": "OpenAi account"
        }
      }
    },
    {
      "parameters": {
        "jsonSchemaExample": "{\n  \"valid\": \"\",\n  \"reason\": \"\"\n}"
      },
      "type": "@n8n/n8n-nodes-langchain.outputParserStructured",
      "typeVersion": 1.3,
      "position": [
        192,
        224
      ],
      "id": "e01adb46-41a0-4399-951e-81c4527631bc",
      "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": "5b7c707a-21de-4b06-98bb-48c2818b6890",
      "name": "Send Shipment PDF To Sender",
      "webhookId": "8fcc5b3e-c5e9-4384-8f9a-1a5b72784ad1",
      "credentials": {
        "gmailOAuth2": {
          "id": "tFIa8CAqigRPLvO1",
          "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": "a42cfe38-c91d-48c4-9540-267c12298814",
      "name": "Send Shipment PDF To Receiver",
      "webhookId": "8fcc5b3e-c5e9-4384-8f9a-1a5b72784ad1",
      "credentials": {
        "gmailOAuth2": {
          "id": "tFIa8CAqigRPLvO1",
          "name": "Gmail account"
        }
      }
    },
    {
      "parameters": {
        "operation": "fromJson",
        "options": {}
      },
      "type": "n8n-nodes-base.extractFromFile",
      "typeVersion": 1,
      "position": [
        880,
        -80
      ],
      "id": "dcba8f27-a3f1-41c1-979f-44bdf2a8fee5",
      "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": "51fa917b-326e-4ad6-8a94-fc76940dca99",
      "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": "24996673-33e5-418e-b132-bbe18b34190b",
      "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": "3680e722-93a8-47bd-8c50-06463ed91a7a",
      "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": "8df9521b-12e3-4999-b0eb-bf82d3f321a2",
      "name": "Send Mismatch Items Details",
      "webhookId": "a0f6e8ff-0e50-43ed-833b-cb43f602ef89",
      "credentials": {
        "gmailOAuth2": {
          "id": "tFIa8CAqigRPLvO1",
          "name": "Gmail account"
        }
      }
    },
    {
      "parameters": {
        "operation": "appendOrUpdate",
        "documentId": {
          "__rl": true,
          "value": "1FdaaTU8TXMZGKV8w8QikhwLg5Vm0pZbQ8U4vtIWUhEM",
          "mode": "list",
          "cachedResultName": "Freight Documentation",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1FdaaTU8TXMZGKV8w8QikhwLg5Vm0pZbQ8U4vtIWUhEM/edit?usp=drivesdk"
        },
        "sheetName": {
          "__rl": true,
          "value": "gid=0",
          "mode": "list",
          "cachedResultName": "Shipping Details",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1FdaaTU8TXMZGKV8w8QikhwLg5Vm0pZbQ8U4vtIWUhEM/edit#gid=0"
        },
        "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": "71cd758b-c636-4b54-9549-1a4e412a0949",
      "name": "Update State",
      "credentials": {
        "googleSheetsOAuth2Api": {
          "id": "oztTa0ZzQpSyJzhB",
          "name": "Google Sheet"
        }
      }
    },
    {
      "parameters": {
        "operation": "appendOrUpdate",
        "documentId": {
          "__rl": true,
          "value": "1FdaaTU8TXMZGKV8w8QikhwLg5Vm0pZbQ8U4vtIWUhEM",
          "mode": "list",
          "cachedResultName": "Freight Documentation",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1FdaaTU8TXMZGKV8w8QikhwLg5Vm0pZbQ8U4vtIWUhEM/edit?usp=drivesdk"
        },
        "sheetName": {
          "__rl": true,
          "value": "gid=0",
          "mode": "list",
          "cachedResultName": "Shipping Details",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1FdaaTU8TXMZGKV8w8QikhwLg5Vm0pZbQ8U4vtIWUhEM/edit#gid=0"
        },
        "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": "d87e5950-7507-4852-84b9-a7c4b5d2d39a",
      "name": "Append or update row in sheet",
      "credentials": {
        "googleSheetsOAuth2Api": {
          "id": "oztTa0ZzQpSyJzhB",
          "name": "Google Sheet"
        }
      }
    },
    {
      "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": "8f2e5e47-b48e-47f5-b958-cca50104eebf",
      "name": "Validate Shipment details"
    },
    {
      "parameters": {
        "content": "## Sample Sheet\nhttps://docs.google.com/spreadsheets/d/1FdaaTU8TXMZGKV8w8QikhwLg5Vm0pZbQ8U4vtIWUhEM/edit?gid=0#gid=0",
        "height": 128,
        "width": 448
      },
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -512,
        -208
      ],
      "typeVersion": 1,
      "id": "5c3ddce0-b12d-4e13-9abb-994bb72451a6",
      "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",
          "cachedResultUrl": "https://drive.google.com/drive/folders/16aQLw-neIIeWXyFFj8UyPEam7xbrby5G"
        },
        "options": {}
      },
      "type": "n8n-nodes-base.googleDrive",
      "typeVersion": 3,
      "position": [
        1696,
        -80
      ],
      "id": "09cd2184-b4b8-4162-b9d4-2e12de4e85dc",
      "name": "Upload file",
      "credentials": {
        "googleDriveOAuth2Api": {
          "id": "PtRfxKQXuV1igv9S",
          "name": "Google Drive account 2"
        }
      }
    },
    {
      "parameters": {
        "url": "={{ $('Get PDF').item.json.data.Files[0].Url }}",
        "options": {}
      },
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        1504,
        -80
      ],
      "id": "b7c956fb-fce7-492e-9ce5-70f9f8050d23",
      "name": "Download File"
    },
    {
      "parameters": {
        "documentId": {
          "__rl": true,
          "value": "1FdaaTU8TXMZGKV8w8QikhwLg5Vm0pZbQ8U4vtIWUhEM",
          "mode": "list",
          "cachedResultName": "Freight Documentation",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1FdaaTU8TXMZGKV8w8QikhwLg5Vm0pZbQ8U4vtIWUhEM/edit?usp=drivesdk"
        },
        "sheetName": {
          "__rl": true,
          "value": 839895459,
          "mode": "list",
          "cachedResultName": "Carrier Details",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1FdaaTU8TXMZGKV8w8QikhwLg5Vm0pZbQ8U4vtIWUhEM/edit#gid=839895459"
        },
        "filtersUI": {
          "values": [
            {
              "lookupColumn": "Status",
              "lookupValue": "Active"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.googleSheetsTool",
      "typeVersion": 4.7,
      "position": [
        32,
        224
      ],
      "id": "1d344b25-f342-494f-9506-da7e74c4ed14",
      "name": "Carrier Details",
      "credentials": {
        "googleSheetsOAuth2Api": {
          "id": "oztTa0ZzQpSyJzhB",
          "name": "Google Sheet"
        }
      }
    }
  ],
  "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": "62e22216-25e1-4ba4-96a1-48e5e5f0cbdb",
  "meta": {
    "templateCredsSetupCompleted": true,
    "instanceId": "9272721148ea09184b6bbb7ce6219dab088562dd450e2df8280d57c2e34c7d84"
  },
  "id": "nbfz8Px8nSpQgivZ",
  "tags": []
}