{
  "name": "Monitor customer risk and AI feedback using PostgreSQL, Gmail and Discord",
  "nodes": [
    {
      "id": "49c8bb24-a4ee-45bb-be6a-066f45335fb9",
      "name": "Get row(s) in sheet1",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        0,
        1536
      ]
    },
    {
      "id": "20a4d950-d390-4b42-8263-234d2b7d96a7",
      "name": "HTTP Request1",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        656,
        1680
      ]
    },
    {
      "id": "c399da16-08d8-4a4d-bff4-3ec025ddc857",
      "name": "Prompt For Model1",
      "type": "n8n-nodes-base.code",
      "position": [
        448,
        1680
      ]
    },
    {
      "id": "0e383847-6910-45d2-b423-c47ac2b99208",
      "name": "Send a message1",
      "type": "n8n-nodes-base.gmail",
      "position": [
        624,
        1376
      ]
    },
    {
      "id": "65c11aa1-c95b-4633-be18-65e1cde88d5f",
      "name": "Loop Over Items1",
      "type": "n8n-nodes-base.splitInBatches",
      "position": [
        208,
        1536
      ]
    },
    {
      "id": "28a05055-10a4-4731-93c3-0ab6c49b4319",
      "name": "Merge1",
      "type": "n8n-nodes-base.merge",
      "position": [
        432,
        1376
      ]
    },
    {
      "id": "c11b9708-dca8-40bb-9191-51faaf5e2037",
      "name": "Wait1",
      "type": "n8n-nodes-base.wait",
      "position": [
        1328,
        1680
      ]
    },
    {
      "id": "937882db-fded-4585-8990-ee2a550de148",
      "name": "Code in JavaScript",
      "type": "n8n-nodes-base.code",
      "position": [
        864,
        1680
      ]
    },
    {
      "id": "e25491e2-b55b-4944-824e-e6b533c837a2",
      "name": "Append or update row in sheet",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        1120,
        1680
      ]
    },
    {
      "id": "8052fb12-4a9b-4c55-83eb-85ef176ed0d2",
      "name": "Weekly schedule1",
      "type": "n8n-nodes-base.scheduleTrigger",
      "position": [
        -736,
        1360
      ]
    },
    {
      "id": "67f0f63a-6fd0-4d73-ab64-7ed6e2969810",
      "name": "Edit Fields2",
      "type": "n8n-nodes-base.set",
      "position": [
        -544,
        1360
      ]
    },
    {
      "id": "d1216d5e-7211-4918-9d8d-3392ac9a22cd",
      "name": "Switch1",
      "type": "n8n-nodes-base.switch",
      "position": [
        -320,
        1216
      ]
    },
    {
      "id": "c8eb6f4d-18ba-4f03-b293-8fb3db8ed238",
      "name": "Edit Fields3",
      "type": "n8n-nodes-base.set",
      "position": [
        -560,
        1024
      ]
    },
    {
      "id": "ab395ee2-12ef-453d-b8f6-451716f2460e",
      "name": "Fetch Customer Risk Data",
      "type": "n8n-nodes-base.postgres",
      "position": [
        0,
        944
      ]
    },
    {
      "id": "7f150f40-00fb-4fa6-a39d-ace9e1ffe2a6",
      "name": "Is High Risk Customer?",
      "type": "n8n-nodes-base.if",
      "position": [
        208,
        944
      ]
    },
    {
      "id": "cc8bcac8-ac7b-498e-af68-c8583fabdd88",
      "name": "Send a message4",
      "type": "n8n-nodes-base.gmail",
      "position": [
        1024,
        848
      ]
    },
    {
      "id": "23c4158b-793e-49e9-8c9b-ad4d881e7cbc",
      "name": "Merge Risk Result",
      "type": "n8n-nodes-base.merge",
      "position": [
        768,
        944
      ]
    },
    {
      "id": "45dc326e-9cf3-4b35-a3f0-819cafc5ec8c",
      "name": "Prepare Escalation Summary For Low Risk User",
      "type": "n8n-nodes-base.set",
      "position": [
        480,
        816
      ]
    },
    {
      "id": "7cdc752d-eb50-4e7c-b500-f4544b63da29",
      "name": "Prepare Escalation Summary For High Risk User",
      "type": "n8n-nodes-base.set",
      "position": [
        480,
        1088
      ]
    },
    {
      "id": "25b76243-1ac2-4a98-9499-74dba8e5af06",
      "name": "Code in JavaScript3",
      "type": "n8n-nodes-base.code",
      "position": [
        1312,
        928
      ]
    },
    {
      "id": "24ab89ed-374e-4c9b-8155-c651d89dfde1",
      "name": "Append or update row in sheet3",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        1520,
        928
      ]
    },
    {
      "id": "71439232-d3d2-4692-96aa-4b6f9ba12ff9",
      "name": "Send a message5",
      "type": "n8n-nodes-base.discord",
      "position": [
        1040,
        1072
      ]
    },
    {
      "id": "528a94a8-4521-41dc-b47f-893ab8867d43",
      "name": "Sticky Note3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        0,
        1280
      ],
      "parameters": {
        "width": 1728,
        "height": 640,
        "content": "## Step3: AI Feedback & Reporting\nGenerates product insights from customer issues.\nSends summaries and logs results for audits and analysis."
      }
    },
    {
      "id": "fa8e9436-7516-4579-a4cb-9b00c0f69c6d",
      "name": "Daily Risk Check Trigger",
      "type": "n8n-nodes-base.scheduleTrigger",
      "position": [
        -736,
        1024
      ]
    },
    {
      "id": "94cccad1-44ed-4615-b32b-3f2a251cbfcf",
      "name": "Sticky Note4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1456,
        832
      ],
      "parameters": {
        "width": 624,
        "height": 1008,
        "content": "## Customer Health Monitoring & Product Feedback Intelligence\n\n### How it works\nThis workflow monitors customer health by combining payment behavior and customer feedback with AI-driven product intell"
      }
    },
    {
      "id": "592a6d55-7dcd-4435-9f49-147ea7c66020",
      "name": "Sticky Note5",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -816,
        832
      ],
      "parameters": {
        "width": 800,
        "height": 1008,
        "content": "## Step 1: Triggers & Mode Selection\nRuns on daily and weekly schedules.\nDetermines whether the execution is a risk scan or a summary run."
      }
    },
    {
      "id": "7f379dae-ba02-4b76-902c-f18b06dcc469",
      "name": "Sticky Note6",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        0,
        656
      ],
      "parameters": {
        "width": 1728,
        "height": 608,
        "content": "## Step2: Risk Evaluation & Escalation\nFetches customer and payment data.\nClassifies customers into low or high risk and prepares escalation records."
      }
    }
  ],
  "connections": {
    "Wait1": {
      "main": [
        [
          {
            "node": "Loop Over Items1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Merge1": {
      "main": [
        [
          {
            "node": "Send a message1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Switch1": {
      "main": [
        [
          {
            "node": "Fetch Customer Risk Data",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Get row(s) in sheet1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Edit Fields2": {
      "main": [
        [
          {
            "node": "Switch1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Edit Fields3": {
      "main": [
        [
          {
            "node": "Switch1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "HTTP Request1": {
      "main": [
        [
          {
            "node": "Code in JavaScript",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Send a message4": {
      "main": [
        [
          {
            "node": "Code in JavaScript3",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Loop Over Items1": {
      "main": [
        [
          {
            "node": "Merge1",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Prompt For Model1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Weekly schedule1": {
      "main": [
        [
          {
            "node": "Edit Fields2",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Merge Risk Result": {
      "main": [
        [
          {
            "node": "Send a message4",
            "type": "main",
            "index": 0
          },
          {
            "node": "Send a message5",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Prompt For Model1": {
      "main": [
        [
          {
            "node": "HTTP Request1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Code in JavaScript": {
      "main": [
        [
          {
            "node": "Append or update row in sheet",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Code in JavaScript3": {
      "main": [
        [
          {
            "node": "Append or update row in sheet3",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get row(s) in sheet1": {
      "main": [
        [
          {
            "node": "Loop Over Items1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Is High Risk Customer?": {
      "main": [
        [
          {
            "node": "Prepare Escalation Summary For Low Risk User",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Prepare Escalation Summary For High Risk User",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Daily Risk Check Trigger": {
      "main": [
        [
          {
            "node": "Edit Fields3",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Fetch Customer Risk Data": {
      "main": [
        [
          {
            "node": "Is High Risk Customer?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Append or update row in sheet": {
      "main": [
        [
          {
            "node": "Wait1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Prepare Escalation Summary For Low Risk User": {
      "main": [
        [
          {
            "node": "Merge Risk Result",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Prepare Escalation Summary For High Risk User": {
      "main": [
        [
          {
            "node": "Merge Risk Result",
            "type": "main",
            "index": 1
          }
        ]
      ]
    }
  }
}