{
  "name": "Cogniz starter 6 · Website enquiry to sheet and owner, with AI sorting",
  "flow": [
    {
      "id": 1,
      "module": "gateway:CustomWebHook",
      "version": 1,
      "parameters": {},
      "mapper": {},
      "metadata": {
        "designer": {
          "x": 0,
          "y": 0,
          "name": "Receive the website form"
        }
      }
    },
    {
      "id": 2,
      "module": "datastore:ExistRecord",
      "version": 1,
      "parameters": {},
      "mapper": {
        "key": "{{lower(trim(1.email))}}|{{1.appliance}}|{{formatDate(now; \"YYYY-MM-DD\"; \"Africa/Johannesburg\")}}"
      },
      "metadata": {
        "designer": {
          "x": 300,
          "y": 0,
          "name": "Same email and appliance today?"
        }
      }
    },
    {
      "id": 3,
      "module": "datastore:AddRecord",
      "version": 1,
      "parameters": {},
      "mapper": {
        "key": "{{lower(trim(1.email))}}|{{1.appliance}}|{{formatDate(now; \"YYYY-MM-DD\"; \"Africa/Johannesburg\")}}",
        "overwrite": true,
        "data": {
          "seen": "{{formatDate(now; \"YYYY-MM-DD HH:mm\")}}"
        }
      },
      "metadata": {
        "designer": {
          "x": 600,
          "y": 0,
          "name": "Remember this request for today"
        }
      }
    },
    {
      "id": 4,
      "module": "ai-tools:Categorize",
      "version": 1,
      "parameters": {},
      "mapper": {
        "input": "{{1.problem}}",
        "categories": [
          {
            " ": "Repair request"
          },
          {
            " ": "Quote question"
          },
          {
            " ": "Complaint"
          },
          {
            " ": "Other"
          }
        ],
        "shouldGenerateDescription": true
      },
      "metadata": {
        "designer": {
          "x": 900,
          "y": 0,
          "name": "Make AI sorts the request"
        }
      }
    },
    {
      "id": 5,
      "module": "google-sheets:addRow",
      "version": 2,
      "parameters": {},
      "mapper": {
        "mode": "map",
        "spreadsheetId": "PASTE-YOUR-SPREADSHEET-ID",
        "sheetId": "Requests",
        "tableFirstRow": "A1:I1",
        "values": {
          "0": "{{formatDate(now; \"YYYY-MM-DD HH:mm\"; \"Africa/Johannesburg\")}}",
          "1": "{{1.name}}",
          "2": "{{1.email}}",
          "3": "{{1.phone}}",
          "4": "{{1.appliance}}",
          "5": "{{1.problem}}",
          "6": "{{1.preferred_day}}",
          "7": "{{join(4.categories; \", \")}}",
          "8": "{{if(2.exist; \"Possible repeat\"; \"New\")}}"
        },
        "insertUnformatted": false,
        "valueInputOption": "RAW",
        "insertDataOption": "INSERT_ROWS"
      },
      "metadata": {
        "designer": {
          "x": 1200,
          "y": 0,
          "name": "Add a row for the owner"
        }
      }
    },
    {
      "id": 6,
      "module": "email:ActionSendMeEmail",
      "version": 7,
      "parameters": {},
      "mapper": {
        "to": "",
        "subject": "{{if(2.exist; \"Possible repeat: \"; \"\")}}{{if(contains(4.categories; \"Other\"); \"Check by hand: \"; \"\")}}[{{join(4.categories; \", \")}}] Repair request from {{1.name}}",
        "html": "{{if(contains(4.categories; \"Other\"); \"<p><b>Check this one by hand: the AI wasn’t sure what it is.</b></p>\"; \"\")}}<p><b>Label:</b> {{join(4.categories; \", \")}}<br><b>Status:</b> {{if(2.exist; \"Possible repeat\"; \"New\")}}</p><p><b>From:</b> {{1.name}} ({{1.email}}, {{ifempty(1.phone; \"no phone given\")}})<br><b>Appliance:</b> {{1.appliance}}<br><b>Problem:</b> {{1.problem}}<br><b>Preferred day:</b> {{ifempty(1.preferred_day; \"none given\")}}</p><p>Reply with a written quote and a time. The AI suggests a label; you decide.</p>"
      },
      "metadata": {
        "designer": {
          "x": 1500,
          "y": 0,
          "name": "Email the owner"
        }
      }
    },
    {
      "id": 7,
      "module": "gateway:WebhookRespond",
      "version": 1,
      "parameters": {},
      "mapper": {
        "status": 200,
        "body": "<!doctype html><html lang=\"en\"><head><meta charset=\"utf-8\"><meta name=\"viewport\" content=\"width=device-width, initial-scale=1\"><title>Request received</title></head><body><main><h1>Thanks, we’ve received your request</h1><p>The owner will reply with a written quote and a time. Your repair isn’t booked yet.</p></main></body></html>",
        "headers": [
          {
            "key": "Content-Type",
            "value": "text/html; charset=utf-8"
          }
        ]
      },
      "metadata": {
        "designer": {
          "x": 1800,
          "y": 0,
          "name": "Show the visitor an honest reply"
        }
      }
    }
  ],
  "metadata": {
    "instant": false,
    "version": 1,
    "scenario": {
      "roundtrips": 1,
      "maxErrors": 3,
      "autoCommit": true,
      "autoCommitTriggerLast": true,
      "sequential": false,
      "confidential": false,
      "dataloss": false,
      "dlq": false,
      "freshVariables": false
    },
    "designer": {
      "orphans": []
    },
    "zone": "eu1.make.com"
  }
}
