{
  "workflow": {
    "id": 1453,
    "name": "Parse email body message",
    "views": 7433,
    "recentViews": 0,
    "totalViews": 7433,
    "createdAt": "2022-02-16T06:04:29.091Z",
    "description": "# Who we are\n\nWe are **Aprende n8n**, the first n8n Spanish course for all n8n lovers.\nIf you want to learn more, you can find out more at [Aprende n8n](https://aprenden8n.com).\n\n# Task goal\n\nThis task allows extracting data from any email body with a NoCode snippet.\n\n# An small explanation\n\nYou receive an email when a user submits a form from your website.\n\nAll those emails usually have the same structure as the next one:\n```\nName: Miquel\nEmail: miquel@aprenden8n.com\nSubject: Welcome aboard\nMessage: Hi Miquel!\n\nThank you for your signup!\n```\n\n\nThis task allows to parse any email body and assign all values to the defined labels, getting an output like this:\n```\n{\n\"Name\": \"Miquel\",\n\"Email\": \"miquel@aprenden8n.com\",\n\"Subject\": \"Welcome aboard\",\n\"Message\" \"Hi Miquel! Thank you for your signup!\"\n}\n```\n\n# After importing it\n\nWhen you import the import, you get the next task in your n8n:\n![aprenden8n.com_email_parser_task.jpeg](fileId:613)\n\nWe recommend importing this workflow into your current task and adapting it.\nYou define a couple of variables in the \"Set values\" SET:\n- body: the email body you want to parse. You can add this as an expression from previous variables.\n- labels: the keywords you want to detect and parse. Labels are case insensitive.\n\nWe define the next values:\n\nBody\n```\nName: Miquel\nEmail: miquel@aprenden8n.com\nSubject: Welcome aboard\nMessage: Hi Miquel!\n\nThank you for your signup!\n```\nLabels\n```\nName,Email,Subject,Message\n```\n\nA screenshot of the Set output is the next one\n![aprenden8n.com_email_parser_set.jpeg](fileId:611)\n\nIf we check the \"Function item\" Node, we get the next content after executing the task:\n![aprenden8n.com_email_parser_output.jpeg](fileId:612)\n\n\n# Capabilities\n\nThe task has the next features:\n- You can detect as many labels as you want.\n- Label detection is case insensitive.\n- You can use the snippet as an independent workflow to call it generically, adding the Function item to the workflow and passing body and labels as paremeters.\n\n# Limitations\n\nThis task has limitations:\n- The parser only accepts the multiline values at the end of the email. \n\n\n# Help and comments\n\nIf you have any doubt about this snippet, please, contact us at miquel@aprenden8n.com.\n\nYou can contact us at [Aprende n8n](https://aprenden8n.com) or in the [Spanish n8n community](https://t.me/comunidadn8n)\n",
    "workflow": {
      "id": "340",
      "name": "Email body parser by aprenden8n.com",
      "nodes": [
        {
          "name": "On clicking 'execute'",
          "type": "n8n-nodes-base.manualTrigger",
          "position": [
            250,
            300
          ],
          "parameters": {},
          "typeVersion": 1
        },
        {
          "name": "Email Parser Snippet",
          "type": "n8n-nodes-base.functionItem",
          "position": [
            670,
            300
          ],
          "parameters": {
            "functionCode": "var obj = {};\nvar labels = item.labels.split(\",\");\nitem.labels.split(\",\").forEach(function(label) {\n  var re = labels.indexOf(label) === labels.length - 1 ? \"\\\\b\" + label + \"\\\\b[: ]+([^$]+)\" : \"\\\\b\" + label + \"\\\\b[: ]+([^\\\\n$]+)\";\n  var found = item.body.match(new RegExp(re, \"i\"));\n  if (found && found.length > 1) {\n    obj[label] = found[1].trim();\n  }\n});\n\nreturn obj;"
          },
          "typeVersion": 1
        },
        {
          "name": "Set values",
          "type": "n8n-nodes-base.set",
          "position": [
            460,
            300
          ],
          "parameters": {
            "values": {
              "number": [],
              "string": [
                {
                  "name": "body",
                  "value": "Name: Miquel\nEmail: user@example.com\nSubject: Welcome aboard\nMessage: Hi Miquel!\n\nThank you for your signup!"
                },
                {
                  "name": "labels",
                  "value": "Name,Email,Subject,Message"
                }
              ]
            },
            "options": {}
          },
          "typeVersion": 1
        }
      ],
      "active": false,
      "settings": {},
      "connections": {
        "Set values": {
          "main": [
            [
              {
                "node": "Email Parser Snippet",
                "type": "main",
                "index": 0
              }
            ]
          ]
        },
        "On clicking 'execute'": {
          "main": [
            [
              {
                "node": "Set values",
                "type": "main",
                "index": 0
              }
            ]
          ]
        }
      }
    },
    "lastUpdatedBy": null,
    "workflowInfo": {
      "nodeCount": 3,
      "nodeTypes": {
        "n8n-nodes-base.set": {
          "count": 1
        },
        "n8n-nodes-base.functionItem": {
          "count": 1
        },
        "n8n-nodes-base.manualTrigger": {
          "count": 1
        }
      }
    },
    "status": "published",
    "readyToDemo": null,
    "user": {
      "name": "Miquel Colomer",
      "username": "mcolomer",
      "bio": "As a passionate developer and AI agent creator, I’ve been at the forefront of automation, pioneering workflows and training AI to handle complex tasks seamlessly. I’m an early adopter and expert of n8n, having worked with its powerful capabilities to create automation solutions for diverse industries. I founded n8nhackers, the first AI-powered agency focused on n8n, where we help businesses transform their workflows with cutting-edge automation.",
      "verified": true,
      "links": [
        "https://n8nhackers.com"
      ],
      "avatar": "https://gravatar.com/avatar/c4974f5be3985d7f30465d2d963967905bcb2f9b8a8ecaf8ba4396bfbd034db2?r=pg&d=retro&size=200"
    },
    "nodes": [
      {
        "id": 15,
        "icon": "fa:code",
        "name": "n8n-nodes-base.functionItem",
        "codex": {
          "data": {
            "alias": [
              "Javascript",
              "Code",
              "Custom Code",
              "JS"
            ],
            "resources": {
              "generic": [
                {
                  "url": "https://n8n.io/blog/how-uproc-scraped-a-multi-page-website-with-a-low-code-workflow/",
                  "icon": " 🕸️",
                  "label": "How uProc scraped a multi-page website with a low-code workflow"
                },
                {
                  "url": "https://n8n.io/blog/aws-workflow-automation/",
                  "label": "7 no-code workflow automations for Amazon Web Services"
                }
              ],
              "primaryDocumentation": [
                {
                  "url": "https://docs.n8n.io/integrations/builtin/core-nodes/n8n-nodes-base.code/"
                }
              ]
            },
            "categories": [
              "Development",
              "Core Nodes"
            ],
            "nodeVersion": "1.0",
            "codexVersion": "1.0",
            "subcategories": {
              "Core Nodes": [
                "Data Transformation"
              ]
            }
          }
        },
        "group": "[\"transform\"]",
        "defaults": {
          "name": "Function Item",
          "color": "#ddbb33"
        },
        "iconData": {
          "icon": "code",
          "type": "icon"
        },
        "displayName": "Function Item",
        "typeVersion": 1,
        "nodeCategories": [
          {
            "id": 5,
            "name": "Development"
          },
          {
            "id": 9,
            "name": "Core Nodes"
          }
        ]
      },
      {
        "id": 38,
        "icon": "fa:pen",
        "name": "n8n-nodes-base.set",
        "codex": {
          "data": {
            "alias": [
              "Set",
              "JS",
              "JSON",
              "Filter",
              "Transform",
              "Map"
            ],
            "resources": {
              "generic": [
                {
                  "url": "https://n8n.io/blog/learn-to-automate-your-factorys-incident-reporting-a-step-by-step-guide/",
                  "icon": "🏭",
                  "label": "Learn to Automate Your Factory's Incident Reporting: A Step by Step Guide"
                },
                {
                  "url": "https://n8n.io/blog/2021-the-year-to-automate-the-new-you-with-n8n/",
                  "icon": "☀️",
                  "label": "2021: The Year to Automate the New You with n8n"
                },
                {
                  "url": "https://n8n.io/blog/automatically-pulling-and-visualizing-data-with-n8n/",
                  "icon": "📈",
                  "label": "Automatically pulling and visualizing data with n8n"
                },
                {
                  "url": "https://n8n.io/blog/database-monitoring-and-alerting-with-n8n/",
                  "icon": "📡",
                  "label": "Database Monitoring and Alerting with n8n"
                },
                {
                  "url": "https://n8n.io/blog/automatically-adding-expense-receipts-to-google-sheets-with-telegram-mindee-twilio-and-n8n/",
                  "icon": "🧾",
                  "label": "Automatically Adding Expense Receipts to Google Sheets with Telegram, Mindee, Twilio, and n8n"
                },
                {
                  "url": "https://n8n.io/blog/no-code-ecommerce-workflow-automations/",
                  "icon": "store",
                  "label": "6 e-commerce workflows to power up your Shopify s"
                },
                {
                  "url": "https://n8n.io/blog/how-to-build-a-low-code-self-hosted-url-shortener/",
                  "icon": "🔗",
                  "label": "How to build a low-code, self-hosted URL shortener in 3 steps"
                },
                {
                  "url": "https://n8n.io/blog/automate-your-data-processing-pipeline-in-9-steps-with-n8n/",
                  "icon": "⚙️",
                  "label": "Automate your data processing pipeline in 9 steps"
                },
                {
                  "url": "https://n8n.io/blog/how-to-get-started-with-crm-automation-and-no-code-workflow-ideas/",
                  "icon": "👥",
                  "label": "How to get started with CRM automation (with 3 no-code workflow ideas"
                },
                {
                  "url": "https://n8n.io/blog/5-tasks-you-can-automate-with-notion-api/",
                  "icon": "⚡️",
                  "label": "5 tasks you can automate with the new Notion API "
                },
                {
                  "url": "https://n8n.io/blog/automate-google-apps-for-productivity/",
                  "icon": "💡",
                  "label": "15 Google apps you can combine and automate to increase productivity"
                },
                {
                  "url": "https://n8n.io/blog/how-uproc-scraped-a-multi-page-website-with-a-low-code-workflow/",
                  "icon": " 🕸️",
                  "label": "How uProc scraped a multi-page website with a low-code workflow"
                },
                {
                  "url": "https://n8n.io/blog/building-an-expense-tracking-app-in-10-minutes/",
                  "icon": "📱",
                  "label": "Building an expense tracking app in 10 minutes"
                },
                {
                  "url": "https://n8n.io/blog/the-ultimate-guide-to-automate-your-video-collaboration-with-whereby-mattermost-and-n8n/",
                  "icon": "📹",
                  "label": "The ultimate guide to automate your video collaboration with Whereby, Mattermost, and n8n"
                },
                {
                  "url": "https://n8n.io/blog/5-workflow-automations-for-mattermost-that-we-love-at-n8n/",
                  "icon": "🤖",
                  "label": "5 workflow automations for Mattermost that we love at n8n"
                },
                {
                  "url": "https://n8n.io/blog/learn-to-build-powerful-api-endpoints-using-webhooks/",
                  "icon": "🧰",
                  "label": "Learn to Build Powerful API Endpoints Using Webhooks"
                },
                {
                  "url": "https://n8n.io/blog/how-a-membership-development-manager-automates-his-work-and-investments/",
                  "icon": "📈",
                  "label": "How a Membership Development Manager automates his work and investments"
                },
                {
                  "url": "https://n8n.io/blog/a-low-code-bitcoin-ticker-built-with-questdb-and-n8n-io/",
                  "icon": "📈",
                  "label": "A low-code bitcoin ticker built with QuestDB and n8n.io"
                },
                {
                  "url": "https://n8n.io/blog/how-to-set-up-a-ci-cd-pipeline-with-no-code/",
                  "icon": "🎡",
                  "label": "How to set up a no-code CI/CD pipeline with GitHub and TravisCI"
                },
                {
                  "url": "https://n8n.io/blog/benefits-of-automation-and-n8n-an-interview-with-hubspots-hugh-durkin/",
                  "icon": "🎖",
                  "label": "Benefits of automation and n8n: An interview with HubSpot's Hugh Durkin"
                },
                {
                  "url": "https://n8n.io/blog/how-goomer-automated-their-operations-with-over-200-n8n-workflows/",
                  "icon": "🛵",
                  "label": "How Goomer automated their operations with over 200 n8n workflows"
                },
                {
                  "url": "https://n8n.io/blog/aws-workflow-automation/",
                  "label": "7 no-code workflow automations for Amazon Web Services"
                }
              ],
              "primaryDocumentation": [
                {
                  "url": "https://docs.n8n.io/integrations/builtin/core-nodes/n8n-nodes-base.set/"
                }
              ]
            },
            "categories": [
              "Core Nodes"
            ],
            "nodeVersion": "1.0",
            "codexVersion": "1.0",
            "subcategories": {
              "Core Nodes": [
                "Data Transformation"
              ]
            }
          }
        },
        "group": "[\"input\"]",
        "defaults": {
          "name": "Edit Fields"
        },
        "iconData": {
          "icon": "pen",
          "type": "icon"
        },
        "displayName": "Edit Fields (Set)",
        "typeVersion": 3,
        "nodeCategories": [
          {
            "id": 9,
            "name": "Core Nodes"
          }
        ]
      },
      {
        "id": 42,
        "icon": "fa:play",
        "name": "n8n-nodes-base.start",
        "codex": {
          "data": {
            "resources": {
              "generic": [
                {
                  "url": "https://n8n.io/blog/why-business-process-automation-with-n8n-can-change-your-daily-life/",
                  "icon": "🧬",
                  "label": "Why business process automation with n8n can change your daily life"
                },
                {
                  "url": "https://n8n.io/blog/why-i-chose-n8n-over-zapier-in-2020/",
                  "icon": "😍",
                  "label": "Why I chose n8n over Zapier in 2020"
                },
                {
                  "url": "https://n8n.io/blog/automatically-pulling-and-visualizing-data-with-n8n/",
                  "icon": "📈",
                  "label": "Automatically pulling and visualizing data with n8n"
                },
                {
                  "url": "https://n8n.io/blog/how-to-use-the-http-request-node-the-swiss-army-knife-for-workflow-automation/",
                  "icon": "🧰",
                  "label": "How to use the HTTP Request Node - The Swiss Army Knife for Workflow Automation"
                },
                {
                  "url": "https://n8n.io/blog/sending-sms-the-low-code-way-with-airtable-twilio-programmable-sms-and-n8n/",
                  "icon": "📱",
                  "label": "Sending SMS the Low-Code Way with Airtable, Twilio Programmable SMS, and n8n"
                },
                {
                  "url": "https://n8n.io/blog/automating-conference-organization-processes-with-n8n/",
                  "icon": "🙋‍♀️",
                  "label": "Automating Conference Organization Processes with n8n"
                }
              ],
              "primaryDocumentation": [
                {
                  "url": "https://docs.n8n.io/integrations/builtin/core-nodes/n8n-nodes-base.start/"
                }
              ]
            },
            "categories": [
              "Core Nodes"
            ],
            "nodeVersion": "1.0",
            "codexVersion": "1.0"
          }
        },
        "group": "[\"input\"]",
        "defaults": {
          "name": "Start",
          "color": "#00e000"
        },
        "iconData": {
          "icon": "play",
          "type": "icon"
        },
        "displayName": "Start",
        "typeVersion": 1,
        "nodeCategories": [
          {
            "id": 9,
            "name": "Core Nodes"
          }
        ]
      }
    ],
    "categories": [
      {
        "id": 41,
        "name": "Ticket Management"
      }
    ],
    "image": [
      {
        "id": 611,
        "url": "https://f000.backblazeb2.com/file/n8n-website-images/08fb8895849941c1881ef1f105c1d53f.jpeg"
      },
      {
        "id": 612,
        "url": "https://f000.backblazeb2.com/file/n8n-website-images/e7a84395603a49d3971f25b4dc8af6c2.jpeg"
      },
      {
        "id": 613,
        "url": "https://f000.backblazeb2.com/file/n8n-website-images/f30421fd57a74bd9b98895bd330abe2f.jpeg"
      }
    ]
  }
}