{ "meta": { "instanceId": "workflow-924af4b5", "versionId": "1.0.0", "createdAt": "2025-09-29T07:07:55.308883", "updatedAt": "2025-09-29T07:07:55.308899", "owner": "n8n-user", "license": "MIT", "category": "automation", "status": "active", "priority": "high", "environment": "production" }, "nodes": [ { "id": "9681490a-68f1-4c6a-86ea-bf2331c3125d", "name": "When clicking \"Execute Workflow\"", "type": "n8n-nodes-base.manualTrigger", "position": [ -600, 1040 ], "parameters": {}, "typeVersion": 1, "notes": "This manualTrigger node performs automated tasks as part of the workflow." }, { "id": "f665f0c6-7694-456f-b877-5f8d69b9f503", "name": "Sticky Note", "type": "n8n-nodes-base.stickyNote", "position": [ -680, 920 ], "parameters": { "width": 715.3278290432247, "height": 315.32782904322477, "content": "## Get and prepare Dummy Data" }, "typeVersion": 1, "notes": "This stickyNote node performs automated tasks as part of the workflow." }, { "id": "79a9ece6-daa5-4cc0-bfb8-5cf8c9e81296", "name": "Sticky Note1", "type": "n8n-nodes-base.stickyNote", "position": [ 340, 480 ], "parameters": { "width": 520.9323109877616, "height": 577.5426854600692, "content": "## Let GPT do the heavy work\n\nFor the prompt we follow the one-shot'ish principle. Also I've decided to **_NOT_** give the AI the personal data. Keeps it simpler regarding data privacy.\n\nThe AI-Chain will generate a **Headline** and the **Text** for the Email and even **decides** if we should send the user a **Coupon**." }, "typeVersion": 1, "notes": "This stickyNote node performs automated tasks as part of the workflow." }, { "id": "51e1bc15-0b9e-4d53-9b99-0ec8ed5e00f8", "name": "Sticky Note2", "type": "n8n-nodes-base.stickyNote", "position": [ 2240, 620 ], "parameters": { "width": 358, "height": 324, "content": "## HTML Email-Template without Coupon" }, "typeVersion": 1, "notes": "This stickyNote node performs automated tasks as part of the workflow." }, { "id": "ee29375a-77fe-4d13-a453-c8b62f0884a7", "name": "Sticky Note3", "type": "n8n-nodes-base.stickyNote", "position": [ 1100, 880 ], "parameters": { "width": 447, "height": 465, "content": "## Make sure we have what we need\nWe do not want to sent empty messages to our customers" }, "typeVersion": 1, "notes": "This stickyNote node performs automated tasks as part of the workflow." }, { "id": "37e09224-3649-43e0-a40f-f8177aa93cda", "name": "Sticky Note4", "type": "n8n-nodes-base.stickyNote", "position": [ 2240, 1140 ], "parameters": { "width": 369.917435648372, "height": 330.56011245057107, "content": "## HTML Email-Template with Coupon" }, "typeVersion": 1, "notes": "This stickyNote node performs automated tasks as part of the workflow." }, { "id": "5147fe48-606d-4dad-9977-2713f40fc8e6", "name": "Sticky Note5", "type": "n8n-nodes-base.stickyNote", "position": [ 1880, 1140 ], "parameters": { "width": 319.84249777513367, "height": 330.6656654860422, "content": "## Mocked: Fake a Coupon Code\nFor a real life scenario add the automated coupon generation here" }, "typeVersion": 1, "notes": "This stickyNote node performs automated tasks as part of the workflow." }, { "id": "6a3ee9b0-540e-4242-a6ac-535e2b23ea3a", "name": "Sticky Note6", "type": "n8n-nodes-base.stickyNote", "position": [ -680, 300 ], "parameters": { "width": 534.1315466553021, "height": 566.556517486655, "content": "# Documentation\n\nThis Workflow is for the n8n AI / Langchain Competition.\n\nIt solves the Problem: Personalizing marketing emails based on customer purchase history.\n\nI've found it a bit ambiguous and decided to go the \"Convert unhappy customers with a Coupon\"-Route.\n\nSo this workflow utilizes the new LangChain Node for generating personalized E-Mail campaigns and decide if the user might need a coupon to be satisfied. Classic Rebound stuff. \n\nThere is also a Node \"Some Options...\" which can be adjusted to quickly change the direction this Campaign should go.\n\nAdditionally we use n8n to generate the HTML Mails by two different Templates. One with simple text and another for that Coupon handling.\n\n![Image]({{ $env.WEBHOOK_URL }}\nEnjoy the Workflow! ❤️ \n{{ $env.WEBHOOK_URL }}\n" }, "typeVersion": 1, "notes": "This stickyNote node performs automated tasks as part of the workflow." }, { "id": "01cf3e60-c280-46c1-9971-ccf63a28ab9a", "name": "Sticky Note7", "type": "n8n-nodes-base.stickyNote", "position": [ 3040, 760 ], "parameters": { "width": 326.9476248855971, "height": 414.15459581943776, "content": "## Send the Email to the Customer\n\nAlthough it's cool that n8n allows sending emails via SMPT I would recommend to stick to your newsletter tool for that to keep track of opt-outs and stuff." }, "typeVersion": 1, "notes": "This stickyNote node performs automated tasks as part of the workflow." }, { "id": "6c458bf6-ea7b-43b5-bc65-d9ae68542a8c", "name": "Extract from File", "type": "n8n-nodes-base.extractFromFile", "position": [ -160, 1040 ], "parameters": { "options": {}, "operation": "xls" }, "typeVersion": 1, "notes": "This extractFromFile node performs automated tasks as part of the workflow." }, { "id": "780dd707-4493-4679-9064-acc3c59011f8", "name": "Some Options for the Campaign", "type": "n8n-nodes-base.set", "position": [ 140, 1040 ], "parameters": { "options": {}, "assignments": { "assignments": [ { "id": "8ef766db-4ad1-43c7-b621-8ea3ed0a44b2", "name": "Campaign Target", "type": "string", "value": "Engage the Customer" }, { "id": "9f9ce88a-a24a-4a27-8b25-25ee85e730d6", "name": "Flavour", "type": "string", "value": "be friendly and witty but also cool and direct. Critique is valuable and embrace the feedback." } ] }, "includeOtherFields": true }, "typeVersion": 3.4, "notes": "This set node performs automated tasks as part of the workflow." }, { "id": "3b152bdc-acb8-4f37-8b91-1ab02c0e9532", "name": "Information Extractor", "type": "n8n-nodes-base.noOp", "position": [ 480, 700 ], "parameters": { "text": "=Item Purchased: {{ $json['Item Purchased'] }} \nFeedback: {{ $json.Feedback }}\nShould we send a coupon to make the customer happy? Yes/No", "options": { "systemPromptTemplate": "=Determine the sentiment of the given product feedback. Then generate a Headline and Text without salutation or any greeting for a personalized Email Campagin after a User gave a product review. If the user seems not happy, tell them that you have a Coupon for them. The User finds the Coupon Code below this E-mail. \nThe target of the campagin: {{ $json['Campaign Target'] }}.\nRemember: {{ $json['Flavour'] }}. Avoid any greeting.\n" }, "schemaType": "manual", "inputSchema": "{\n \"type\": \"object\",\n \"required\": [\"Headline\",\"Body\",\"SendCoupon\"],\n \"properties\": {\n \"Headline\": {\n \"type\": \"string\"\n },\n \"Body\": {\n \"type\": \"string\"\n },\n \"SendCoupon\": {\n \"type\": \"boolean\"\n }\n }\n}" }, "typeVersion": 1, "notes": "This informationExtractor node performs automated tasks as part of the workflow." }, { "id": "f597a54e-27e9-46e8-b9d5-46dd54406803", "name": "OpenAI Chat Model1", "type": "n8n-nodes-base.noOp", "position": [ 480, 880 ], "parameters": { "model": { "__rl": true, "mode": "list", "value": "gpt-4o-mini" }, "options": {} }, "credentials": { "openAiApi": { "id": "8gccIjcuf3gvaoEr", "name": "OpenAi account" } }, "typeVersion": 1.2, "notes": "This lmChatOpenAi node performs automated tasks as part of the workflow." }, { "id": "716e4281-cf18-4cc7-b5ed-4de0308bf9aa", "name": "AI did fail us1", "type": "n8n-nodes-base.stopAndError", "position": [ 1380, 1180 ], "parameters": { "errorMessage": "Unexpected Langchain Output" }, "typeVersion": 1, "notes": "This stopAndError node performs automated tasks as part of the workflow." }, { "id": "1dc51ad5-e605-4cad-9a5b-3b20eabd9797", "name": "Fake coupon", "type": "n8n-nodes-base.set", "position": [ 1980, 1280 ], "parameters": { "options": {}, "assignments": { "assignments": [ { "id": "73989d0e-667f-4227-ab41-4eb1e8c1c10e", "name": "Coupon", "type": "string", "value": "F4k3ItT1llY0uM4k3It" }, { "id": "4d86d8c8-1be3-40b0-b4fd-09f9ffc24386", "name": "Coupon Value", "type": "string", "value": "20% of any purchase" }, { "id": "f73b8a70-5bf6-45c2-8061-d10f95b199a8", "name": "Coupon Terms", "type": "string", "value": "=Valid until {{ $today.plus({days: 14}).format(\"d. MMM. y\") }} | minimum purchase amount: 20$ " } ] }, "includeOtherFields": true }, "typeVersion": 3.4, "notes": "This set node performs automated tasks as part of the workflow." }, { "id": "dfa6b376-dd66-40f1-8626-0f3f04e4c4bd", "name": "Download dummy data", "type": "n8n-nodes-base.httpRequest", "position": [ -380, 1040 ], "parameters": { "url": "{{ $env.WEBHOOK_URL }}", "options": {} }, "typeVersion": 4.2, "notes": "This httpRequest node performs automated tasks as part of the workflow." }, { "id": "a95ce7c4-c592-40c7-9dfa-db0e37d5b71f", "name": "AI Output + Prev Data", "type": "n8n-nodes-base.merge", "position": [ 940, 1040 ], "parameters": { "mode": "combine", "options": {}, "combineBy": "combineByPosition" }, "typeVersion": 3, "notes": "This merge node performs automated tasks as part of the workflow." }, { "id": "bb0474a1-425c-4a02-a13e-385272091189", "name": "Is the result valid?", "type": "n8n-nodes-base.if", "position": [ 1160, 1040 ], "parameters": { "options": {}, "conditions": { "options": { "version": 2, "leftValue": "", "caseSensitive": true, "typeValidation": "strict" }, "combinator": "and", "conditions": [ { "id": "9b4ced26-dd86-4ae4-8f69-6177ec42c827", "operator": { "type": "string", "operation": "notEmpty", "singleValue": true }, "leftValue": "Headline", "rightValue": "" }, { "id": "7723102c-43d2-48df-82f6-5bb45ddf615c", "operator": { "type": "string", "operation": "notEmpty", "singleValue": true }, "leftValue": "Body", "rightValue": "" } ] } }, "typeVersion": 2.2, "notes": "This if node performs automated tasks as part of the workflow." }, { "id": "b39e0b98-6824-4265-94a0-fe12154f2ad4", "name": "Coupon them or not to Coupon them", "type": "n8n-nodes-base.if", "position": [ 1620, 1040 ], "parameters": { "options": {}, "conditions": { "options": { "version": 2, "leftValue": "", "caseSensitive": true, "typeValidation": "strict" }, "combinator": "and", "conditions": [ { "id": "967f37a1-a600-46a2-82cf-f340dd3c7a96", "operator": { "type": "boolean", "operation": "true", "singleValue": true }, "leftValue": "={{ $json.SendCoupon }}", "rightValue": "" } ] } }, "typeVersion": 2.2, "notes": "This if node performs automated tasks as part of the workflow." }, { "id": "13c4426f-f522-4127-b899-7e6397e18182", "name": "Html Template for our Email", "type": "n8n-nodes-base.html", "position": [ 2360, 740 ], "parameters": { "html": "\n\n\n \n {{ $json['Headline'] }}\n\n\n
\n \n

Hey {{ $json['Custome Name'] ? $json['Custome Name']+', ' : '!' }}

\n

{{ $json['Body'] }}

\n \n
\n

\n Definitely not a real company Lmt.
\n Also not a real street 123
\n Unreal Town\n

\n
\n
\n \n \n\n\n\n" }, "typeVersion": 1.2, "notes": "This html node performs automated tasks as part of the workflow." }, { "id": "71e36c09-6e24-4eb2-9b1a-4fb3bb4b4536", "name": "The composed E-Mail + Prev Data", "type": "n8n-nodes-base.merge", "position": [ 2740, 860 ], "parameters": { "mode": "combine", "options": {}, "combineBy": "combineByPosition" }, "typeVersion": 3, "notes": "This merge node performs automated tasks as part of the workflow." }, { "id": "a2b6ec8e-1bcf-4216-b9b6-476c0d82f706", "name": "Html Template for our Email with a Coupon", "type": "n8n-nodes-base.html", "position": [ 2360, 1280 ], "parameters": { "html": "\n\n\n \n {{ $json.output['Headline'] }}\n\n\n
\n \n

Hey {{ $json['Custome Name'] ? $json['Custome Name']+', ' : '!' }}

\n

{{ $json.output['Body'] }}

\n \n
\n

Here's a Coupon for you!
\n {{ $json['Coupon Value'] }}

\n

{{ $json['Coupon'] }}

\n

{{ $json['Coupon Terms'] }}

\n
\n
\n

\n Definitely not a real company Lmt.
\n Also not a real street 123
\n Unreal Town\n

\n
\n
\n \n \n\n\n\n" }, "typeVersion": 1.2, "notes": "This html node performs automated tasks as part of the workflow." }, { "id": "2d5dd858-cf61-4136-b405-e6ad4a372725", "name": "The composed E-Mail with Coupon + Prev Data", "type": "n8n-nodes-base.merge", "position": [ 2740, 1040 ], "parameters": { "mode": "combine", "options": {}, "combineBy": "combineByPosition" }, "typeVersion": 3, "notes": "This merge node performs automated tasks as part of the workflow." }, { "id": "5b1606b4-903a-4e90-8cf6-01fd92006195", "name": "Send Email", "type": "n8n-nodes-base.emailSend", "position": [ 3140, 960 ], "webhookId": "a155d7b3-39b1-4a96-adc5-4f8e984506ec", "parameters": { "html": "={{ $json.html }}", "options": {}, "subject": "={{ $json.output.Headline }}", "toEmail": "={{ $json.Email }}", "fromEmail": "n8n@myemail.com" }, "credentials": { "smtp": { "id": "EagS3depRLAKo3Sw", "name": "Greenmail SMTP account (bob@example.com)" } }, "typeVersion": 2.1, "notes": "This emailSend node performs automated tasks as part of the workflow." } ], "pinData": {}, "connections": { "6c458bf6-ea7b-43b5-bc65-d9ae68542a8c": { "main": [ [ { "node": "error-handler-6c458bf6-ea7b-43b5-bc65-d9ae68542a8c-c2a62c87", "type": "main", "index": 0 } ] ] }, "f597a54e-27e9-46e8-b9d5-46dd54406803": { "main": [ [ { "node": "error-handler-f597a54e-27e9-46e8-b9d5-46dd54406803-dd259d6d", "type": "main", "index": 0 } ] ] }, "dfa6b376-dd66-40f1-8626-0f3f04e4c4bd": { "main": [ [ { "node": "error-handler-dfa6b376-dd66-40f1-8626-0f3f04e4c4bd-9c89f041", "type": "main", "index": 0 } ], [ { "node": "error-handler-dfa6b376-dd66-40f1-8626-0f3f04e4c4bd-bb5e4b98", "type": "main", "index": 0 } ], [ { "node": "error-handler-dfa6b376-dd66-40f1-8626-0f3f04e4c4bd-6e9ee55d", "type": "main", "index": 0 } ], [ { "node": "error-handler-dfa6b376-dd66-40f1-8626-0f3f04e4c4bd-9ccde0a7", "type": "main", "index": 0 } ], [ { "node": "error-handler-dfa6b376-dd66-40f1-8626-0f3f04e4c4bd-0a96c767", "type": "main", "index": 0 } ], [ { "node": "error-handler-dfa6b376-dd66-40f1-8626-0f3f04e4c4bd-bfc08d9b", "type": "main", "index": 0 } ], [ { "node": "error-handler-dfa6b376-dd66-40f1-8626-0f3f04e4c4bd-e87ce797", "type": "main", "index": 0 } ], [ { "node": "error-handler-dfa6b376-dd66-40f1-8626-0f3f04e4c4bd-49d673a3", "type": "main", "index": 0 } ] ] }, "5b1606b4-903a-4e90-8cf6-01fd92006195": { "main": [ [ { "node": "error-handler-5b1606b4-903a-4e90-8cf6-01fd92006195-414c7e12", "type": "main", "index": 0 } ], [ { "node": "error-handler-5b1606b4-903a-4e90-8cf6-01fd92006195-2e6fc789", "type": "main", "index": 0 } ], [ { "node": "error-handler-5b1606b4-903a-4e90-8cf6-01fd92006195-6e932948", "type": "main", "index": 0 } ], [ { "node": "error-handler-5b1606b4-903a-4e90-8cf6-01fd92006195-3a4d269d", "type": "main", "index": 0 } ], [ { "node": "error-handler-5b1606b4-903a-4e90-8cf6-01fd92006195-e8406855", "type": "main", "index": 0 } ], [ { "node": "error-handler-5b1606b4-903a-4e90-8cf6-01fd92006195-397ddd93", "type": "main", "index": 0 } ], [ { "node": "error-handler-5b1606b4-903a-4e90-8cf6-01fd92006195-6a3d4a0e", "type": "main", "index": 0 } ], [ { "node": "error-handler-5b1606b4-903a-4e90-8cf6-01fd92006195-176b8b0e", "type": "main", "index": 0 } ] ] } }, "name": "Manualtrigger Workflow", "settings": { "executionOrder": "v1", "saveManualExecutions": true, "callerPolicy": "workflowsFromSameOwner", "errorWorkflow": null, "timezone": "UTC", "executionTimeout": 3600, "maxExecutions": 1000, "retryOnFail": true, "retryCount": 3, "retryDelay": 1000 }, "description": "Automated workflow: Manualtrigger Workflow. This workflow integrates 12 different services: stickyNote, httpRequest, merge, informationExtractor, set. It contains 28 nodes and follows best practices for error handling and security.", "tags": [ "automation", "n8n", "production-ready", "excellent", "optimized" ], "notes": "Excellent quality workflow: Manualtrigger Workflow. This workflow has been optimized for production use with comprehensive error handling, security, and documentation." }