{
  "name": "📦 Electronic data interchange (EDI) message parsing with Gmail and Google Sheet",
  "nodes": [
    {
      "id": "bc49829b-45f2-4910-9c37-907271982f14",
      "name": "Sticky Note3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -4200,
        -560
      ],
      "parameters": {
        "width": 780,
        "height": 540,
        "content": "### 5. Do you need more details?\nFind a step-by-step guide in this tutorial\n![Guide](https://www.samirsaci.com/content/images/2025/04/EDI-Message-Parser.png)\n[🎥 Watch My Tutorial](https://youtu.be/-ph"
      }
    },
    {
      "id": "fca5a1f8-874b-4b25-92af-066e7ca03f67",
      "name": "Order Information",
      "type": "n8n-nodes-base.set",
      "position": [
        -4360,
        -1000
      ]
    },
    {
      "id": "3598dc97-a0d3-4d34-8220-b91925014e4a",
      "name": "Return Orders",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        -3620,
        -960
      ]
    },
    {
      "id": "edfa5ef9-3095-47c2-ad80-c09cac647823",
      "name": "Outbound Orders",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        -3640,
        -780
      ]
    },
    {
      "id": "6d1c614f-9301-4f25-ab11-350018f145e3",
      "name": "Order Type",
      "type": "n8n-nodes-base.if",
      "position": [
        -3840,
        -880
      ]
    },
    {
      "id": "fc206367-2fbf-4943-b2ce-9fe399dd2730",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -5420,
        -1240
      ],
      "parameters": {
        "width": 380,
        "height": 620,
        "content": "### 1. Workflow Trigger with Gmail Trigger\nThe workflow is triggered by a new email received in your Gmail mailbox. \nIf the subject includes the string \"EDI\" we proceed, if not we do nothing.\n\n#### Ho"
      }
    },
    {
      "id": "c6da1a85-d725-4a41-b63f-504fa8b552fb",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -5420,
        -540
      ],
      "parameters": {
        "width": 800,
        "height": 880,
        "content": "### Example of EDI Message\nYou can send yourself this email to test the workflow.\n\nUNA:+.? '\nUNB+UNOC:3+SENDER_ID+RECEIVER_ID+240317:1200+ORDER67890'\nUNH+1+ORDERS:D:96A:UN'\nBGM+220+PO56789012+9'\nDTM+1"
      }
    },
    {
      "id": "4c82f8ff-e405-4e5f-8386-9c622805023a",
      "name": "Sticky Note2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -4980,
        -1240
      ],
      "parameters": {
        "width": 440,
        "height": 620,
        "content": "### 2. Get Email Body & Parse EDI Message\nThe first node extracts the email body using the ID from the trigger. This body is parsed using the code node to extract order information.\n\n#### How to setup"
      }
    },
    {
      "id": "e90096b1-ad36-4b18-96a2-9259377b4873",
      "name": "Email Trigger",
      "type": "n8n-nodes-base.gmailTrigger",
      "position": [
        -5400,
        -860
      ]
    },
    {
      "id": "26433f0f-487d-49dc-8de7-d4bd3bcf895c",
      "name": "Subject includes EDI",
      "type": "n8n-nodes-base.if",
      "position": [
        -5180,
        -860
      ]
    },
    {
      "id": "6960941f-6b49-41c2-88c6-9442bcb7cb34",
      "name": "Extract Body",
      "type": "n8n-nodes-base.set",
      "position": [
        -4820,
        -860
      ]
    },
    {
      "id": "6e64556e-07ce-4d9d-89fc-07971dd9c553",
      "name": "Get Email",
      "type": "n8n-nodes-base.gmail",
      "position": [
        -4960,
        -860
      ]
    },
    {
      "id": "0346eabe-552a-47d8-ac9e-9619926d0242",
      "name": "Parse EDI Message",
      "type": "n8n-nodes-base.code",
      "position": [
        -4660,
        -860
      ]
    },
    {
      "id": "0fa4b446-bb37-48ab-a44b-8b2c52e2660b",
      "name": "Sticky Note4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -4100,
        -1240
      ],
      "parameters": {
        "width": 700,
        "height": 620,
        "content": "### 4. Store the Transactions in a Google Sheet\nThis block will filter the order based on the order type (Return Orders, Outbound Orders) extracted from the order information node. Results are stored "
      }
    },
    {
      "id": "7a1451db-9390-431f-bca5-54a537ff8016",
      "name": "Order Info + Orderlines",
      "type": "n8n-nodes-base.merge",
      "position": [
        -4040,
        -880
      ]
    },
    {
      "id": "e64a1db7-4c22-4925-9597-9c14fdddbfe4",
      "name": "Flatten Data to Orderlines",
      "type": "n8n-nodes-base.code",
      "position": [
        -4460,
        -860
      ]
    },
    {
      "id": "5b56fe40-9cfb-4668-946d-470dc9e3a39e",
      "name": "Split Out by Line",
      "type": "n8n-nodes-base.splitOut",
      "position": [
        -4280,
        -860
      ]
    },
    {
      "id": "903399b2-cdee-40c0-99cb-1c44d84e96d2",
      "name": "Sticky Note5",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -4480,
        -1240
      ],
      "parameters": {
        "width": 320,
        "height": 620,
        "content": "### 3. Process Parsed Data\nThis block extract order information and format the orderlines to be stored in a google sheet.\n\n#### How to setup?\nNothing to do."
      }
    }
  ],
  "connections": {
    "Get Email": {
      "main": [
        [
          {
            "node": "Extract Body",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Order Type": {
      "main": [
        [
          {
            "node": "Return Orders",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Outbound Orders",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Extract Body": {
      "main": [
        [
          {
            "node": "Parse EDI Message",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Email Trigger": {
      "main": [
        [
          {
            "node": "Subject includes EDI",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Order Information": {
      "main": [
        [
          {
            "node": "Order Info + Orderlines",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Parse EDI Message": {
      "main": [
        [
          {
            "node": "Order Information",
            "type": "main",
            "index": 0
          },
          {
            "node": "Flatten Data to Orderlines",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Split Out by Line": {
      "main": [
        [
          {
            "node": "Order Info + Orderlines",
            "type": "main",
            "index": 1
          }
        ]
      ]
    },
    "Subject includes EDI": {
      "main": [
        [
          {
            "node": "Get Email",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Order Info + Orderlines": {
      "main": [
        [
          {
            "node": "Order Type",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Flatten Data to Orderlines": {
      "main": [
        [
          {
            "node": "Split Out by Line",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}