{ "updatedAt": "2026-03-29T18:33:43.163Z", "createdAt": "2025-07-05T06:04:09.291Z", "id": "yNLjtV9yG0T6CqSr", "name": "Bestell-Eingang Online-Shop", "description": null, "active": true, "isArchived": false, "nodes": [ { "parameters": { "format": "resolved", "options": {} }, "type": "n8n-nodes-base.emailReadImap", "typeVersion": 2, "position": [ -272, -768 ], "id": "def6f3b1-b241-4e6c-89b1-63e4a0c12258", "name": "Email Trigger (IMAP)", "credentials": { "imap": { "id": "5jzK2kuSVJ8NWL1D", "name": "IMAP account 4" } } }, { "parameters": { "content": "Eingang ist Bestellung", "height": 520, "width": 860 }, "type": "n8n-nodes-base.stickyNote", "position": [ 80, -960 ], "typeVersion": 1, "id": "cec90477-28bf-45fd-a220-72edb7e20297", "name": "Sticky Note" }, { "parameters": { "modelId": { "__rl": true, "value": "deepseek/deepseek-v3.2", "mode": "list", "cachedResultName": "DEEPSEEK/DEEPSEEK-V3.2" }, "messages": { "values": [ { "content": "=Your input is this HTML-Mail: {{ $json.html }}\nYou are a JSON extractor for our order-processing pipeline.\nGiven the raw email HTML/text, you must output exactly one JSON object matching our schema, with these keys (in any order):\n\n*Section Bestellinformationen*\nBestellungNr, Zahlungsstatus, Zahlungsmethode, \n*Section Zahlungsinformationen*\nVorname_RgAdr, Nachname_RgAdr, Strasse_RgAdr, Hausnummer_RgAdr, Stadt_RgAdr, Bundesland_RgAdr, PLZ_RgAdr, Land_RgAdr, EmailKunde, \n*Section Lieferinformationen*\nVorname_LfAdr, Nachname_LfAdr, Strasse_LfAdr, Hausnummer_LfAdr, Stadt_LfAdr, Bundesland_LfAdr, PLZ_LfAdr, Land_LfAdr,\n*Section Versandmethode\"\nLiefermethode\n\n*Section Bestelldetails*\nEach lineItems entry must be an object with exactly these keys: \ntitel (Name of the item), artikelnummer, preisEinheit (CHF Price per lineitem divided by #Items), artikelanzahl (Anzahl)\n*Bottom-Sections*\nNetto, Versandkosten, Mehrwertsteuer, Rabatt (add to total if several Rabatte exist in the section), Rabattcode (is the name of the rabatt in the left column on the line of the rabatt sum) Gesamtsumme, \n\n\nImportant: \n- Output only the JSON object (no surrounding array, no code fences, no explanations). \n- Use string values for all text fields and numbers for all numeric fields. \n- If a field is missing or empty, output an empty string (\"\") for text or 0 for numbers.\n\nExtract the order details from the given raw email (HTML or text) and respond with only the JSON object below—no code fences, no markdown, no surrounding array, no keys like index or message. It must match exactly this schema (ordering doesn’t matter):\n\n{\n \"BestellungNr\": string,\n \"Zahlungsstatus\": string,\n \"Zahlungsmethode\": string,\n \"Vorname_RgAdr\": string,\n \"Nachname_RgAdr\": string,\n \"Strasse_RgAdr\": string,\n \"Hausnummer_RgAdr\": string,\n \"Stadt_RgAdr\": string,\n \"Bundesland_RgAdr\": string,\n \"PLZ_RgAdr\": string,\n \"Land_RgAdr\": string,\n \"EmailKunde\": string,\n \"Vorname_LfAdr\": string,\n \"Nachname_LfAdr\": string,\n \"Strasse_LfAdr\": string,\n \"Hausnummer_LfAdr\": string,\n \"Stadt_LfAdr\": string,\n \"Bundesland_LfAdr\": string,\n \"PLZ_LfAdr\": string,\n \"Land_LfAdr\": string,\n \"Liefermethode\": string,\n \"Netto\": number,\n \"Versandkosten\": number,\n \"Mehrwertsteuer\": number,\n \"Rabatt\": number,\n \"Gesamtsumme\": number,\n\"Rabattcode\": string\n \"lineItems\": [\n {\n \"titel\": string,\n \"artikelnummer\": string,\n \"preisEinheit\": number,\n \"artikelanzahl\": number\n }\n // repeat for each line item\n ]\n}" } ] }, "options": {} }, "type": "@n8n/n8n-nodes-langchain.openAi", "typeVersion": 1.8, "position": [ 144, -784 ], "id": "7ab009e6-5c24-48cb-ad34-28886cfec035", "name": "Message a model", "retryOnFail": true, "waitBetweenTries": 5000, "credentials": { "openAiApi": { "id": "CQ31lEApDEhhVATP", "name": "OpenAi OpenRouter" } } }, { "parameters": { "jsCode": "// n8n Code-Node – parse AI-Agent output into a clean JSON object\nreturn items.map(item => {\n // 1) Roh-String aus dem AI-Step ziehen\n let content = item.json.message?.content\n || item.json.content\n || '';\n \n // 2) Code-Fence und Markdown-Marker entfernen\n content = content\n .replace(/```json\\s*/g, '')\n .replace(/```/g, '')\n .trim();\n \n // 3) Falls der Agent eine Array-Antwort (z.B. “[ { … } ]”) liefert,\n // das Array parsen und das erste Objekt herausgreifen\n if (content.startsWith('[') && content.endsWith(']')) {\n let arr;\n try {\n arr = JSON.parse(content);\n } catch {\n throw new Error(`Kann AI-Array nicht parsen:\\n${content}`);\n }\n if (!Array.isArray(arr) || arr.length === 0) {\n throw new Error(`Erwartetes Array mit mindestens einem Element, bekam:\\n${content}`);\n }\n // Wenn das Array schon Deine Order-Objekte enthält (kein wrapper), nimm arr[0]\n // Andernfalls, falls es das n8n-wrapper-Format ist, grabe tiefer:\n content = JSON.stringify(\n typeof arr[0].message?.content === 'string'\n // falls das erste Element wieder ein wrapper-Objekt mit .message.content ist:\n ? JSON.parse(arr[0].message.content.replace(/```/g, '').trim())\n // sonst direkt das erste Element\n : arr[0]\n );\n }\n \n // 4) Jetzt das finale JSON parsen\n let data;\n try {\n data = JSON.parse(content);\n } catch (e) {\n throw new Error(`Failed to JSON.parse AI output:\\n${content}`);\n }\n \n // 5) Als neues Item zurückgeben\n return { json: data };\n});" }, "type": "n8n-nodes-base.code", "typeVersion": 2, "position": [ 480, -784 ], "id": "a199695a-ed3f-4b16-b1c2-0dc5bf143fd8", "name": "JSON Parsen1" }, { "parameters": { "conditions": { "options": { "caseSensitive": true, "leftValue": "", "typeValidation": "strict", "version": 3 }, "conditions": [ { "id": "dbe1657a-046d-44a2-a602-588bb6e2e83a", "leftValue": "={{ $json.headers.subject }}", "rightValue": "Neue Bestellung", "operator": { "type": "string", "operation": "contains" } } ], "combinator": "and" }, "options": {} }, "type": "n8n-nodes-base.if", "typeVersion": 2.3, "position": [ -64, -768 ], "id": "8c16451e-288d-4348-b04e-d072a133bc8f", "name": "If" }, { "parameters": { "method": "POST", "url": "https://erpnaurua.imhochrain.ch/order-import.php", "sendHeaders": true, "headerParameters": { "parameters": [ { "name": "Content-Type", "value": "application/json" }, { "name": "X-Webhook-Secret", "value": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiJmODJlZDZhOC00NzA0LTRmODAtODYxNy02MjJmZDU5MTFkNTYiLCJpc3MiOiJuOG4iLCJhdWQiOiJwdWJsaWMtYXBpIiw" } ] }, "sendBody": true, "specifyBody": "json", "jsonBody": "={{ $json }}", "options": { "response": { "response": { "responseFormat": "json" } } } }, "type": "n8n-nodes-base.httpRequest", "typeVersion": 4.2, "position": [ 736, -784 ], "id": "5c81fac4-8ca3-471a-a546-0e73995446a5", "name": "Bestellung an ERP senden" } ], "connections": { "Email Trigger (IMAP)": { "main": [ [ { "node": "If", "type": "main", "index": 0 } ] ] }, "Message a model": { "main": [ [ { "node": "JSON Parsen1", "type": "main", "index": 0 } ] ] }, "JSON Parsen1": { "main": [ [ { "node": "Bestellung an ERP senden", "type": "main", "index": 0 } ] ] }, "If": { "main": [ [ { "node": "Message a model", "type": "main", "index": 0 } ] ] }, "Bestellung an ERP senden": { "main": [ [] ] } }, "settings": { "executionOrder": "v1", "callerPolicy": "workflowsFromSameOwner", "errorWorkflow": "QQ1KFafAxgMOjKWm", "availableInMCP": false }, "staticData": { "node:Email Trigger (IMAP)": {}, "node:Email Trigger (IMAP)1": {} }, "meta": { "templateCredsSetupCompleted": true }, "pinData": { "Email Trigger (IMAP)": [ { "json": { "headers": { "return-path": "Return-Path: ", "x-original-to": "X-Original-To: n8n_naurua_bestelleingang@imhochrain.ch", "delivered-to": "Delivered-To: n8n_naurua_bestelleingang@imhochrain.ch", "received-spf": "Received-SPF: pass (bounces.wixemails.com: Sender is authorized to use 'msprvs1=20545RoK9oTDl=bounces-17751-1668086@bounces.wixemails.com' in 'mfrom' identity (mechanism 'exists:%{i}._spf.sparkpostmail.com' matched)) receiver=hz_nas2; identity=mailfrom; envelope-from=\"msprvs1=20545RoK9oTDl=bounces-17751-1668086@bounces.wixemails.com\"; helo=mta-70-25-9.wix-shared.com.sparkpostmail.com; client-ip=156.70.25.9", "authentication-results": "Authentication-Results: imhochrain.ch;\r\n\tdkim=pass (1024-bit key) header.d=stores-emails.com header.i=@stores-emails.com header.b=jsFBHei7", "received": "Received: from [10.90.46.161] ([10.90.46.161])\r\n\tby i-043224e4cc422583f.mta1vrest.sd.prd.sparkpost (ecelerity 5.2.0.75340 r(msys-ecelerity:tags/5.2.0.8)) with REST\r\n\tid 27/8B-10073-3CDF4C96; Thu, 26 Mar 2026 09:34:59 +0000", "x-msfbl": "X-MSFBL: I5/PwAFR1Omzb1UxJL4Y250GcVn79Tr/9VF5IMMBVfg=|eyJzdWJhY2NvdW50X2l\r\n\tkIjoiMTY2ODA4NiIsIm1lc3NhZ2VfaWQiOiI2OWMzYzNmZGM0Njk2NzMxMzg3MiI\r\n\tsImN1c3RvbWVyX2lkIjoiMTc3NTEiLCJyIjoibjhuX25hdXJ1YV9iZXN0ZWxsZWl\r\n\tuZ2FuZ0BpbWhvY2hyYWluLmNoIiwidGVuYW50X2lkIjoic3BjIn0=", "dkim-signature": "DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=stores-emails.com;\r\n\ts=scph0326; t=1774517699; i=@stores-emails.com;\r\n\tbh=/4WZe0NPBZ4rRG9eBwLVkQNU0JfwTneiOpmKK/Ov38E=;\r\n\th=To:Message-ID:Date:Content-Type:List-Unsubscribe-Post:Subject:\r\n\t List-Unsubscribe:From:From:To:Cc:Subject;\r\n\tb=jsFBHei7R1LKcqpF2tE8f6vPPWTYlaIOtolOZtySbszRdJW+rWb+fS5RKfAoGWTsJ\r\n\t rBD4mmIjiGNHTdF+jAyPIevNXVG8ybRw7cXk8ASx8dc0IbRVP0V5C7ZfwXZGUi0MWA\r\n\t 3iWth0ouQNtVcG/fcOlN7cPUtUHqkwppHGClMZOk=", "to": "To: n8n_naurua_bestelleingang@imhochrain.ch", "message-id": "Message-ID: <27.8B.10073.3CDF4C96@i-043224e4cc422583f.mta1vrest.sd.prd.sparkpost>", "date": "Date: Thu, 26 Mar 2026 09:34:59 +0000", "content-type": "Content-Type: multipart/alternative; boundary=\"_----myAB/yV9XX69ShxBXnnVhA===_F6/8B-10073-3CDF4C96\"", "mime-version": "MIME-Version: 1.0", "reply-to": "Reply-To: naurua.ch@gmail.com", "list-unsubscribe-post": "List-Unsubscribe-Post: List-Unsubscribe=One-Click", "subject": "Subject: Neue Bestellung (#10466)", "list-unsubscribe": "List-Unsubscribe: ", "from": "From: \"Naurua GmbH\" ", "x-abuse-id": "x-abuse-id: a052a266-8283-493d-8e9f-88a82683af01", "precedence": "Precedence: Bulk", "feedback-id": "Feedback-ID: a052a266-8283-493d-8e9f-88a82683af01:6b1c6765-7f6f-45df-b6ab-df8f41b90345:wixshoutout", "x-mailscanner-id": "X-MailScanner-ID: 211D7339758.A58F0", "x-mailscanner": "X-MailScanner: Found to be clean", "x-mailscanner-from": "X-MailScanner-From: msprvs1=20545rok9otdl=bounces-17751-1668086@bounces.wixemails.com", "x-spam-status": "X-Spam-Status: No" }, "html": "\n
\"\"/
\n
Auf deiner Website wurde eine Bestellung aufgegeben.‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ 
Die Nachricht ist nicht sichtbar? Im Browser ansehen

Neue Bestellung

Auf deiner Website wurde eine Bestellung aufgegeben.

Bestellung #10466 

Bestellinformationen

Bestellung #10466 

Datum:

26. März 2026 um 10:34 MEZ

Betrag:

CHF 54.90

Zahlungsstatus: bezahlt

Zahlungsmethode:

Kredit-/Debitkarten

Zahlungsinformationen

Holger Hannemann prakt. Naturarzt

Bahnhofplatz 11
9100 Herisau
Schweiz
 

Herisau, CH-AR, CH

9100 

mail@hannemann.ch 

Lieferinformationen

Holger Hannemann prakt. Naturarzt 

 

Bahnhofplatz 11 

 

Herisau CH-AR CH 

9100 

 

Versandmethode

shipping

Versand mit Die Schweizerische Post (1-3 Werktage)

Bestelldetails

Chaga Extrakt Tinktur 50 ml | 100% rein

Artikelnummer: 001.01

Preis: CHF 49.95

Anzahl: 1 

CHF 49.95

Zwischensumme

CHF 49.95

Versand

CHF 4.95

MwSt.

 CHF 0.00

Gesamtsumme

CHF 54.90

Diese E-Mail wurde von dieser Website gesendet.
Falls der Erhalt dieser E-Mails nicht erwünscht ist, bitte die E-Mail-Einstellungen hier ändern.
\n\"\"\n", "text": "Neue Bestellung\n\nAuf deiner Website wurde eine Bestellung aufgegeben.\n\nBestellung #10466  \n\nBestellinformationen\n\nBestelldetails\n\nKlicke auf den Link unten, um die Nachricht in einem Browser zu öffnen.\nhttps://naurua.ch/so/tr/3078e2f5-3b52-4dd2-8e38-a47eb2dda7a1\n\nDiese E-Mail wird an Abonnenten dieser Website gesendet.\nhttps://naurua.ch/so/tr/3078e2f5-3b52-4dd2-8e38-a47eb2dda7a1/c?w=z1-nY5tvv5xMH793kk24PFyY_tHVXU7Gwpm6yyIShio.eyJ1IjoiaHR0cHM6Ly93d3cubmF1cnVhLmNoLyIsImMiOiI1NTBmZmMxOC0zNGFmLTM5NDItYWI2ZS1lNDQ0NzlmMTAyOWUiLCJtIjoibWFpbCIsInJpIjoiNTE2Y2ZhZmUtZjAzNC00ZmFhLTkxODAtOWJlNTBjOGFkNDA4IiwicnQiOiJVc2VyIn0\n\nZum Abbestellen dieser E-Mail bitte hier klicken:\nhttps://manage.wix.com/_manage-preferences?token=JWE.eyJhbGciOiJBMTI4S1ciLCJlbmMiOiJBMTI4Q0JDLUhTMjU2Iiwia2lkIjoiYWRxdVA4WE8ifQ.UasP5dRUUJPkYW9s2DC7voh72ZmK2LcfJUSzSNCWt-uRdeD5GNc1aQ.ZDbXuCWhzUmDNxY5ILrM-A.DE7HSGUgMAJv9mVDO26k7bZcJyw2GBqhEPJaauGQDOy9vipoZINC8kIcATm7xvHf7cE18cZhmdQFPfzkjcGfhbD_VLhcfe7P6yOmkFLd4e0bHPEtKLE9I3bZUd7N-0d2Li7pMQzgHKgM6rVcHmyeOv-LT-zLYxtSJLKOmHHZuZMBvQ5GbTkyrDep8TwfgdlZrd8T0kXgAEzuOyh8dMs1PpR53I2a4_m3vISSlK3gs3Zcu5ZaTdFi4JXwQzqpt9YwJvHZmpYhvtR1QcGWlbDSRVFpyNVVqod0V7euzbQ9wqBFI0yvMDMt70Wpy5i-aOw8l0tOPkLAK6i_itUQIYWdfGGeExkfKw_IxzESMDz8cJ3A4gcxdRWopw1QkQvd0lyVqhqYGjOicCnYdM0O5l5YA1qOPnNcf3Wk-1NUNLBwd00.KrDqqqX_KEPspf0jWDGb8Q&locale=de", "textAsHtml": "

Neue Bestellung

Auf deiner Website wurde eine Bestellung aufgegeben.

Bestellung #10466  

Bestellinformationen

Bestelldetails

Klicke auf den Link unten, um die Nachricht in einem Browser zu öffnen.
https://naurua.ch/so/tr/3078e2f5-3b52-4dd2-8e38-a47eb2dda7a1

Diese E-Mail wird an Abonnenten dieser Website gesendet.
https://naurua.ch/so/tr/3078e2f5-3b52-4dd2-8e38-a47eb2dda7a1/c?w=z1-nY5tvv5xMH793kk24PFyY_tHVXU7Gwpm6yyIShio.eyJ1IjoiaHR0cHM6Ly93d3cubmF1cnVhLmNoLyIsImMiOiI1NTBmZmMxOC0zNGFmLTM5NDItYWI2ZS1lNDQ0NzlmMTAyOWUiLCJtIjoibWFpbCIsInJpIjoiNTE2Y2ZhZmUtZjAzNC00ZmFhLTkxODAtOWJlNTBjOGFkNDA4IiwicnQiOiJVc2VyIn0

Zum Abbestellen dieser E-Mail bitte hier klicken:
https://manage.wix.com/_manage-preferences?token=JWE.eyJhbGciOiJBMTI4S1ciLCJlbmMiOiJBMTI4Q0JDLUhTMjU2Iiwia2lkIjoiYWRxdVA4WE8ifQ.UasP5dRUUJPkYW9s2DC7voh72ZmK2LcfJUSzSNCWt-uRdeD5GNc1aQ.ZDbXuCWhzUmDNxY5ILrM-A.DE7HSGUgMAJv9mVDO26k7bZcJyw2GBqhEPJaauGQDOy9vipoZINC8kIcATm7xvHf7cE18cZhmdQFPfzkjcGfhbD_VLhcfe7P6yOmkFLd4e0bHPEtKLE9I3bZUd7N-0d2Li7pMQzgHKgM6rVcHmyeOv-LT-zLYxtSJLKOmHHZuZMBvQ5GbTkyrDep8TwfgdlZrd8T0kXgAEzuOyh8dMs1PpR53I2a4_m3vISSlK3gs3Zcu5ZaTdFi4JXwQzqpt9YwJvHZmpYhvtR1QcGWlbDSRVFpyNVVqod0V7euzbQ9wqBFI0yvMDMt70Wpy5i-aOw8l0tOPkLAK6i_itUQIYWdfGGeExkfKw_IxzESMDz8cJ3A4gcxdRWopw1QkQvd0lyVqhqYGjOicCnYdM0O5l5YA1qOPnNcf3Wk-1NUNLBwd00.KrDqqqX_KEPspf0jWDGb8Q&locale=de

", "subject": "Neue Bestellung (#10466)", "date": "2026-03-26T09:34:59.000Z", "to": { "value": [ { "address": "n8n_naurua_bestelleingang@imhochrain.ch", "name": "" } ], "html": "n8n_naurua_bestelleingang@imhochrain.ch", "text": "n8n_naurua_bestelleingang@imhochrain.ch" }, "from": { "value": [ { "address": "naurua.ch@stores-emails.com", "name": "Naurua GmbH" } ], "html": "Naurua GmbH <naurua.ch@stores-emails.com>", "text": "\"Naurua GmbH\" " }, "messageId": "<27.8B.10073.3CDF4C96@i-043224e4cc422583f.mta1vrest.sd.prd.sparkpost>", "replyTo": { "value": [ { "address": "naurua.ch@gmail.com", "name": "" } ], "html": "naurua.ch@gmail.com", "text": "naurua.ch@gmail.com" }, "attributes": { "uid": 266 } }, "pairedItem": { "item": 0 } } ], "Message a model": [ { "json": { "index": 0, "logprobs": null, "finish_reason": "stop", "native_finish_reason": "stop", "message": { "role": "assistant", "content": "{\n \"BestellungNr\": \"10466\",\n \"Zahlungsstatus\": \"bezahlt\",\n \"Zahlungsmethode\": \"Kredit-/Debitkarten\",\n \"Vorname_RgAdr\": \"Holger\",\n \"Nachname_RgAdr\": \"Hannemann prakt. Naturarzt\",\n \"Strasse_RgAdr\": \"Bahnhofplatz\",\n \"Hausnummer_RgAdr\": \"11\",\n \"Stadt_RgAdr\": \"Herisau\",\n \"Bundesland_RgAdr\": \"CH-AR\",\n \"PLZ_RgAdr\": \"9100\",\n \"Land_RgAdr\": \"Schweiz\",\n \"EmailKunde\": \"mail@hannemann.ch\",\n \"Vorname_LfAdr\": \"Holger\",\n \"Nachname_LfAdr\": \"Hannemann prakt. Naturarzt\",\n \"Strasse_LfAdr\": \"Bahnhofplatz\",\n \"Hausnummer_LfAdr\": \"11\",\n \"Stadt_LfAdr\": \"Herisau\",\n \"Bundesland_LfAdr\": \"CH-AR\",\n \"PLZ_LfAdr\": \"9100\",\n \"Land_LfAdr\": \"CH\",\n \"Liefermethode\": \"Versand mit Die Schweizerische Post (1-3 Werktage)\",\n \"Netto\": 49.95,\n \"Versandkosten\": 4.95,\n \"Mehrwertsteuer\": 0.0,\n \"Rabatt\": 0.0,\n \"Rabattcode\": \"\",\n \"Gesamtsumme\": 54.90,\n \"lineItems\": [\n {\n \"titel\": \"Chaga Extrakt Tinktur 50 ml | 100% rein\",\n \"artikelnummer\": \"001.01\",\n \"preisEinheit\": 49.95,\n \"artikelanzahl\": 1\n }\n ]\n}", "refusal": null, "reasoning": null } }, "pairedItem": { "item": 0 } } ] }, "versionId": "0d0f1eec-82c8-4b6e-9770-bbbeca45a905", "activeVersionId": "0d0f1eec-82c8-4b6e-9770-bbbeca45a905", "versionCounter": 221, "triggerCount": 1, "shared": [ { "updatedAt": "2025-07-05T06:04:09.312Z", "createdAt": "2025-07-05T06:04:09.312Z", "role": "workflow:owner", "workflowId": "yNLjtV9yG0T6CqSr", "projectId": "loIw8cF8XKYX00Ow", "project": { "updatedAt": "2025-06-07T09:04:27.150Z", "createdAt": "2025-06-07T06:22:39.698Z", "id": "loIw8cF8XKYX00Ow", "name": "Mathias Gläser ", "type": "personal", "icon": null, "description": null, "creatorId": "f82ed6a8-4704-4f80-8617-622fd5911d56" } } ], "tags": [], "activeVersion": { "updatedAt": "2026-03-29T18:33:43.165Z", "createdAt": "2026-03-29T18:33:43.165Z", "versionId": "0d0f1eec-82c8-4b6e-9770-bbbeca45a905", "workflowId": "yNLjtV9yG0T6CqSr", "nodes": [ { "parameters": { "format": "resolved", "options": {} }, "type": "n8n-nodes-base.emailReadImap", "typeVersion": 2, "position": [ -272, -768 ], "id": "def6f3b1-b241-4e6c-89b1-63e4a0c12258", "name": "Email Trigger (IMAP)", "credentials": { "imap": { "id": "5jzK2kuSVJ8NWL1D", "name": "IMAP account 4" } } }, { "parameters": { "content": "Eingang ist Bestellung", "height": 520, "width": 860 }, "type": "n8n-nodes-base.stickyNote", "position": [ 80, -960 ], "typeVersion": 1, "id": "cec90477-28bf-45fd-a220-72edb7e20297", "name": "Sticky Note" }, { "parameters": { "modelId": { "__rl": true, "value": "deepseek/deepseek-v3.2", "mode": "list", "cachedResultName": "DEEPSEEK/DEEPSEEK-V3.2" }, "messages": { "values": [ { "content": "=Your input is this HTML-Mail: {{ $json.html }}\nYou are a JSON extractor for our order-processing pipeline.\nGiven the raw email HTML/text, you must output exactly one JSON object matching our schema, with these keys (in any order):\n\n*Section Bestellinformationen*\nBestellungNr, Zahlungsstatus, Zahlungsmethode, \n*Section Zahlungsinformationen*\nVorname_RgAdr, Nachname_RgAdr, Strasse_RgAdr, Hausnummer_RgAdr, Stadt_RgAdr, Bundesland_RgAdr, PLZ_RgAdr, Land_RgAdr, EmailKunde, \n*Section Lieferinformationen*\nVorname_LfAdr, Nachname_LfAdr, Strasse_LfAdr, Hausnummer_LfAdr, Stadt_LfAdr, Bundesland_LfAdr, PLZ_LfAdr, Land_LfAdr,\n*Section Versandmethode\"\nLiefermethode\n\n*Section Bestelldetails*\nEach lineItems entry must be an object with exactly these keys: \ntitel (Name of the item), artikelnummer, preisEinheit (CHF Price per lineitem divided by #Items), artikelanzahl (Anzahl)\n*Bottom-Sections*\nNetto, Versandkosten, Mehrwertsteuer, Rabatt (add to total if several Rabatte exist in the section), Rabattcode (is the name of the rabatt in the left column on the line of the rabatt sum) Gesamtsumme, \n\n\nImportant: \n- Output only the JSON object (no surrounding array, no code fences, no explanations). \n- Use string values for all text fields and numbers for all numeric fields. \n- If a field is missing or empty, output an empty string (\"\") for text or 0 for numbers.\n\nExtract the order details from the given raw email (HTML or text) and respond with only the JSON object below—no code fences, no markdown, no surrounding array, no keys like index or message. It must match exactly this schema (ordering doesn’t matter):\n\n{\n \"BestellungNr\": string,\n \"Zahlungsstatus\": string,\n \"Zahlungsmethode\": string,\n \"Vorname_RgAdr\": string,\n \"Nachname_RgAdr\": string,\n \"Strasse_RgAdr\": string,\n \"Hausnummer_RgAdr\": string,\n \"Stadt_RgAdr\": string,\n \"Bundesland_RgAdr\": string,\n \"PLZ_RgAdr\": string,\n \"Land_RgAdr\": string,\n \"EmailKunde\": string,\n \"Vorname_LfAdr\": string,\n \"Nachname_LfAdr\": string,\n \"Strasse_LfAdr\": string,\n \"Hausnummer_LfAdr\": string,\n \"Stadt_LfAdr\": string,\n \"Bundesland_LfAdr\": string,\n \"PLZ_LfAdr\": string,\n \"Land_LfAdr\": string,\n \"Liefermethode\": string,\n \"Netto\": number,\n \"Versandkosten\": number,\n \"Mehrwertsteuer\": number,\n \"Rabatt\": number,\n \"Gesamtsumme\": number,\n\"Rabattcode\": string\n \"lineItems\": [\n {\n \"titel\": string,\n \"artikelnummer\": string,\n \"preisEinheit\": number,\n \"artikelanzahl\": number\n }\n // repeat for each line item\n ]\n}" } ] }, "options": {} }, "type": "@n8n/n8n-nodes-langchain.openAi", "typeVersion": 1.8, "position": [ 144, -784 ], "id": "7ab009e6-5c24-48cb-ad34-28886cfec035", "name": "Message a model", "retryOnFail": true, "waitBetweenTries": 5000, "credentials": { "openAiApi": { "id": "CQ31lEApDEhhVATP", "name": "OpenAi OpenRouter" } } }, { "parameters": { "jsCode": "// n8n Code-Node – parse AI-Agent output into a clean JSON object\nreturn items.map(item => {\n // 1) Roh-String aus dem AI-Step ziehen\n let content = item.json.message?.content\n || item.json.content\n || '';\n \n // 2) Code-Fence und Markdown-Marker entfernen\n content = content\n .replace(/```json\\s*/g, '')\n .replace(/```/g, '')\n .trim();\n \n // 3) Falls der Agent eine Array-Antwort (z.B. “[ { … } ]”) liefert,\n // das Array parsen und das erste Objekt herausgreifen\n if (content.startsWith('[') && content.endsWith(']')) {\n let arr;\n try {\n arr = JSON.parse(content);\n } catch {\n throw new Error(`Kann AI-Array nicht parsen:\\n${content}`);\n }\n if (!Array.isArray(arr) || arr.length === 0) {\n throw new Error(`Erwartetes Array mit mindestens einem Element, bekam:\\n${content}`);\n }\n // Wenn das Array schon Deine Order-Objekte enthält (kein wrapper), nimm arr[0]\n // Andernfalls, falls es das n8n-wrapper-Format ist, grabe tiefer:\n content = JSON.stringify(\n typeof arr[0].message?.content === 'string'\n // falls das erste Element wieder ein wrapper-Objekt mit .message.content ist:\n ? JSON.parse(arr[0].message.content.replace(/```/g, '').trim())\n // sonst direkt das erste Element\n : arr[0]\n );\n }\n \n // 4) Jetzt das finale JSON parsen\n let data;\n try {\n data = JSON.parse(content);\n } catch (e) {\n throw new Error(`Failed to JSON.parse AI output:\\n${content}`);\n }\n \n // 5) Als neues Item zurückgeben\n return { json: data };\n});" }, "type": "n8n-nodes-base.code", "typeVersion": 2, "position": [ 480, -784 ], "id": "a199695a-ed3f-4b16-b1c2-0dc5bf143fd8", "name": "JSON Parsen1" }, { "parameters": { "conditions": { "options": { "caseSensitive": true, "leftValue": "", "typeValidation": "strict", "version": 3 }, "conditions": [ { "id": "dbe1657a-046d-44a2-a602-588bb6e2e83a", "leftValue": "={{ $json.headers.subject }}", "rightValue": "Neue Bestellung", "operator": { "type": "string", "operation": "contains" } } ], "combinator": "and" }, "options": {} }, "type": "n8n-nodes-base.if", "typeVersion": 2.3, "position": [ -64, -768 ], "id": "8c16451e-288d-4348-b04e-d072a133bc8f", "name": "If" }, { "parameters": { "method": "POST", "url": "https://erpnaurua.imhochrain.ch/order-import.php", "sendHeaders": true, "headerParameters": { "parameters": [ { "name": "Content-Type", "value": "application/json" }, { "name": "X-Webhook-Secret", "value": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiJmODJlZDZhOC00NzA0LTRmODAtODYxNy02MjJmZDU5MTFkNTYiLCJpc3MiOiJuOG4iLCJhdWQiOiJwdWJsaWMtYXBpIiw" } ] }, "sendBody": true, "specifyBody": "json", "jsonBody": "={{ $json }}", "options": { "response": { "response": { "responseFormat": "json" } } } }, "type": "n8n-nodes-base.httpRequest", "typeVersion": 4.2, "position": [ 736, -784 ], "id": "5c81fac4-8ca3-471a-a546-0e73995446a5", "name": "Bestellung an ERP senden" } ], "connections": { "Email Trigger (IMAP)": { "main": [ [ { "node": "If", "type": "main", "index": 0 } ] ] }, "Message a model": { "main": [ [ { "node": "JSON Parsen1", "type": "main", "index": 0 } ] ] }, "JSON Parsen1": { "main": [ [ { "node": "Bestellung an ERP senden", "type": "main", "index": 0 } ] ] }, "If": { "main": [ [ { "node": "Message a model", "type": "main", "index": 0 } ] ] }, "Bestellung an ERP senden": { "main": [ [] ] } }, "authors": "Mathias Gläser", "name": null, "description": null, "autosaved": false, "workflowPublishHistory": [ { "createdAt": "2026-03-29T18:33:43.293Z", "id": 144, "workflowId": "yNLjtV9yG0T6CqSr", "versionId": "0d0f1eec-82c8-4b6e-9770-bbbeca45a905", "event": "activated", "userId": "f82ed6a8-4704-4f80-8617-622fd5911d56" }, { "createdAt": "2026-03-29T18:33:43.221Z", "id": 143, "workflowId": "yNLjtV9yG0T6CqSr", "versionId": "0d0f1eec-82c8-4b6e-9770-bbbeca45a905", "event": "deactivated", "userId": "f82ed6a8-4704-4f80-8617-622fd5911d56" } ] } }