{
  "id": "sgW9ciNP7KNuxk4M",
  "name": "AI-Driven Consent Dispute Reporting & Response Workflow",
  "tags": [],
  "nodes": [
    {
      "id": "cbe5276d-83e5-4a49-aee1-0c2cb93c1e83",
      "name": "Receive Consent Complaint",
      "type": "n8n-nodes-base.webhook",
      "position": [
        -752,
        -272
      ],
      "parameters": {
        "path": "002db51e-bd01-4450-9e05-2fa462faa6cf",
        "options": {},
        "httpMethod": "POST"
      },
      "typeVersion": 2.1
    },
    {
      "id": "7d385bbd-b75c-4dcc-adb3-430edc0c785a",
      "name": "Check Required Fields",
      "type": "n8n-nodes-base.if",
      "position": [
        -416,
        -272
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "e2adb005-2b3c-4d1e-8445-442df1fe925a",
              "operator": {
                "type": "string",
                "operation": "notEmpty",
                "singleValue": true
              },
              "leftValue": "={{ $json.body.description }}",
              "rightValue": ""
            }
          ]
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "7f77ea83-4a09-49a6-bfc2-a8f0f93b9f46",
      "name": "Clean & Normalize Complaint Data",
      "type": "n8n-nodes-base.code",
      "position": [
        -112,
        -288
      ],
      "parameters": {
        "jsCode": "// Incoming data from webhook\nconst input = $json;\n\n// Extract only relevant fields and clean data\nconst cleanData = {\n  ticketId: `T-${Date.now()}`,                     \n  action: input.body?.action || null,\n  name: input.body?.name || null,\n  email: input.body?.email || null,\n  issueType: input.body?.issueType || null,\n  description: input.body?.description || null,\n  timestamp: input.body?.timestamp || new Date().toISOString(),\n\n  // Additional useful metadata\n  status: \"Open\",\n  priority: input.body?.issueType === \"unauthorized-data-use\" ? \"High\" : \"Normal\",\n  source: input.headers?.origin || \"unknown\"\n};\n\n// Return clean formatted output for next nodes\nreturn [{ json: cleanData }];\n"
      },
      "typeVersion": 2
    },
    {
      "id": "10cdddc5-a71d-4b24-9955-68cc7d8babf4",
      "name": "Log Invalid Complaint Records to Google Sheets",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        -192,
        208
      ],
      "parameters": {
        "operation": "append",
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": "",
          "cachedResultUrl": "",
          "cachedResultName": ""
        },
        "documentId": {
          "__rl": true,
          "mode": "url",
          "value": ""
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4.6
    },
    {
      "id": "3d94139c-bfb9-4406-98d1-26869e21b7ac",
      "name": "Store Complaint Ticket in Consent Dispute Sheet",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        144,
        192
      ],
      "parameters": {
        "operation": "append",
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": "",
          "cachedResultUrl": "",
          "cachedResultName": ""
        },
        "documentId": {
          "__rl": true,
          "mode": "url",
          "value": ""
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4.6
    },
    {
      "id": "ab685ae5-c047-45a0-b6a5-69a3b6dac532",
      "name": "Generate Acknowledgement Email",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        416,
        -288
      ],
      "parameters": {
        "text": "=Generate a formal acknowledgement email for the data consent complaint based on the following details:\n\nTicket ID: {{$json.ticketId}}\nUser Name: {{$json.name}}\nUser Email: {{$json.email}}\nIssue Type: {{$json.issueType}}\nDescription: {{$json.description}}\nReported At: {{$json.timestamp}}\nPriority Level: {{$json.priority}}\n\nThe email must:\n- Start with a greeting using the user's name\n- Acknowledge receipt of their concern\n- Mention the ticket ID clearly\n- Summarize their reported issue in a respectful way\n- Inform that the privacy/compliance team will review and respond\n- Provide an estimated response window (48\u201372 hours)\n- Offer them an option to share any additional information\n- Close professionally\n\nNow generate the final email.\n",
        "options": {
          "systemMessage": "=You are an AI assistant working for a privacy-focused organization that follows the Digital Personal Data Protection (DPDP) Act, India. \nYour job is to generate professional, empathetic, and compliant email responses related to data consent, privacy issues, and complaints.\n\nGuidelines you MUST follow:\n- Be polite, respectful, and supportive.\n- Acknowledge the user's concern clearly.\n- Never admit fault, wrongdoing, or share internal confidential details.\n- Avoid legal promises, guarantees, or commitments.\n- Do not provide technical investigation details.\n- Use formal yet friendly tone.\n- Mention ticket ID.\n- Inform the user about next steps and expected timelines.\n- Encourage them to reply if they have more details.\n\nResponse Format Rules:\n- Write as a professional customer support email.\n- Use short paragraphs and simple language.\n- No emojis, no slang, no hype.\n- End with an official polite closing.\n\nYou must output ONLY the final email message \u2014 do NOT explain or add extra notes.\n"
        },
        "promptType": "define"
      },
      "typeVersion": 2.1
    },
    {
      "id": "91653813-33dd-40a1-8773-7b907f437734",
      "name": "Configure GPT-4o \u2013 Email Generator",
      "type": "@n8n/n8n-nodes-langchain.lmChatAzureOpenAi",
      "position": [
        416,
        -80
      ],
      "parameters": {
        "model": "gpt-4o",
        "options": {}
      },
      "credentials": {
        "azureOpenAiApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "dc5d4edd-f4b4-45c7-881a-6ece95694ad4",
      "name": "Extract Email Subject + Body",
      "type": "n8n-nodes-base.code",
      "position": [
        816,
        -288
      ],
      "parameters": {
        "jsCode": "const raw = $json.output;\n\n// Normalize line breaks\nconst text = raw.replace(/\\r\\n/g, \"\\n\").trim();\n\n// Extract subject (everything until first newline)\nconst firstLineBreak = text.indexOf(\"\\n\");\nlet subject = \"\";\nlet message = \"\";\n\n// If we found a line break, split\nif (firstLineBreak !== -1) {\n  subject = text.substring(0, firstLineBreak).replace(\"Subject:\", \"\").trim();\n  message = text.substring(firstLineBreak).trim();\n} else {\n  // fallback if no newline found\n  subject = text.replace(\"Subject:\", \"\").trim();\n  message = \"\";\n}\n\n// Return clean JSON\nreturn [{\n  json: {\n    subject,\n    message\n  }\n}];\n"
      },
      "typeVersion": 2
    },
    {
      "id": "5657485d-212c-44bc-a076-3f5eac5efc3b",
      "name": "Send Acknowledgement Email to User",
      "type": "n8n-nodes-base.gmail",
      "position": [
        1072,
        -288
      ],
      "parameters": {
        "sendTo": "={{ $('Receive Consent Complaint').item.json.body.email }}",
        "message": "={{ $json.message }}",
        "options": {},
        "subject": "={{ $json.subject }}"
      },
      "credentials": {
        "gmailOAuth2": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 2.1
    },
    {
      "id": "324e339f-7809-4883-9e15-37e215c52ab3",
      "name": "Configure GPT-4o \u2013 Slack Summary Model",
      "type": "@n8n/n8n-nodes-langchain.lmChatAzureOpenAi",
      "position": [
        1360,
        -32
      ],
      "parameters": {
        "model": "gpt-4o",
        "options": {}
      },
      "credentials": {
        "azureOpenAiApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "d4241f68-8042-4cc2-be84-aecfdca7cc3b",
      "name": "Generate Slack Incident Summary",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        1360,
        -288
      ],
      "parameters": {
        "text": "=Create an internal Slack notification message summarizing the newly received consent-related complaint using the following data:\n\nTicket ID: {{ $('Clean & Normalize Complaint Data').item.json.ticketId }}\nUser Name: {{ $('Clean & Normalize Complaint Data').item.json.name }}\nUser Email: {{ $('Clean & Normalize Complaint Data').item.json.email }}\nIssue Type: {{ $('Clean & Normalize Complaint Data').item.json.issueType }}\nDescription: {{ $('Clean & Normalize Complaint Data').item.json.description }}\nReported At: {{ $('Clean & Normalize Complaint Data').item.json.timestamp }}\nPriority: {{ $('Clean & Normalize Complaint Data').item.json.priority }}\nStatus: {{ $('Clean & Normalize Complaint Data').item.json.status }}\n\nInstruction:\n- Keep it concise and action-focused.\n- Add a short recommended next step for the team.\n- Format clearly using short lines.\n- Do not write like an email.\n",
        "options": {
          "systemMessage": "=You are an AI assistant generating internal team notifications for privacy and compliance workflows. \nThe message must be formatted for Slack, short, clear, and actionable. \nUse a professional but fast-moving internal tone.\nDo NOT write like an email. \nDo NOT add greetings or signatures. \nUse simple line breaks and bullet points if needed. \nInclude urgency, ticket reference, issue type, and requested action. \nDo NOT add emojis unless instructed.\nOutput should ONLY contain the Slack message text, nothing else.\n"
        },
        "promptType": "define"
      },
      "typeVersion": 2.1
    },
    {
      "id": "992919fb-3739-4b23-8f99-d12b63cdf6c9",
      "name": "Slack \u2013 Notify Compliance Team",
      "type": "n8n-nodes-base.slack",
      "notes": "Sends formatted notification to #product-faqs channel with FAQ summary, category, and links",
      "position": [
        1760,
        -288
      ],
      "parameters": {
        "text": "={{ $json.output }}",
        "user": {
          "__rl": true,
          "mode": "list",
          "value": "U09HMPVD466",
          "cachedResultName": "newscctv22"
        },
        "select": "user",
        "otherOptions": {
          "includeLinkToWorkflow": false
        }
      },
      "credentials": {
        "slackApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 2.1
    },
    {
      "id": "89a1f190-aa8e-467a-9c51-908d503c3941",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1504,
        -896
      ],
      "parameters": {
        "width": 640,
        "height": 496,
        "content": "## \ud83d\udee1\ufe0f AI-Driven Consent Dispute Reporting & Response Workflow\nHandles and tracks user complaints regarding data consent or privacy under the DPDP Act.  \nAutomates ticket creation, acknowledgment emails, and internal compliance notifications.\n\n### \ud83d\udd39 Workflow Overview\n1\ufe0f\u20e3 Webhook receives consent complaint from UI  \n2\ufe0f\u20e3 Validates mandatory fields (name, email, description)  \n3\ufe0f\u20e3 Cleans and normalizes incoming data  \n4\ufe0f\u20e3 Generates a unique Ticket ID + assigns priority  \n5\ufe0f\u20e3 Stores complaint details in Google Sheets  \n6\ufe0f\u20e3 Sends user acknowledgement email via GPT-4o  \n7\ufe0f\u20e3 Notifies the compliance team on Slack  \n\n### \ud83d\udd39 Tools & Integrations\n- **Webhook** \u2192 Complaint intake  \n- **Azure GPT-4o** \u2192 AI-generated emails and Slack messages  \n- **Google Sheets** \u2192 Ticket storage  \n- **Gmail** \u2192 User communication  \n- **Slack** \u2192 Team alert system  \n"
      },
      "typeVersion": 1
    },
    {
      "id": "e6ce7324-4d78-429c-ac9b-f5197e2f9c25",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -800,
        -464
      ],
      "parameters": {
        "color": 7,
        "width": 544,
        "height": 384,
        "content": "## Intake & Validation  \nWebhook receives complaint payload \u2192 Mandatory field check performed.  \nInvalid submissions are logged separately in Google Sheets for audit + retries.\n"
      },
      "typeVersion": 1
    },
    {
      "id": "6cafdc7d-f8e8-4dc2-bde0-0013c0d23641",
      "name": "Sticky Note2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -176,
        -512
      ],
      "parameters": {
        "color": 7,
        "height": 480,
        "content": "## Data Normalization & Ticket Creation  \n- Generates unique Ticket ID  \n- Assigns status and priority  \n- Extracts relevant complainant information  \n- Prepares clean JSON for downstream actions\n"
      },
      "typeVersion": 1
    },
    {
      "id": "8b47f5bf-c74c-472b-9080-7d93c20a7ef5",
      "name": "Sticky Note3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -320,
        64
      ],
      "parameters": {
        "color": 7,
        "width": 640,
        "height": 336,
        "content": "## Complaint Storage & Logging  \nValid complaints \u2192 appended to \"Consent Dispute\" sheet  \nInvalid complaints \u2192 appended to \"Invalid Intake\" sheet  \nUsed for compliance, tracking, reporting & audits\n"
      },
      "typeVersion": 1
    },
    {
      "id": "dd87cf63-78f3-43ed-b0c9-cb881acc75ae",
      "name": "Sticky Note4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        256,
        -480
      ],
      "parameters": {
        "color": 7,
        "width": 960,
        "height": 528,
        "content": "## Acknowledgement Email Flow  \nGPT-4o drafts DPDP-compliant acknowledgement \u2192 Subject & body parsed \u2192  \nDelivered automatically via Gmail to complainant.\n"
      },
      "typeVersion": 1
    },
    {
      "id": "45f6436d-7836-4c31-bd24-9836eaab09e1",
      "name": "Sticky Note5",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1296,
        -480
      ],
      "parameters": {
        "color": 7,
        "width": 672,
        "height": 608,
        "content": "## Slack Compliance Alert  \nGenerates concise internal summary with ticket reference, priority & description  \n\u2192 Sent to compliance team for immediate action & follow-up.\n"
      },
      "typeVersion": 1
    }
  ],
  "active": false,
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "ba23be4f-d4ba-488d-9ab6-49c0b51286c1",
  "connections": {
    "Check Required Fields": {
      "main": [
        [
          {
            "node": "Clean & Normalize Complaint Data",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Log Invalid Complaint Records to Google Sheets",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Receive Consent Complaint": {
      "main": [
        [
          {
            "node": "Check Required Fields",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Extract Email Subject + Body": {
      "main": [
        [
          {
            "node": "Send Acknowledgement Email to User",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Generate Acknowledgement Email": {
      "main": [
        [
          {
            "node": "Extract Email Subject + Body",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Generate Slack Incident Summary": {
      "main": [
        [
          {
            "node": "Slack \u2013 Notify Compliance Team",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Clean & Normalize Complaint Data": {
      "main": [
        [
          {
            "node": "Store Complaint Ticket in Consent Dispute Sheet",
            "type": "main",
            "index": 0
          },
          {
            "node": "Generate Acknowledgement Email",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Send Acknowledgement Email to User": {
      "main": [
        [
          {
            "node": "Generate Slack Incident Summary",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Configure GPT-4o \u2013 Email Generator": {
      "ai_languageModel": [
        [
          {
            "node": "Generate Acknowledgement Email",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Configure GPT-4o \u2013 Slack Summary Model": {
      "ai_languageModel": [
        [
          {
            "node": "Generate Slack Incident Summary",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    }
  }
}