{
  "name": "♻️ AI multi-stop planner for circular logistics with GPT-4o & Open Route API",
  "nodes": [
    {
      "id": "9f8389be-ac2e-4a1d-bfe3-18a7d9900b36",
      "name": "Gmail Trigger",
      "type": "n8n-nodes-base.gmailTrigger",
      "position": [
        20,
        460
      ]
    },
    {
      "id": "5eb9eadc-3836-4cc9-9130-62bc655b9eb0",
      "name": "Structured Output Parser",
      "type": "@n8n/n8n-nodes-langchain.outputParserStructured",
      "position": [
        520,
        640
      ]
    },
    {
      "id": "1a98f859-b7ba-4778-a05b-7bd1c6da29fe",
      "name": "AI Agent Parser",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        300,
        460
      ]
    },
    {
      "id": "170e9ffb-23a6-42ce-bca9-ae31d18124f0",
      "name": "Record Email Content",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        1360,
        460
      ]
    },
    {
      "id": "4c3c818c-9931-4eed-b145-39190e405b50",
      "name": "5 sec",
      "type": "n8n-nodes-base.wait",
      "position": [
        2140,
        460
      ]
    },
    {
      "id": "f567d1dd-432b-4e8e-9dec-5f27799ff61f",
      "name": "Query Open Route API Pickup",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        1560,
        460
      ]
    },
    {
      "id": "a88ca302-325e-4309-b427-a9eb807ab0e9",
      "name": "Save Pickup GPS",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        1940,
        460
      ]
    },
    {
      "id": "e07773a7-dd80-411e-b056-f6eb473d5dcb",
      "name": "GPS Pickup",
      "type": "n8n-nodes-base.set",
      "position": [
        1740,
        460
      ]
    },
    {
      "id": "121aa413-54e5-470a-be3b-ef243f3e9445",
      "name": "Collect Coordinates",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        840,
        700
      ]
    },
    {
      "id": "eca19e02-596a-47af-a448-b18ba2aa3af7",
      "name": "Request Open Route API",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        1360,
        700
      ]
    },
    {
      "id": "6f0027ec-68f9-495f-8958-14960dde3ccc",
      "name": "Collect Shipment Information",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        840,
        1520
      ]
    },
    {
      "id": "743b5224-10c1-4629-85e5-f32a57b85926",
      "name": "OpenAI Chat Model",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "position": [
        1140,
        1680
      ]
    },
    {
      "id": "93ed811e-041f-4f1b-92eb-b519c5b758f8",
      "name": "AI Agent Reply",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        1200,
        1520
      ]
    },
    {
      "id": "5ba3408c-37c7-4d2b-8972-9e753824b21e",
      "name": "Reply",
      "type": "n8n-nodes-base.gmail",
      "position": [
        1520,
        1520
      ]
    },
    {
      "id": "cfc99cbf-12ae-4c77-be75-99609d3f24d5",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        780,
        0
      ],
      "parameters": {
        "width": 1560,
        "height": 1100,
        "content": "### 3. Record Shipment Request Information and fetch distance and driving time using Open Route API\nThis starts by recording all the information parsed by the AI node. Then, we use the **Open Route AP"
      }
    },
    {
      "id": "2bb6e08e-1378-49dd-b3a4-ed68b2923705",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        0,
        0
      ],
      "parameters": {
        "width": 180,
        "height": 820,
        "content": "### 1. Workflow Trigger with Gmail Trigger\nThe workflow is triggered by a new email received in your Gmail mailbox dedicated to process **collection request**.\n\n#### How to setup?\n- **Gmail Trigger No"
      }
    },
    {
      "id": "59841c15-7453-4069-9e6b-af0e9b24dbd4",
      "name": "Sticky Note2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        200,
        0
      ],
      "parameters": {
        "width": 440,
        "height": 820,
        "content": "### 2. AI Agent to parse the collection process\nThis node will analyze the content of the email to extract information about the **sender** *(name, company)* and the **collections** *(address, time wi"
      }
    },
    {
      "id": "95067b31-0ab2-48f2-b08f-ef08989c81ac",
      "name": "OpenAI Chat Model2",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "position": [
        260,
        660
      ]
    },
    {
      "id": "48a5b173-0022-4628-b4c2-acb8a0a19122",
      "name": "Sticky Note3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        800,
        1120
      ],
      "parameters": {
        "width": 680,
        "height": 720,
        "content": "### 4. Reply with a confirmation of shipment allocation\nWe first collect all the information of the sequence of pickups from the **Google Sheets** the AI Agent will use that to generate a reply by ema"
      }
    },
    {
      "id": "bb47b105-1f97-4b23-b92c-dbe318ab21f9",
      "name": "Loop Over Items",
      "type": "n8n-nodes-base.splitInBatches",
      "position": [
        1080,
        460
      ]
    },
    {
      "id": "60ede508-1b35-4ce3-a316-b23bd8d59ef3",
      "name": "Split by Address",
      "type": "n8n-nodes-base.splitOut",
      "position": [
        840,
        460
      ]
    },
    {
      "id": "5325cb92-2d71-4416-a521-1c911b1f6df3",
      "name": "Extract Job",
      "type": "n8n-nodes-base.code",
      "position": [
        1580,
        700
      ]
    },
    {
      "id": "6d56227b-9c13-4924-86b3-53573ead3642",
      "name": "Jobs Mapping",
      "type": "n8n-nodes-base.set",
      "position": [
        1240,
        920
      ]
    },
    {
      "id": "17afe2de-5512-4c23-bc31-a67ebd10a3c8",
      "name": "Format Jobs",
      "type": "n8n-nodes-base.code",
      "position": [
        1040,
        700
      ]
    },
    {
      "id": "ea3ebcd5-76c6-43cf-a486-bb778d473c0d",
      "name": "Split Jobs",
      "type": "n8n-nodes-base.splitOut",
      "position": [
        1480,
        920
      ]
    },
    {
      "id": "1af40684-cb06-455c-b6f5-0684c06438c3",
      "name": "Merge Sequence with coordinates",
      "type": "n8n-nodes-base.merge",
      "position": [
        1820,
        780
      ]
    },
    {
      "id": "4d77cac0-5d3a-4778-aa98-ad10e3aa33b2",
      "name": "Format GPS Coordinates",
      "type": "n8n-nodes-base.set",
      "position": [
        2020,
        780
      ]
    },
    {
      "id": "308f8e6b-ea6a-484f-ac0e-3593fd197360",
      "name": "Save Sequence & Duration",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        2200,
        780
      ]
    },
    {
      "id": "d1f64c61-2b7e-4454-b10d-7d9d49998eb7",
      "name": "Format Schedule",
      "type": "n8n-nodes-base.code",
      "position": [
        1000,
        1520
      ]
    }
  ],
  "connections": {
    "5 sec": {
      "main": [
        [
          {
            "node": "Loop Over Items",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "GPS Pickup": {
      "main": [
        [
          {
            "node": "Save Pickup GPS",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Split Jobs": {
      "main": [
        [
          {
            "node": "Merge Sequence with coordinates",
            "type": "main",
            "index": 1
          }
        ]
      ]
    },
    "Extract Job": {
      "main": [
        [
          {
            "node": "Merge Sequence with coordinates",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Format Jobs": {
      "main": [
        [
          {
            "node": "Request Open Route API",
            "type": "main",
            "index": 0
          },
          {
            "node": "Jobs Mapping",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Jobs Mapping": {
      "main": [
        [
          {
            "node": "Split Jobs",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Gmail Trigger": {
      "main": [
        [
          {
            "node": "AI Agent Parser",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "AI Agent Reply": {
      "main": [
        [
          {
            "node": "Reply",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "AI Agent Parser": {
      "main": [
        [
          {
            "node": "Split by Address",
            "type": "main",
            "index": 0
          },
          {
            "node": "Collect Coordinates",
            "type": "main",
            "index": 0
          },
          {
            "node": "Collect Shipment Information",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Format Schedule": {
      "main": [
        [
          {
            "node": "AI Agent Reply",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Loop Over Items": {
      "main": [
        [],
        [
          {
            "node": "Record Email Content",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Save Pickup GPS": {
      "main": [
        [
          {
            "node": "5 sec",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Split by Address": {
      "main": [
        [
          {
            "node": "Loop Over Items",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "AI Agent Reply",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI Chat Model2": {
      "ai_languageModel": [
        [
          {
            "node": "AI Agent Parser",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Collect Coordinates": {
      "main": [
        [
          {
            "node": "Format Jobs",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Record Email Content": {
      "main": [
        [
          {
            "node": "Query Open Route API Pickup",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Format GPS Coordinates": {
      "main": [
        [
          {
            "node": "Save Sequence & Duration",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Request Open Route API": {
      "main": [
        [
          {
            "node": "Extract Job",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Structured Output Parser": {
      "ai_outputParser": [
        [
          {
            "node": "AI Agent Parser",
            "type": "ai_outputParser",
            "index": 0
          }
        ]
      ]
    },
    "Query Open Route API Pickup": {
      "main": [
        [
          {
            "node": "GPS Pickup",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Collect Shipment Information": {
      "main": [
        [
          {
            "node": "Format Schedule",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Merge Sequence with coordinates": {
      "main": [
        [
          {
            "node": "Format GPS Coordinates",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}