{
  "name": "G6 Mensaje a pedido con IA",
  "nodes": [
    {
      "parameters": {
        "formTitle": "Haz tu pedido",
        "formDescription": "Escríbelo como quieras: qué necesitas, cuántas piezas, para cuándo y tu correo.",
        "formFields": {
          "values": [
            {
              "fieldLabel": "Mensaje",
              "fieldType": "textarea"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.formTrigger",
      "typeVersion": 2.6,
      "position": [
        0,
        0
      ],
      "id": "91f0201d-63d3-467c-98f6-7cb4116d7c7d",
      "name": "Recibir mensaje",
      "webhookId": "24d7f79f-7408-4cbf-af4d-d659b47f4739"
    },
    {
      "parameters": {
        "text": "={{ $json.Mensaje }}",
        "schemaType": "manual",
        "inputSchema": "{\n  \"type\": \"object\",\n  \"properties\": {\n    \"nombre\": {\n      \"type\": \"string\",\n      \"description\": \"Nombre y apellido del cliente\"\n    },\n    \"producto\": {\n      \"type\": \"string\",\n      \"description\": \"Qué quiere imprimir, en minúsculas (volantes, tarjetas, lona...)\"\n    },\n    \"cantidad\": {\n      \"type\": \"number\",\n      \"description\": \"Cuántas piezas pide, solo el número\"\n    },\n    \"fecha_entrega\": {\n      \"type\": \"string\",\n      \"description\": \"Para cuándo lo necesita, en formato AAAA-MM-DD\"\n    },\n    \"correo\": {\n      \"type\": \"string\",\n      \"description\": \"Correo electrónico del cliente\"\n    }\n  },\n  \"required\": [\n    \"nombre\",\n    \"producto\",\n    \"cantidad\",\n    \"fecha_entrega\",\n    \"correo\"\n  ]\n}",
        "options": {
          "systemPromptTemplate": "=Eres el asistente de pedidos de una imprenta. Lee el mensaje del cliente y extrae solo los datos que pide el esquema.\nHoy es {{ $now.toFormat('yyyy-MM-dd') }}. Si el cliente dice una fecha relativa (\"el viernes\", \"mañana\"), conviértela a AAAA-MM-DD.\nSi un dato no aparece en el mensaje, déjalo vacío. No inventes nada."
        }
      },
      "type": "@n8n/n8n-nodes-langchain.informationExtractor",
      "typeVersion": 1.2,
      "position": [
        224,
        0
      ],
      "id": "5458b9fc-273e-4331-8467-cbe6053053bd",
      "name": "Extraer datos con IA"
    },
    {
      "parameters": {
        "model": {
          "__rl": true,
          "value": "claude-haiku-5-5",
          "mode": "id"
        },
        "options": {}
      },
      "type": "@n8n/n8n-nodes-langchain.lmChatAnthropic",
      "typeVersion": 1.6,
      "position": [
        160,
        208
      ],
      "id": "dde80e38-e894-44a5-8067-60b41a3779a8",
      "name": "Claude",
      "credentials": {
        "anthropicApi": {
          "id": "h7AWGSrwrrpTfwnS",
          "name": "G6 Anthropic"
        }
      }
    },
    {
      "parameters": {
        "dataTableId": {
          "__rl": true,
          "value": "n1xcD8sF0bccZr79",
          "mode": "list",
          "cachedResultName": "G6 Pedidos",
          "cachedResultUrl": "/projects/UUwwveoSJZuHP6z1/datatables/n1xcD8sF0bccZr79"
        },
        "columns": {
          "mappingMode": "defineBelow",
          "value": {
            "nombre": "={{ $json.output.nombre }}",
            "producto": "={{ $json.output.producto }}",
            "cantidad": "={{ $json.output.cantidad }}",
            "fecha_entrega": "={{ $json.output.fecha_entrega }}",
            "correo": "={{ $json.output.correo }}"
          },
          "matchingColumns": [],
          "schema": [
            {
              "id": "nombre",
              "displayName": "nombre",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "readOnly": false,
              "removed": false
            },
            {
              "id": "producto",
              "displayName": "producto",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "readOnly": false,
              "removed": false
            },
            {
              "id": "cantidad",
              "displayName": "cantidad",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "number",
              "readOnly": false,
              "removed": false
            },
            {
              "id": "fecha_entrega",
              "displayName": "fecha_entrega",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "readOnly": false,
              "removed": false
            },
            {
              "id": "correo",
              "displayName": "correo",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "readOnly": false,
              "removed": false
            }
          ],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {}
      },
      "type": "n8n-nodes-base.dataTable",
      "typeVersion": 1.1,
      "position": [
        592,
        0
      ],
      "id": "33315756-d581-4a53-9137-c1650a7fef59",
      "name": "Guardar en la tabla"
    }
  ],
  "connections": {
    "Recibir mensaje": {
      "main": [
        [
          {
            "node": "Extraer datos con IA",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Claude": {
      "ai_languageModel": [
        [
          {
            "node": "Extraer datos con IA",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Extraer datos con IA": {
      "main": [
        [
          {
            "node": "Guardar en la tabla",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "pinData": {},
  "settings": {
    "executionOrder": "v1",
    "binaryMode": "separate"
  },
  "active": false,
  "meta": {
    "templateCredsSetupCompleted": true
  },
  "tags": []
}