Automate EDI Order Parsing with Gmail & Google Sheets in n8n

This workflow automates processing EDI return and outbound orders received via Gmail. It parses complex EDI email messages, extracts detailed order data, and stores it smartly in Google Sheets, freeing hours of manual work and errors.
gmailTrigger
googleSheets
code
+5
Workflow Identifier: 1917
NODES in Use: Gmail Trigger, If, Gmail, Set, Code, Split Out, Merge, Google Sheets

Press CTRL+F5 if the workflow didn't load.

Learn how to Build this Workflow with AI:

Visit through Desktop for Best experience

What this workflow does

This workflow helps read emails with “EDI” in the subject from Gmail. It takes the complex EDI message inside the email, breaks it down, and gets order details like order types, dates, parties, and line items. Then, it puts return orders and outbound orders in separate tabs in Google Sheets. This saves hours from manually copying data and avoids mistakes.


Who should use this workflow

Any business handling many EDI orders by email who wants to stop manual data entry for orders. It is good for people who want to easily check and organize order data. Users should have basic access to Gmail and Google Sheets and want automation for better accuracy and speed.


Tools and services used

  • Gmail API: To watch for new emails and get full email content.
  • n8n Workflow Automation: To build the automated process connecting Gmail, parsing, and Google Sheets.
  • Google Sheets API: To add parsed order lines to specific spreadsheet tabs.
  • JavaScript Code Nodes: To interpret EDI format messages inside emails and flatten data.

Inputs, processing steps, and outputs

Inputs

  • Emails in Gmail inbox with “EDI” in subject line.
  • Raw EDI message inside the email plain text body.

Processing steps

  • Check Gmail every minute for new emails matching “EDI” subject filter.
  • Download full email content including plain text body.
  • Clean and extract the EDI message text from email body.
  • Use JavaScript to parse EDI segments: UNB (envelope), UNH (header), BGM (document info), DTM (dates), NAD (parties), LIN and related nodes (order lines).
  • Flatten nested parsed data into rows combining document header with each order line.
  • Split orders by document type into Return Orders or Outbound Orders branch.
  • Append data rows to two separate Google Sheets tabs dedicated to returns and outbound orders.

Outputs

  • Return order details saved as rows in “Return Orders” Google Sheet tab.
  • Outbound order details saved as rows in “Outbound Orders” Google Sheet tab.

Beginner step-by-step: How to build this workflow in n8n

Importing and setup

  1. Inside the n8n editor, click the Download button on this page and save the workflow file to your computer.
  2. In n8n, use the “Import from File” function to upload the downloaded workflow file.
  3. Open the imported workflow. Add your Gmail and Google Sheets API credentials if not already done.
  4. Check each node needing setting, update email filters, spreadsheet IDs, sheet names, or other values to match your environment.
  5. If there is JavaScript code node for parsing, verify no changes needed unless your EDI format differs.

Testing and activation

  1. Run the workflow once manually with a test email containing an EDI message to confirm parsing and sheet updates work as expected.
  2. After successful test, toggle the workflow from inactive to active to let it run automatically.
  3. The workflow will now check Gmail every minute, parse incoming EDI emails, and update Google Sheets without manual work.

For setups running n8n on your own server, explore self-host n8n for full control.


Common issues and fixes

  • Emails not triggering workflow: Check Gmail API credentials are valid and polling is enabled.
  • EDI parsing errors: Confirm the raw email body text is captured correctly in the “Extract Body” node.
  • Google Sheets writing fails: Ensure Google Sheets node credentials and sheet/tab names are correct and access is allowed.

Customization ideas

  • Add filters by sender email to only process trusted partners.
  • Expand JavaScript parser code to extract more EDI fields like tax or discounts if needed.
  • Use different Google spreadsheets for return and outbound orders by adjusting spreadsheet IDs.
  • Add messaging platforms like Slack to notify teams when new orders arrive.
  • Set workflow to run only during work hours by adding a Cron node before Gmail trigger.

Summary of benefits and results

✓ Time saved from manual data entry—more than 3 hours daily.
✓ Fewer errors by automating EDI parsing and data logging.
✓ Clear separation of return and outbound orders in Google Sheets.
✓ Better order visibility and faster processing.
✓ Easy to test and activate inside n8n with basic setup steps.


Frequently Asked Questions

The workflow uses a Gmail trigger node that checks emails every minute and filters those with “EDI” in the subject line.
The JavaScript parser code will need updating to handle the new EDI segments or structure.
Yes, by changing spreadsheet IDs in the Google Sheets nodes, it can write to different files.
Check the Google Sheets API credentials, sheet or tab names, and ensure the user has write permissions.

Promoted by BULDRR AI

Related Workflows

Automate Viral UGC Video Creation Using n8n + Degaus (Beginner-Friendly Guide)

Learn how to automate viral UGC video creation using n8n, AI prompts, and Degaus. This beginner-friendly guide shows how to import, configure, and run the workflow without technical complexity.
Form Trigger
Google Sheets
Gmail
+37
Free

AI SEO Blog Writer Automation in n8n

A complete beginner guide to building an AI-powered SEO blog writer automation using n8n.
AI Agent
Google Sheets
httpRequest
+5
Free

Automate CrowdStrike Alerts with VirusTotal, Jira & Slack

This workflow automates processing of CrowdStrike detections by enriching threat data via VirusTotal, creating Jira tickets for incident tracking, and notifying teams on Slack for quick response. Save hours daily by transforming complex threat data into actionable alerts effortlessly.
scheduleTrigger
httpRequest
jira
+5
Free

Automate Telegram Invoices to Notion with AI Summaries & Reports

Save hours on financial tracking by automating invoice extraction from Telegram photos to Notion using Google Gemini AI. This workflow extracts data, records transactions, and generates detailed spending reports with charts sent on schedule via Telegram.
lmChatGoogleGemini
telegramTrigger
notion
+9
Free

Automate Email Replies with n8n and AI-Powered Summarization

Save hours managing your inbox with this n8n workflow that uses IMAP email triggers, AI summarization, and vector search to draft concise replies requiring minimal review. Automate business email processing efficiently with AI guidance and Gmail integration.
emailReadImap
vectorStoreQdrant
emailSend
+12
Free

Automate Email Campaigns Using n8n with Gmail & Google Sheets

This n8n workflow automates personalized email outreach campaigns by integrating Gmail and Google Sheets, saving hours of manual follow-up work and reducing errors in email sequences. It ensures timely follow-ups based on previous email interactions, optimizing communication efficiency.
googleSheets
gmail
code
+5
Free