{
  "name": "Personalize marketing emails using customer data and AI",
  "nodes": [
    {
      "id": "9681490a-68f1-4c6a-86ea-bf2331c3125d",
      "name": "When clicking \"Execute Workflow\"",
      "type": "n8n-nodes-base.manualTrigger",
      "position": [
        -600,
        1040
      ]
    },
    {
      "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"
      }
    },
    {
      "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 "
      }
    },
    {
      "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"
      }
    },
    {
      "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"
      }
    },
    {
      "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"
      }
    },
    {
      "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"
      }
    },
    {
      "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 "
      }
    },
    {
      "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."
      }
    },
    {
      "id": "6c458bf6-ea7b-43b5-bc65-d9ae68542a8c",
      "name": "Extract from File",
      "type": "n8n-nodes-base.extractFromFile",
      "position": [
        -160,
        1040
      ]
    },
    {
      "id": "780dd707-4493-4679-9064-acc3c59011f8",
      "name": "Some Options for the Campaign",
      "type": "n8n-nodes-base.set",
      "position": [
        140,
        1040
      ]
    },
    {
      "id": "3b152bdc-acb8-4f37-8b91-1ab02c0e9532",
      "name": "Information Extractor",
      "type": "@n8n/n8n-nodes-langchain.informationExtractor",
      "position": [
        480,
        700
      ]
    },
    {
      "id": "f597a54e-27e9-46e8-b9d5-46dd54406803",
      "name": "OpenAI Chat Model1",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "position": [
        480,
        880
      ]
    },
    {
      "id": "716e4281-cf18-4cc7-b5ed-4de0308bf9aa",
      "name": "AI did fail us1",
      "type": "n8n-nodes-base.stopAndError",
      "position": [
        1380,
        1180
      ]
    },
    {
      "id": "1dc51ad5-e605-4cad-9a5b-3b20eabd9797",
      "name": "Fake coupon",
      "type": "n8n-nodes-base.set",
      "position": [
        1980,
        1280
      ]
    },
    {
      "id": "dfa6b376-dd66-40f1-8626-0f3f04e4c4bd",
      "name": "Download dummy data",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        -380,
        1040
      ]
    },
    {
      "id": "a95ce7c4-c592-40c7-9dfa-db0e37d5b71f",
      "name": "AI Output + Prev Data",
      "type": "n8n-nodes-base.merge",
      "position": [
        940,
        1040
      ]
    },
    {
      "id": "bb0474a1-425c-4a02-a13e-385272091189",
      "name": "Is the result valid?",
      "type": "n8n-nodes-base.if",
      "position": [
        1160,
        1040
      ]
    },
    {
      "id": "b39e0b98-6824-4265-94a0-fe12154f2ad4",
      "name": "Coupon them or not to Coupon them",
      "type": "n8n-nodes-base.if",
      "position": [
        1620,
        1040
      ]
    },
    {
      "id": "13c4426f-f522-4127-b899-7e6397e18182",
      "name": "Html Template for our Email",
      "type": "n8n-nodes-base.html",
      "position": [
        2360,
        740
      ]
    },
    {
      "id": "71e36c09-6e24-4eb2-9b1a-4fb3bb4b4536",
      "name": "The composed E-Mail + Prev Data",
      "type": "n8n-nodes-base.merge",
      "position": [
        2740,
        860
      ]
    },
    {
      "id": "a2b6ec8e-1bcf-4216-b9b6-476c0d82f706",
      "name": "Html Template for our Email with a Coupon",
      "type": "n8n-nodes-base.html",
      "position": [
        2360,
        1280
      ]
    },
    {
      "id": "2d5dd858-cf61-4136-b405-e6ad4a372725",
      "name": "The composed E-Mail with Coupon + Prev Data",
      "type": "n8n-nodes-base.merge",
      "position": [
        2740,
        1040
      ]
    },
    {
      "id": "5b1606b4-903a-4e90-8cf6-01fd92006195",
      "name": "Send Email",
      "type": "n8n-nodes-base.emailSend",
      "position": [
        3140,
        960
      ]
    }
  ],
  "connections": {
    "Fake coupon": {
      "main": [
        [
          {
            "node": "Html Template for our Email with a Coupon",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Extract from File": {
      "main": [
        [
          {
            "node": "Some Options for the Campaign",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI Chat Model1": {
      "ai_languageModel": [
        [
          {
            "node": "Information Extractor",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Download dummy data": {
      "main": [
        [
          {
            "node": "Extract from File",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Is the result valid?": {
      "main": [
        [
          {
            "node": "Coupon them or not to Coupon them",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "AI did fail us1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "AI Output + Prev Data": {
      "main": [
        [
          {
            "node": "Is the result valid?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Information Extractor": {
      "main": [
        [
          {
            "node": "AI Output + Prev Data",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Html Template for our Email": {
      "main": [
        [
          {
            "node": "The composed E-Mail + Prev Data",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Some Options for the Campaign": {
      "main": [
        [
          {
            "node": "Information Extractor",
            "type": "main",
            "index": 0
          },
          {
            "node": "AI Output + Prev Data",
            "type": "main",
            "index": 1
          }
        ]
      ]
    },
    "The composed E-Mail + Prev Data": {
      "main": [
        [
          {
            "node": "Send Email",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "When clicking \"Execute Workflow\"": {
      "main": [
        [
          {
            "node": "Download dummy data",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Coupon them or not to Coupon them": {
      "main": [
        [
          {
            "node": "Html Template for our Email",
            "type": "main",
            "index": 0
          },
          {
            "node": "The composed E-Mail + Prev Data",
            "type": "main",
            "index": 1
          }
        ],
        [
          {
            "node": "Fake coupon",
            "type": "main",
            "index": 0
          },
          {
            "node": "The composed E-Mail with Coupon + Prev Data",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Html Template for our Email with a Coupon": {
      "main": [
        [
          {
            "node": "The composed E-Mail with Coupon + Prev Data",
            "type": "main",
            "index": 1
          }
        ]
      ]
    },
    "The composed E-Mail with Coupon + Prev Data": {
      "main": [
        [
          {
            "node": "Send Email",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}