{
  "name": "Enroutia · Brand report from a form",
  "nodes": [
    {
      "parameters": {
        "formTitle": "What do the AI models say about your brand?",
        "formDescription": "Six questions to the chat models, answered from memory. The report arrives by email in a few minutes.",
        "formFields": {
          "values": [
            {
              "fieldLabel": "Brand",
              "requiredField": true
            },
            {
              "fieldLabel": "Sector",
              "requiredField": true,
              "placeholder": "e.g. web analytics"
            },
            {
              "fieldLabel": "Category",
              "requiredField": true,
              "placeholder": "e.g. cookieless web analytics tool"
            },
            {
              "fieldLabel": "Country",
              "placeholder": "Spain"
            },
            {
              "fieldLabel": "Competitors",
              "placeholder": "Up to three, comma separated"
            }
          ]
        },
        "options": {}
      },
      "name": "Brand report form",
      "type": "n8n-nodes-base.formTrigger",
      "typeVersion": 2.2,
      "position": [
        0,
        0
      ],
      "webhookId": "enroutia-brand-report-form"
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "enroutia_api",
              "name": "ENROUTIA_API",
              "value": "https://platform.enroutia.com",
              "type": "string"
            }
          ]
        },
        "includeOtherFields": true,
        "options": {}
      },
      "name": "Settings",
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        220,
        0
      ]
    },
    {
      "parameters": {
        "method": "POST",
        "url": "={{ $('Settings').item.json.ENROUTIA_API }}/api/brand-reports",
        "authentication": "genericCredentialType",
        "genericAuthType": "httpHeaderAuth",
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "Content-Type",
              "value": "application/json"
            }
          ]
        },
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={{ JSON.stringify({\n  brand: $json.Brand,\n  sector: $json.Sector,\n  category: $json.Category,\n  country: $json.Country || 'Spain',\n  competitors: String($json.Competitors || '').split(',').map((c) => c.trim()).filter(Boolean).slice(0, 3),\n  client_ref: 'n8n-' + $execution.id\n}) }}",
        "options": {
          "timeout": 30000
        }
      },
      "name": "Request report",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        460,
        0
      ],
      "credentials": {
        "httpHeaderAuth": {
          "name": "Enroutia account token"
        }
      }
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "report_id",
              "name": "report_id",
              "value": "={{ $json.id }}",
              "type": "string"
            },
            {
              "id": "status",
              "name": "status",
              "value": "={{ $json.status }}",
              "type": "string"
            },
            {
              "id": "client_ref",
              "name": "client_ref",
              "value": "={{ $json.client_ref }}",
              "type": "string"
            },
            {
              "id": "estimate_cents",
              "name": "estimate_cents",
              "value": "={{ $json.estimate_cents }}",
              "type": "number"
            },
            {
              "id": "report_path",
              "name": "report_path",
              "value": "={{ $json.report_path }}",
              "type": "string"
            }
          ]
        },
        "options": {}
      },
      "name": "Keep the report id",
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        700,
        0
      ]
    }
  ],
  "connections": {
    "Brand report form": {
      "main": [
        [
          {
            "node": "Settings",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Request report": {
      "main": [
        [
          {
            "node": "Keep the report id",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Settings": {
      "main": [
        [
          {
            "node": "Request report",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "active": false,
  "settings": {
    "executionOrder": "v1"
  },
  "pinData": {},
  "meta": {
    "templateCredsSetupCompleted": false
  },
  "tags": []
}
