{
 "name": "Mendera · 010 · Gastos del mes con foto del ticket",
 "nodes": [
  {
   "id": "a0100000-0000-4000-8000-000000000001",
   "name": "Mendera Systems",
   "parameters": {
    "content": "## Creado con Mendera Systems\nmenderasystems.com — Sistema 010 de la biblioteca.\nSi te lo han pasado, es gratis: el resto de la biblioteca está en menderasystems.com/biblioteca-de-sistemas.",
    "height": 160,
    "width": 420
   },
   "position": [
    0,
    -160
   ],
   "type": "n8n-nodes-base.stickyNote",
   "typeVersion": 1
  },
  {
   "id": "a0100000-0000-4000-8000-000000000002",
   "name": "Cómo se monta",
   "parameters": {
    "content": "## Cómo se monta\n1. Importa este archivo en n8n (Workflows → Import from File).\n2. Conecta tu credencial de WhatsApp Business en «WhatsApp Trigger» y en «Responder «Gasto apuntado»».\n3. En «Responder «Gasto apuntado»», pon tu Phone Number ID en TU_PHONE_NUMBER_ID.\n4. Crea una hoja de cálculo con las columnas fecha | importe | nota y pon su ID en TU_ID_DE_HOJA.\n5. Conecta tu credencial de Google Sheets en «Guardar gasto».\n6. Activa el flujo. Para apuntar un gasto, manda la foto del ticket con el pie «gasto:» seguido del importe (por ejemplo, «gasto: 12.50 café»). La foto queda en el chat; a la hoja van la fecha y el importe.",
    "height": 380,
    "width": 420
   },
   "position": [
    0,
    40
   ],
   "type": "n8n-nodes-base.stickyNote",
   "typeVersion": 1
  },
  {
   "id": "a0100000-0000-4000-8000-000000000003",
   "name": "WhatsApp Trigger",
   "parameters": {
    "options": {},
    "updates": [
     "messages"
    ]
   },
   "position": [
    480,
    300
   ],
   "type": "n8n-nodes-base.whatsAppTrigger",
   "typeVersion": 1,
   "webhookId": "a0100000-0000-4000-8000-000000000003",
   "credentials": {
    "whatsAppTriggerApi": {
     "id": "",
     "name": "TU_CREDENCIAL_WHATSAPP_TRIGGER"
    }
   }
  },
  {
   "id": "a0100000-0000-4000-8000-000000000006",
   "name": "¿Foto con «gasto:»?",
   "parameters": {
    "conditions": {
     "combinator": "and",
     "conditions": [
      {
       "id": "a0100000-0000-4000-8000-000000000004",
       "leftValue": "={{ $json.messages[0].type }}",
       "operator": {
        "operation": "equals",
        "type": "string"
       },
       "rightValue": "image"
      },
      {
       "id": "a0100000-0000-4000-8000-000000000005",
       "leftValue": "={{ $json.messages[0].image.caption }}",
       "operator": {
        "operation": "startsWith",
        "type": "string"
       },
       "rightValue": "gasto:"
      }
     ],
     "options": {
      "caseSensitive": true,
      "leftValue": "",
      "typeValidation": "loose"
     }
    },
    "options": {}
   },
   "position": [
    720,
    300
   ],
   "type": "n8n-nodes-base.if",
   "typeVersion": 2
  },
  {
   "id": "a0100000-0000-4000-8000-000000000007",
   "name": "Guardar gasto",
   "parameters": {
    "columns": {
     "mappingMode": "defineBelow",
     "value": {
      "fecha": "={{ $now.toISO() }}",
      "importe": "={{ $json.messages[0].image.caption.slice(6).trim() }}",
      "nota": "foto recibida"
     }
    },
    "documentId": {
     "__rl": true,
     "mode": "id",
     "value": "TU_ID_DE_HOJA"
    },
    "operation": "append",
    "sheetName": {
     "__rl": true,
     "mode": "name",
     "value": "Gastos"
    }
   },
   "position": [
    960,
    140
   ],
   "type": "n8n-nodes-base.googleSheets",
   "typeVersion": 4,
   "credentials": {
    "googleSheetsOAuth2Api": {
     "id": "",
     "name": "TU_CREDENCIAL_GOOGLE_SHEETS"
    }
   }
  },
  {
   "id": "a0100000-0000-4000-8000-000000000008",
   "name": "Responder «Gasto apuntado»",
   "parameters": {
    "additionalFields": {},
    "operation": "send",
    "phoneNumberId": "TU_PHONE_NUMBER_ID",
    "recipientPhoneNumber": "={{ $json.messages[0].from }}",
    "textBody": "=Gasto apuntado: {{ $json.messages[0].image.caption.slice(6).trim() }}."
   },
   "position": [
    960,
    300
   ],
   "type": "n8n-nodes-base.whatsApp",
   "typeVersion": 1,
   "credentials": {
    "whatsAppApi": {
     "id": "",
     "name": "TU_CREDENCIAL_WHATSAPP"
    }
   }
  }
 ],
 "connections": {
  "WhatsApp Trigger": {
   "main": [
    [
     {
      "node": "¿Foto con «gasto:»?",
      "type": "main",
      "index": 0
     }
    ]
   ]
  },
  "¿Foto con «gasto:»?": {
   "main": [
    [
     {
      "node": "Guardar gasto",
      "type": "main",
      "index": 0
     },
     {
      "node": "Responder «Gasto apuntado»",
      "type": "main",
      "index": 0
     }
    ],
    []
   ]
  }
 },
 "active": false,
 "settings": {
  "executionOrder": "v1"
 },
 "pinData": {}
}
