{
  "name": "Personalized Beat Recommendation Email System",
  "nodes": [
    {
      "parameters": {
        "rule": {
          "interval": [
            {
              "field": "weeks"
            }
          ]
        }
      },
      "id": "3981e13a-2858-448d-a29b-b9c923851126",
      "name": "Weekly Schedule",
      "type": "n8n-nodes-base.scheduleTrigger",
      "typeVersion": 1.3,
      "position": [
        256,
        408
      ]
    },
    {
      "parameters": {
        "pollTimes": {
          "item": [
            {
              "mode": "everyMinute"
            }
          ]
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": ""
        },
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": ""
        },
        "event": "rowAdded",
        "options": {}
      },
      "id": "d720958d-8da1-47c1-b5ba-9839e61bfec8",
      "name": "New Customer Trigger",
      "type": "n8n-nodes-base.googleSheetsTrigger",
      "typeVersion": 1,
      "position": [
        288,
        960
      ]
    },
    {
      "parameters": {
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": ""
        },
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": ""
        }
      },
      "id": "939b58f8-1613-4b98-bdea-8f80200d3da6",
      "name": "Get Customers",
      "type": "n8n-nodes-base.googleSheets",
      "typeVersion": 4.7,
      "position": [
        480,
        408
      ]
    },
    {
      "parameters": {
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": ""
        },
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": ""
        }
      },
      "id": "ff380b44-a19b-4678-95c7-0fcb0ff99f23",
      "name": "Get Beat Catalog",
      "type": "n8n-nodes-base.googleSheets",
      "typeVersion": 4.7,
      "position": [
        704,
        504
      ]
    },
    {
      "parameters": {
        "fieldToSplitOut": "={{ $('Get Customers').item.json }}",
        "options": {}
      },
      "id": "c73aafd1-6434-421e-b159-5e8b0357b07d",
      "name": "Split Customers",
      "type": "n8n-nodes-base.splitOut",
      "typeVersion": 1,
      "position": [
        704,
        312
      ]
    },
    {
      "parameters": {
        "mode": "combine",
        "combineBy": "combineAll",
        "options": {}
      },
      "id": "b40da018-f8af-4de9-862e-f4153ace84e1",
      "name": "Merge Customer with Catalog",
      "type": "n8n-nodes-base.merge",
      "typeVersion": 3.2,
      "position": [
        928,
        408
      ]
    },
    {
      "parameters": {
        "model": {
          "__rl": true,
          "mode": "id",
          "value": "gpt-4o-mini"
        },
        "builtInTools": {},
        "options": {
          "temperature": 0.2
        }
      },
      "id": "afa894bc-92bb-4d51-a6dd-c4492549d2e2",
      "name": "OpenAI Chat Model",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "typeVersion": 1.3,
      "position": [
        1152,
        608
      ]
    },
    {
      "parameters": {
        "promptType": "define",
        "text": "={{ $json }}",
        "options": {
          "systemMessage": "You are a music recommendation expert. Analyze the customer's purchase history and the available beat catalog to recommend ONE beat that matches their taste. Consider genre similarity and BPM/RPM compatibility. Provide the recommendation with a brief personalized explanation of why this beat suits their style."
        }
      },
      "id": "8c453091-09a0-4ac3-987d-0fe3420f811f",
      "name": "AI Recommendation Agent",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "typeVersion": 3.1,
      "position": [
        1152,
        400
      ]
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "id-1",
              "name": "customerName",
              "value": "={{ $json.customerName }}",
              "type": "string"
            },
            {
              "id": "id-2",
              "name": "customerEmail",
              "value": "={{ $json.customerEmail }}",
              "type": "string"
            },
            {
              "id": "id-3",
              "name": "recommendation",
              "value": "={{ $('AI Recommendation Agent').item.json.output }}",
              "type": "string"
            },
            {
              "id": "id-4",
              "name": "purchasedTrack",
              "value": "={{ $json.purchasedTrack }}",
              "type": "string"
            },
            {
              "id": "id-5",
              "name": "purchasedGenre",
              "value": "={{ $json.purchasedGenre }}",
              "type": "string"
            }
          ]
        },
        "options": {}
      },
      "id": "733a2346-bd08-4df4-8144-7f0aefc7b143",
      "name": "Prepare Email Data",
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        1504,
        408
      ]
    },
    {
      "parameters": {
        "html": "<!DOCTYPE html>\n<html>\n<head>\n  <meta charset=\"UTF-8\" />\n  <title>Your Personalized Beat Recommendation</title>\n</head>\n<body>\n  <div class=\"container\">\n    <div class=\"header\">\n      <h1>🎵 Your Personalized Beat Recommendation</h1>\n    </div>\n    \n    <div class=\"content\">\n      <p class=\"greeting\">Hey {{ $json.customerName }},</p>\n      \n      <p>We noticed you recently purchased <strong>{{ $json.purchasedTrack }}</strong> in the <strong>{{ $json.purchasedGenre }}</strong> genre. Based on your taste, we have a special recommendation just for you!</p>\n      \n      <div class=\"recommendation-box\">\n        <h2>Recommended for You</h2>\n        <div class=\"recommendation-content\">\n          {{ $json.recommendation }}\n        </div>\n      </div>\n      \n      <div class=\"cta-section\">\n        <a href=\"#\" class=\"cta-button\">Listen Now</a>\n      </div>\n      \n      <p class=\"footer-text\">Keep creating amazing music!</p>\n    </div>\n    \n    <div class=\"footer\">\n      <p>© 2024 Beat Store. All rights reserved.</p>\n    </div>\n  </div>\n</body>\n</html>\n\n<style>\nbody {\n  margin: 0;\n  padding: 0;\n  font-family: Arial, sans-serif;\n  background-color: #f4f4f4;\n}\n\n.container {\n  max-width: 600px;\n  margin: 0 auto;\n  background-color: #ffffff;\n  border-radius: 8px;\n  overflow: hidden;\n  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);\n}\n\n.header {\n  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);\n  padding: 30px 20px;\n  text-align: center;\n}\n\n.header h1 {\n  color: #ffffff;\n  margin: 0;\n  font-size: 28px;\n  font-weight: bold;\n}\n\n.content {\n  padding: 30px 20px;\n}\n\n.greeting {\n  font-size: 18px;\n  color: #333333;\n  margin-bottom: 20px;\n}\n\n.content p {\n  color: #555555;\n  line-height: 1.6;\n  font-size: 16px;\n}\n\n.recommendation-box {\n  background-color: #f8f9fa;\n  border-left: 4px solid #667eea;\n  padding: 20px;\n  margin: 25px 0;\n  border-radius: 4px;\n}\n\n.recommendation-box h2 {\n  color: #667eea;\n  font-size: 20px;\n  margin-top: 0;\n  margin-bottom: 15px;\n}\n\n.recommendation-content {\n  color: #333333;\n  font-size: 15px;\n  line-height: 1.6;\n}\n\n.cta-section {\n  text-align: center;\n  margin: 30px 0;\n}\n\n.cta-button {\n  display: inline-block;\n  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);\n  color: #ffffff;\n  padding: 14px 40px;\n  text-decoration: none;\n  border-radius: 25px;\n  font-size: 16px;\n  font-weight: bold;\n  transition: transform 0.2s;\n}\n\n.cta-button:hover {\n  transform: scale(1.05);\n}\n\n.footer-text {\n  text-align: center;\n  color: #666666;\n  font-style: italic;\n  margin-top: 20px;\n}\n\n.footer {\n  background-color: #f8f9fa;\n  padding: 20px;\n  text-align: center;\n  border-top: 1px solid #e0e0e0;\n}\n\n.footer p {\n  color: #999999;\n  font-size: 12px;\n  margin: 0;\n}\n</style>"
      },
      "id": "dc23081b-b83a-4383-9e33-f7c78b225421",
      "name": "Build HTML Email",
      "type": "n8n-nodes-base.html",
      "typeVersion": 1.2,
      "position": [
        1728,
        408
      ]
    },
    {
      "parameters": {
        "sendTo": "={{ $json.customerEmail }}",
        "subject": "={{ '🎵 ' + $json.customerName + ', We Have a Beat Recommendation Just for You!' }}",
        "message": "={{ $('Build HTML Email').item.json.html }}",
        "options": {
          "appendAttribution": false
        }
      },
      "id": "4d5ce19a-46fc-4739-94e2-728d5abd3483",
      "name": "Send Email",
      "type": "n8n-nodes-base.gmail",
      "typeVersion": 2.2,
      "position": [
        1952,
        408
      ],
      "webhookId": "79592540-8a6a-48e8-b00e-a2db60a4f7ea"
    },
    {
      "parameters": {
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": ""
        },
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": ""
        }
      },
      "id": "f993c98e-f720-4fbc-b656-d70005f9849f",
      "name": "Get Beat Catalog for New Customer",
      "type": "n8n-nodes-base.googleSheets",
      "typeVersion": 4.7,
      "position": [
        480,
        768
      ]
    },
    {
      "parameters": {
        "mode": "combine",
        "combineBy": "combineAll",
        "options": {}
      },
      "id": "f6b839b7-9656-407d-8af4-90c1ffc74ac8",
      "name": "Merge New Customer with Catalog",
      "type": "n8n-nodes-base.merge",
      "typeVersion": 3.2,
      "position": [
        704,
        840
      ]
    },
    {
      "parameters": {
        "model": {
          "__rl": true,
          "mode": "id",
          "value": "gpt-4o-mini"
        },
        "builtInTools": {},
        "options": {
          "temperature": 0.2
        }
      },
      "id": "4fe216bb-2fb2-47ff-9b0d-7ce138a1159b",
      "name": "OpenAI Chat Model for New Customer",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "typeVersion": 1.3,
      "position": [
        944,
        1040
      ]
    },
    {
      "parameters": {
        "promptType": "define",
        "text": "={{ $json }}",
        "options": {
          "systemMessage": "You are a music recommendation expert welcoming a new customer. Based on their first purchase, recommend ONE beat from the catalog that complements their taste. Consider genre similarity and BPM/RPM compatibility. Create a warm, welcoming message that thanks them for their purchase and explains why this recommended beat would be perfect for them."
        }
      },
      "id": "2c370e91-65f9-4447-9e95-6d133781cb9d",
      "name": "AI Welcome Agent",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "typeVersion": 3.1,
      "position": [
        928,
        840
      ]
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "id-1",
              "name": "customerName",
              "value": "={{ $('New Customer Trigger').item.json.customerName }}",
              "type": "string"
            },
            {
              "id": "id-2",
              "name": "customerEmail",
              "value": "={{ $('New Customer Trigger').item.json.customerEmail }}",
              "type": "string"
            },
            {
              "id": "id-3",
              "name": "welcomeMessage",
              "value": "={{ $('AI Welcome Agent').item.json.output }}",
              "type": "string"
            },
            {
              "id": "id-4",
              "name": "purchasedTrack",
              "value": "={{ $('New Customer Trigger').item.json.purchasedTrack }}",
              "type": "string"
            },
            {
              "id": "id-5",
              "name": "purchasedGenre",
              "value": "={{ $('New Customer Trigger').item.json.purchasedGenre }}",
              "type": "string"
            }
          ]
        },
        "options": {}
      },
      "id": "74c87496-59f6-4acc-a36f-755b6dadc41c",
      "name": "Prepare Welcome Email Data",
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        1280,
        840
      ]
    },
    {
      "parameters": {
        "html": "<!DOCTYPE html>\n<html>\n<head>\n  <meta charset=\"UTF-8\" />\n  <title>Welcome to Beat Store!</title>\n</head>\n<body>\n  <div class=\"container\">\n    <div class=\"header\">\n      <h1>🎉 Welcome to Beat Store!</h1>\n    </div>\n    \n    <div class=\"content\">\n      <p class=\"greeting\">Hey {{ $json.customerName }},</p>\n      \n      <p class=\"thank-you\">Thank you for choosing Beat Store! We're thrilled to have you as part of our community.</p>\n      \n      <div class=\"purchase-box\">\n        <h2>Your Purchase</h2>\n        <p><strong>Track:</strong> {{ $json.purchasedTrack }}</p>\n        <p><strong>Genre:</strong> {{ $json.purchasedGenre }}</p>\n      </div>\n      \n      <div class=\"recommendation-box\">\n        <h2>We Think You'll Love This</h2>\n        <div class=\"recommendation-content\">\n          {{ $json.welcomeMessage }}\n        </div>\n      </div>\n      \n      <div class=\"cta-section\">\n        <a href=\"#\" class=\"cta-button\">Explore More Beats</a>\n      </div>\n      \n      <p class=\"footer-text\">We can't wait to see what you create!</p>\n    </div>\n    \n    <div class=\"footer\">\n      <p>© 2024 Beat Store. All rights reserved.</p>\n    </div>\n  </div>\n</body>\n</html>\n\n<style>\nbody {\n  margin: 0;\n  padding: 0;\n  font-family: Arial, sans-serif;\n  background-color: #f4f4f4;\n}\n\n.container {\n  max-width: 600px;\n  margin: 0 auto;\n  background-color: #ffffff;\n  border-radius: 8px;\n  overflow: hidden;\n  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);\n}\n\n.header {\n  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);\n  padding: 30px 20px;\n  text-align: center;\n}\n\n.header h1 {\n  color: #ffffff;\n  margin: 0;\n  font-size: 28px;\n  font-weight: bold;\n}\n\n.content {\n  padding: 30px 20px;\n}\n\n.greeting {\n  font-size: 18px;\n  color: #333333;\n  margin-bottom: 15px;\n}\n\n.thank-you {\n  color: #555555;\n  line-height: 1.6;\n  font-size: 16px;\n  margin-bottom: 25px;\n}\n\n.content p {\n  color: #555555;\n  line-height: 1.6;\n  font-size: 16px;\n}\n\n.purchase-box {\n  background-color: #e8f4f8;\n  border-left: 4px solid #4a90e2;\n  padding: 20px;\n  margin: 25px 0;\n  border-radius: 4px;\n}\n\n.purchase-box h2 {\n  color: #4a90e2;\n  font-size: 20px;\n  margin-top: 0;\n  margin-bottom: 15px;\n}\n\n.purchase-box p {\n  color: #333333;\n  font-size: 15px;\n  margin: 8px 0;\n}\n\n.recommendation-box {\n  background-color: #f8f9fa;\n  border-left: 4px solid #667eea;\n  padding: 20px;\n  margin: 25px 0;\n  border-radius: 4px;\n}\n\n.recommendation-box h2 {\n  color: #667eea;\n  font-size: 20px;\n  margin-top: 0;\n  margin-bottom: 15px;\n}\n\n.recommendation-content {\n  color: #333333;\n  font-size: 15px;\n  line-height: 1.6;\n}\n\n.cta-section {\n  text-align: center;\n  margin: 30px 0;\n}\n\n.cta-button {\n  display: inline-block;\n  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);\n  color: #ffffff;\n  padding: 14px 40px;\n  text-decoration: none;\n  border-radius: 25px;\n  font-size: 16px;\n  font-weight: bold;\n  transition: transform 0.2s;\n}\n\n.cta-button:hover {\n  transform: scale(1.05);\n}\n\n.footer-text {\n  text-align: center;\n  color: #666666;\n  font-style: italic;\n  margin-top: 20px;\n}\n\n.footer {\n  background-color: #f8f9fa;\n  padding: 20px;\n  text-align: center;\n  border-top: 1px solid #e0e0e0;\n}\n\n.footer p {\n  color: #999999;\n  font-size: 12px;\n  margin: 0;\n}\n</style>"
      },
      "id": "e5836130-0b09-4f76-88cd-0d7a0401f862",
      "name": "Build Welcome HTML Email",
      "type": "n8n-nodes-base.html",
      "typeVersion": 1.2,
      "position": [
        1504,
        840
      ]
    },
    {
      "parameters": {
        "sendTo": "={{ $json.customerEmail }}",
        "subject": "={{ '🎉 Welcome to Beat Store, ' + $json.customerName + '! Thank You for Your Purchase!' }}",
        "message": "={{ $('Build Welcome HTML Email').item.json.html }}",
        "options": {
          "appendAttribution": false
        }
      },
      "id": "4b479c6b-535e-40c9-bd7f-5304413c20b9",
      "name": "Send Welcome Email",
      "type": "n8n-nodes-base.gmail",
      "typeVersion": 2.2,
      "position": [
        1728,
        840
      ],
      "webhookId": "0e4030fe-29d2-446e-8f06-df9b8124a1eb"
    }
  ],
  "pinData": {},
  "connections": {
    "Weekly Schedule": {
      "main": [
        [
          {
            "node": "Get Customers",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get Customers": {
      "main": [
        [
          {
            "node": "Get Beat Catalog",
            "type": "main",
            "index": 0
          },
          {
            "node": "Split Customers",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Split Customers": {
      "main": [
        [
          {
            "node": "Merge Customer with Catalog",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get Beat Catalog": {
      "main": [
        [
          {
            "node": "Merge Customer with Catalog",
            "type": "main",
            "index": 1
          }
        ]
      ]
    },
    "OpenAI Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "AI Recommendation Agent",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Merge Customer with Catalog": {
      "main": [
        [
          {
            "node": "AI Recommendation Agent",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "AI Recommendation Agent": {
      "main": [
        [
          {
            "node": "Prepare Email Data",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Prepare Email Data": {
      "main": [
        [
          {
            "node": "Build HTML Email",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Build HTML Email": {
      "main": [
        [
          {
            "node": "Send Email",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "New Customer Trigger": {
      "main": [
        [
          {
            "node": "Get Beat Catalog for New Customer",
            "type": "main",
            "index": 0
          },
          {
            "node": "Merge New Customer with Catalog",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get Beat Catalog for New Customer": {
      "main": [
        [
          {
            "node": "Merge New Customer with Catalog",
            "type": "main",
            "index": 1
          }
        ]
      ]
    },
    "OpenAI Chat Model for New Customer": {
      "ai_languageModel": [
        [
          {
            "node": "AI Welcome Agent",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Merge New Customer with Catalog": {
      "main": [
        [
          {
            "node": "AI Welcome Agent",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "AI Welcome Agent": {
      "main": [
        [
          {
            "node": "Prepare Welcome Email Data",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Prepare Welcome Email Data": {
      "main": [
        [
          {
            "node": "Build Welcome HTML Email",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Build Welcome HTML Email": {
      "main": [
        [
          {
            "node": "Send Welcome Email",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "active": false,
  "settings": {
    "executionOrder": "v1",
    "binaryMode": "separate"
  },
  "versionId": "4014797a-5b07-4a63-ab6d-e5e575d8e443",
  "meta": {
    "instanceId": "1ba0e779608fabcd69faca382101ec17bf81e8d793716f2454ee93ae23331a22"
  },
  "id": "zWgoPKktHIsojSWo",
  "tags": []
}