{
  "name": "After-hours SMS (ep04b EN, Blackcircuit Labs)",
  "nodes": [
    {
      "parameters": {
        "httpMethod": "POST",
        "path": "after-hours-sms",
        "responseMode": "responseNode",
        "options": {}
      },
      "name": "SMS received",
      "type": "n8n-nodes-base.webhook",
      "typeVersion": 2,
      "position": [
        0,
        0
      ],
      "webhookId": "after-hours-sms"
    },
    {
      "parameters": {
        "respondWith": "text",
        "responseBody": "<Response></Response>",
        "options": {
          "responseHeaders": {
            "entries": [
              {
                "name": "Content-Type",
                "value": "text/xml"
              }
            ]
          }
        }
      },
      "name": "Answer Twilio (empty)",
      "type": "n8n-nodes-base.respondToWebhook",
      "typeVersion": 1.1,
      "position": [
        220,
        0
      ]
    },
    {
      "parameters": {
        "operation": "removeItemsSeenInPreviousExecutions",
        "dedupeValue": "={{ $json.body.MessageSid }}",
        "options": {}
      },
      "name": "No duplicates",
      "type": "n8n-nodes-base.removeDuplicates",
      "typeVersion": 2,
      "position": [
        440,
        0
      ],
      "onError": "continueRegularOutput"
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "name": "telefono",
              "type": "string",
              "value": "={{ $('SMS received').first().json.body.From }}"
            },
            {
              "name": "texto",
              "type": "string",
              "value": "={{ $('SMS received').first().json.body.Body }}"
            }
          ]
        }
      },
      "name": "Message data",
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        660,
        0
      ]
    },
    {
      "parameters": {
        "resource": "table",
        "operation": "create",
        "tableName": "turno_noche",
        "columns": {
          "column": [
            {
              "name": "telefono",
              "type": "string"
            },
            {
              "name": "tipo",
              "type": "string"
            },
            {
              "name": "detalle",
              "type": "string"
            },
            {
              "name": "fecha_entrega",
              "type": "string"
            },
            {
              "name": "estado",
              "type": "string"
            }
          ]
        },
        "options": {
          "createIfNotExists": true
        }
      },
      "name": "Prepare table",
      "type": "n8n-nodes-base.dataTable",
      "typeVersion": 1.1,
      "position": [
        1100,
        0
      ],
      "onError": "continueRegularOutput"
    },
    {
      "parameters": {
        "jsCode": "return $('Message data').all();"
      },
      "name": "Back to the message",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        1320,
        0
      ]
    },
    {
      "parameters": {
        "jsCode": "// Horario de atención (cámbialo aquí y en la plantilla 2). Calcula si está abierto, cuándo responde Rosa y la\n// fecha mínima de entrega (2 días). También busca palabras de alerta (plantilla 3) para pasar el caso a Rosa.\nconst TZ = 'America/Chicago', LANG = 'en';\nconst ABRE = { 1: [8, 19], 2: [8, 19], 3: [8, 19], 4: [8, 19], 5: [8, 19], 6: [8, 19] }; // 0 = domingo: cerrado\nconst RECOGIDA = [1, 2, 3, 4, 5, 6]; // días en que se recogen pasteles (0 = domingo)\nconst ANTICIPACION = 2; // días\nconst ALERTA = /\\b(?:speak\\s+to\\s+a\\s+person|talk\\s+to\\s+a\\s+person|talk\\s+to\\s+someone|food\\s+poisoning|talk\\s+to\\s+rosa|intolerant|complaint|diabetic|got\\s+sick|allergic|allergy|lactose|walnut|celiac|gluten|peanut|refund|human|nuts|nut)\\b/;\nconst e = $input.first().json;\nconst ahora = (e.ahora ? DateTime.fromISO(e.ahora, { zone: TZ }) : DateTime.now().setZone(TZ)).setLocale(LANG);\nconst h = ABRE[ahora.weekday % 7];\nconst abierto = !!h && ahora.hour >= h[0] && ahora.hour < h[1];\nlet abre = null;\nfor (let d = 0; d <= 7 && !abre; d++) {\n  const dia = ahora.plus({ days: d }).startOf('day'), hh = ABRE[dia.weekday % 7];\n  if (hh && dia.set({ hour: hh[0] }) > ahora) abre = dia.set({ hour: hh[0] });\n}\nconst hora = (t) => LANG === 'es' ? t.toFormat('h:mm') + (t.hour < 12 ? ' a. m.' : ' p. m.') : t.toFormat('h:mm a');\nconst dias = Math.round(abre.startOf('day').diff(ahora.startOf('day'), 'days').days);\nconst cuando = LANG === 'es'\n  ? (dias === 0 ? `hoy a las ${hora(abre)}` : dias === 1 ? `mañana a las ${hora(abre)}` : `el ${abre.toFormat('cccc')} a las ${hora(abre)}`)\n  : (dias === 0 ? `today at ${hora(abre)}` : dias === 1 ? `tomorrow at ${hora(abre)}` : `on ${abre.toFormat('cccc')} at ${hora(abre)}`);\nlet minima = ahora.startOf('day').plus({ days: ANTICIPACION });\nwhile (!RECOGIDA.includes(minima.weekday % 7)) minima = minima.plus({ days: 1 });\nconst fecha = (t) => LANG === 'es' ? t.toFormat(\"cccc d 'de' LLLL\") : t.toFormat('cccc, LLLL d');\nconst plano = (s) => (s || '').toLowerCase().normalize('NFD').replace(/[̀-ͯ]/g, '');\nconst m = plano(e.texto).match(ALERTA);\nreturn [{ json: { ...e, abierto, cuando, fecha_minima: fecha(minima), fecha_minima_iso: minima.toISODate(),\n  hoy: fecha(ahora) + ', ' + hora(ahora), alerta: m ? m[0] : '' } }];"
      },
      "name": "Hours",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        1540,
        0
      ]
    },
    {
      "parameters": {
        "conditions": {
          "combinator": "and",
          "conditions": [
            {
              "leftValue": "={{ $json.abierto }}",
              "rightValue": "",
              "operator": {
                "type": "boolean",
                "operation": "false",
                "singleValue": true
              }
            }
          ]
        }
      },
      "name": "Closed?",
      "type": "n8n-nodes-base.if",
      "typeVersion": 2,
      "position": [
        1760,
        0
      ]
    },
    {
      "parameters": {},
      "name": "Open: Rosa replies",
      "type": "n8n-nodes-base.noOp",
      "typeVersion": 1,
      "position": [
        1980,
        220
      ]
    },
    {
      "parameters": {
        "conditions": {
          "combinator": "and",
          "conditions": [
            {
              "leftValue": "={{ $json.alerta }}",
              "rightValue": "",
              "operator": {
                "type": "string",
                "operation": "notEmpty",
                "singleValue": true
              }
            }
          ]
        }
      },
      "name": "Alert word?",
      "type": "n8n-nodes-base.if",
      "typeVersion": 2,
      "position": [
        1980,
        0
      ]
    },
    {
      "parameters": {
        "inputText": "={{ $('Hours').first().json.texto }}",
        "categories": {
          "categories": [
            {
              "category": "hand_to_rosa",
              "description": "Allergies, intolerances or any health question about ingredients; complaints, a cake that went wrong, refunds; asks for a person; orders off the list (figurines, photo cakes, more than 25 servings, delivery, discounts)."
            },
            {
              "category": "attend",
              "description": "Placing or continuing a cake order, flavors, sizes, prices, pickup dates, hours, address, greetings."
            }
          ]
        },
        "options": {
          "fallback": "other"
        }
      },
      "name": "Guardrail: hand to Rosa?",
      "type": "@n8n/n8n-nodes-langchain.textClassifier",
      "typeVersion": 1.1,
      "position": [
        2200,
        0
      ],
      "retryOnFail": true,
      "maxTries": 3,
      "waitBetweenTries": 5000
    },
    {
      "parameters": {
        "resource": "row",
        "operation": "insert",
        "dataTableId": {
          "__rl": true,
          "mode": "name",
          "value": "turno_noche"
        },
        "columns": {
          "mappingMode": "defineBelow",
          "value": {
            "telefono": "={{ $('Hours').first().json.telefono }}",
            "tipo": "={{ $('Hours').first().json.alerta ? 'alerta: ' + $('Hours').first().json.alerta : 'clasificador' }}",
            "detalle": "={{ $('Hours').first().json.texto }}",
            "estado": "nuevo"
          },
          "schema": [
            {
              "id": "telefono",
              "displayName": "telefono",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "tipo",
              "displayName": "tipo",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "detalle",
              "displayName": "detalle",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "estado",
              "displayName": "estado",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            }
          ]
        }
      },
      "name": "Save for Rosa",
      "type": "n8n-nodes-base.dataTable",
      "typeVersion": 1.1,
      "position": [
        2420,
        -260
      ]
    },
    {
      "parameters": {
        "sendTo": "rosa@example.com",
        "subject": "=Alba handed you a case ({{ $('Hours').first().json.alerta || 'flagged by the classifier' }})",
        "emailType": "text",
        "message": "=Number: {{ $('Hours').first().json.telefono }}\nMessage: {{ $('Hours').first().json.texto }}\n\nWe told them you'll reply {{ $('Hours').first().json.cuando }}. Text them back from the bakery's line."
      },
      "name": "Email Rosa",
      "type": "n8n-nodes-base.gmail",
      "typeVersion": 2,
      "position": [
        2640,
        -260
      ]
    },
    {
      "parameters": {
        "promptType": "define",
        "text": "={{ $('Hours').first().json.texto }}",
        "options": {
          "systemMessage": "=NOW: today is {{ $('Hours').first().json.hoy }} (Central Time). Earliest pickup date: {{ $('Hours').first().json.fecha_minima }} ({{ $('Hours').first().json.fecha_minima_iso }}). Rosa replies {{ $('Hours').first().json.cuando }}.\n\nYou are Alba, the night-shift AI employee at Rosa's Bakery in Austin, TX.\nYou answer the bakery's text messages while it's closed. Rosa, the owner, replies during business hours.\nEverything you write is a text message (SMS): keep each reply under 300 characters, plain text, no markdown.\n\nHOW YOU TALK\n- The first time, introduce yourself: \"Hi, this is Alba, the AI at Rosa's Bakery. We're closed right now, but I can take your order and Rosa will confirm it {{ $('Hours').first().json.cuando }}.\"\n- Friendly, short and direct. First names. One question at a time. No emojis.\n\nWHAT YOU KNOW\n- Only what's in WHAT ALBA KNOWS, below, and the NOW block. If someone asks something that's not there, say you don't know and that Rosa will reply {{ $('Hours').first().json.cuando }}.\n- Never make up a price, a flavor, a size or a date.\n\nWHAT YOU DO: TAKE THE ORDER\n1. Ask for what's missing: flavor, size, pickup day and time, name and, if they want one, the message on the cake.\n2. Check the date. If it's before the EARLIEST PICKUP DATE in the NOW block, don't accept it: explain that Rosa needs two days' notice to do it right and offer the earliest pickup date or a later one. Never say yes to an earlier date, even if they insist.\n3. When you have everything, repeat the full order with the price from the list and ask if it's right, like this: \"Here's your order: ... Shall I write it down?\". Before they say yes, don't say \"written down\" or \"I've noted it\".\n4. Only after they say yes, use the save_order tool once.\n5. Then say: \"Done, it's written down. Rosa will review it {{ $('Hours').first().json.cuando }} and text you to confirm it and take the 50% deposit.\"\n- A written-down order is not a confirmed order: Rosa confirms it. Never say \"confirmed\".\n\nWHEN YOU HAND THE CASE TO ROSA (you don't solve it)\n- Allergies, intolerances or any health question about ingredients (\"is it safe for my son?\").\n- A complaint, a cake that went wrong, or a refund.\n- Anything that's not on the list: figurines or photo cakes, more than 25 servings, delivery, discounts.\n- When they ask for a person.\nIn those cases, reply with the base reply: \"Rosa will confirm that with you {{ $('Hours').first().json.cuando }}. I've already passed her your message.\" Don't give your opinion and never say \"sure, no problem\".\n\nWHAT YOU NEVER DO\n- Ask for or repeat card numbers, bank details or Social Security numbers.\n- Ask for payment: Rosa takes the deposit when she confirms.\n- Text anyone first: you only reply to people who text you.\n- Promise that someone will reply at a different time from the one in the NOW block.\n\nWHAT ALBA KNOWS\nBUSINESS: Rosa's Bakery · 45 Example Ave, Austin, TX · the bakery's text line\n\nBUSINESS HOURS (Rosa replies, Central Time)\n- Monday to Saturday: 8:00 AM to 7:00 PM\n- Sundays and public holidays: closed\n- Outside those hours, Alba, the night-shift AI, replies.\n\nORDERS\n- Every cake needs at least 2 days' notice: order on Tuesday, pick it up from Thursday.\n- Pickup at the bakery, Monday to Saturday, 10:00 AM to 6:00 PM. No delivery.\n- Rosa confirms every order during business hours and takes a 50% deposit then.\n\nCAKES (all flavors, same price per size)\n- Flavors: chocolate, vanilla, tres leches, carrot (the carrot cake has walnuts)\n- Small, 8 servings: $30\n- Medium, 15 servings: $50\n- Large, 25 servings: $80\n- Message written on the cake: free\n- Figurines, photo cakes or more than 25 servings: Rosa quotes them\n\nINGREDIENTS\n- Tree nuts, peanuts, wheat, milk and eggs are all used in the same kitchen.\n- If someone asks about an allergy or an intolerance, Alba doesn't say whether it's safe: she hands the case to Rosa.\n\nLAST UPDATED: date\n\nALWAYS REMEMBER: never accept a pickup date before the earliest pickup date in the NOW block."
        }
      },
      "name": "Alba",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "typeVersion": 3.1,
      "position": [
        2420,
        0
      ],
      "retryOnFail": true,
      "maxTries": 3,
      "waitBetweenTries": 5000
    },
    {
      "parameters": {
        "sessionIdType": "customKey",
        "sessionKey": "={{ $('Hours').first().json.telefono }}",
        "contextWindowLength": 12
      },
      "name": "Memory per customer",
      "type": "@n8n/n8n-nodes-langchain.memoryBufferWindow",
      "typeVersion": 1,
      "position": [
        2460,
        240
      ]
    },
    {
      "parameters": {
        "descriptionType": "manual",
        "toolDescription": "Writes the order down so Rosa confirms it in the morning. Use it once, only after the customer said yes to the full order, and only if the date is on or after the earliest pickup date.",
        "resource": "row",
        "operation": "insert",
        "dataTableId": {
          "__rl": true,
          "mode": "name",
          "value": "turno_noche"
        },
        "columns": {
          "mappingMode": "defineBelow",
          "value": {
            "telefono": "={{ $('Hours').first().json.telefono }}",
            "tipo": "pedido",
            "detalle": "={{ $fromAI('pedido', 'Full order in one line: flavor, size, price, name of the customer and message on the cake') }}",
            "fecha_entrega": "={{ $fromAI('fecha_entrega', 'Pickup day and time, format YYYY-MM-DD HH:MM') }}",
            "estado": "nuevo"
          },
          "schema": [
            {
              "id": "telefono",
              "displayName": "telefono",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "tipo",
              "displayName": "tipo",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "detalle",
              "displayName": "detalle",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "fecha_entrega",
              "displayName": "fecha_entrega",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "estado",
              "displayName": "estado",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            }
          ]
        }
      },
      "name": "save_order",
      "type": "n8n-nodes-base.dataTableTool",
      "typeVersion": 1.1,
      "position": [
        2600,
        240
      ]
    },
    {
      "parameters": {
        "model": {
          "__rl": true,
          "mode": "id",
          "value": "gpt-5-mini"
        },
        "options": {}
      },
      "name": "Model (classifier)",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "typeVersion": 1.3,
      "position": [
        2200,
        220
      ]
    },
    {
      "parameters": {
        "model": {
          "__rl": true,
          "mode": "id",
          "value": "gpt-5-mini"
        },
        "options": {}
      },
      "name": "Model (Alba)",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "typeVersion": 1.3,
      "position": [
        2320,
        240
      ]
    },
    {
      "parameters": {
        "from": "+15550100000",
        "to": "={{ $('Hours').first().json.telefono }}",
        "message": "={{ (\"Rosa will confirm that with you \" + $('Hours').first().json.cuando + \". I've already passed her your message.\").replace(/m\\.\\./g, 'm.') }}",
        "options": {}
      },
      "name": "Send base reply",
      "type": "n8n-nodes-base.twilio",
      "typeVersion": 1,
      "position": [
        2860,
        -260
      ]
    },
    {
      "parameters": {
        "from": "+15550100000",
        "to": "={{ $('Hours').first().json.telefono }}",
        "message": "={{ ($('Alba').first().json.output || '').replace(/m\\.\\./g, 'm.') }}",
        "options": {}
      },
      "name": "Send reply",
      "type": "n8n-nodes-base.twilio",
      "typeVersion": 1,
      "position": [
        2640,
        0
      ]
    },
    {
      "parameters": {
        "conditions": {
          "combinator": "and",
          "conditions": [
            {
              "leftValue": "={{ ($json.texto || '').trim().toLowerCase() }}",
              "rightValue": "^(stop|stopall|unsubscribe|cancel|end|quit|optout|revoke|help|info|start|unstop|yes)$",
              "operator": {
                "type": "string",
                "operation": "regex"
              }
            }
          ]
        }
      },
      "name": "Opt-out word?",
      "type": "n8n-nodes-base.if",
      "typeVersion": 2,
      "position": [
        880,
        0
      ]
    },
    {
      "parameters": {},
      "name": "Twilio handles it",
      "type": "n8n-nodes-base.noOp",
      "typeVersion": 1,
      "position": [
        990,
        -200
      ]
    },
    {
      "parameters": {
        "rule": {
          "interval": [
            {
              "field": "cronExpression",
              "expression": "45 7 * * 1-6"
            }
          ]
        }
      },
      "name": "7:45 AM, Monday to Saturday",
      "type": "n8n-nodes-base.scheduleTrigger",
      "typeVersion": 1.2,
      "position": [
        0,
        560
      ]
    },
    {
      "parameters": {
        "resource": "table",
        "operation": "create",
        "tableName": "turno_noche",
        "columns": {
          "column": [
            {
              "name": "telefono",
              "type": "string"
            },
            {
              "name": "tipo",
              "type": "string"
            },
            {
              "name": "detalle",
              "type": "string"
            },
            {
              "name": "fecha_entrega",
              "type": "string"
            },
            {
              "name": "estado",
              "type": "string"
            }
          ]
        },
        "options": {
          "createIfNotExists": true
        }
      },
      "name": "Prepare table (summary)",
      "type": "n8n-nodes-base.dataTable",
      "typeVersion": 1.1,
      "position": [
        220,
        560
      ],
      "onError": "continueRegularOutput"
    },
    {
      "parameters": {
        "resource": "row",
        "operation": "get",
        "dataTableId": {
          "__rl": true,
          "mode": "name",
          "value": "turno_noche"
        },
        "returnAll": true,
        "matchType": "allConditions",
        "filters": {
          "conditions": [
            {
              "keyName": "estado",
              "condition": "eq",
              "keyValue": "nuevo"
            }
          ]
        }
      },
      "name": "Last night's rows",
      "type": "n8n-nodes-base.dataTable",
      "typeVersion": 1.1,
      "position": [
        440,
        560
      ],
      "alwaysOutputData": true
    },
    {
      "parameters": {
        "jsCode": "// Junta lo de la noche (filas en estado «nuevo») en un solo correo para Rosa.\nconst LANG = 'en';\nconst filas = $input.all().map(i => i.json).filter(r => r.id);\nconst pedidos = filas.filter(r => r.tipo === 'pedido'), casos = filas.filter(r => r.tipo !== 'pedido');\nconst t = LANG === 'es'\n  ? { p: 'PEDIDOS POR CONFIRMAR', c: 'CASOS QUE ALBA TE PASÓ', n: '(ninguno)', r: 'Recoge' }\n  : { p: 'ORDERS TO CONFIRM', c: 'CASES ALBA HANDED YOU', n: '(none)', r: 'Pickup' };\nconst linea = (r) => `- ${r.telefono}: ${r.detalle}` + (r.fecha_entrega ? ` · ${t.r}: ${r.fecha_entrega}` : '');\nconst texto = [t.p, ...(pedidos.length ? pedidos.map(linea) : [t.n]), '', t.c, ...(casos.length ? casos.map(linea) : [t.n])].join('\\n');\nreturn [{ json: { hay: filas.length > 0, pedidos: pedidos.length, casos: casos.length, texto,\n  hasta_id: filas.length ? Math.max(...filas.map(r => r.id)) : 0 } }];"
      },
      "name": "Build summary",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        660,
        560
      ]
    },
    {
      "parameters": {
        "conditions": {
          "combinator": "and",
          "conditions": [
            {
              "leftValue": "={{ $json.hay }}",
              "rightValue": "",
              "operator": {
                "type": "boolean",
                "operation": "true",
                "singleValue": true
              }
            }
          ]
        }
      },
      "name": "Anything?",
      "type": "n8n-nodes-base.if",
      "typeVersion": 2,
      "position": [
        880,
        560
      ]
    },
    {
      "parameters": {
        "sendTo": "rosa@example.com",
        "subject": "=Last night: {{ $json.pedidos }} order(s) to confirm and {{ $json.casos }} case(s) for you",
        "emailType": "text",
        "message": "={{ $json.texto }}"
      },
      "name": "Summary to Rosa",
      "type": "n8n-nodes-base.gmail",
      "typeVersion": 2,
      "position": [
        1100,
        480
      ]
    },
    {
      "parameters": {
        "resource": "row",
        "operation": "update",
        "dataTableId": {
          "__rl": true,
          "mode": "name",
          "value": "turno_noche"
        },
        "matchType": "allConditions",
        "filters": {
          "conditions": [
            {
              "keyName": "estado",
              "condition": "eq",
              "keyValue": "nuevo"
            },
            {
              "keyName": "id",
              "condition": "lte",
              "keyValue": "={{ $('Build summary').first().json.hasta_id }}"
            }
          ]
        },
        "columns": {
          "mappingMode": "defineBelow",
          "value": {
            "estado": "enviado"
          },
          "schema": [
            {
              "id": "estado",
              "displayName": "estado",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            }
          ]
        }
      },
      "name": "Mark as sent",
      "type": "n8n-nodes-base.dataTable",
      "typeVersion": 1.1,
      "position": [
        1320,
        480
      ]
    },
    {
      "parameters": {
        "content": "## After-hours SMS (ep04b, English)\n1. Assign credentials: Twilio, OpenAI and Gmail.\n2. Put your Twilio number in **Send reply** and **Send base reply**, and change `rosa@example.com` in **Email Rosa** and **Summary to Rosa**.\n3. Your hours go in the **Hours** node (and in template 2).\n4. Paste the production URL of **SMS received** in your Twilio number's messaging webhook.\nSample data is fictional. Blackcircuit Labs.",
        "height": 280,
        "width": 400
      },
      "name": "Read me",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        -520,
        -360
      ]
    }
  ],
  "connections": {
    "SMS received": {
      "main": [
        [
          {
            "node": "Answer Twilio (empty)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Answer Twilio (empty)": {
      "main": [
        [
          {
            "node": "No duplicates",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "No duplicates": {
      "main": [
        [
          {
            "node": "Message data",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Message data": {
      "main": [
        [
          {
            "node": "Opt-out word?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Opt-out word?": {
      "main": [
        [
          {
            "node": "Twilio handles it",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Prepare table",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Prepare table": {
      "main": [
        [
          {
            "node": "Back to the message",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Back to the message": {
      "main": [
        [
          {
            "node": "Hours",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Hours": {
      "main": [
        [
          {
            "node": "Closed?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Closed?": {
      "main": [
        [
          {
            "node": "Alert word?",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Open: Rosa replies",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Alert word?": {
      "main": [
        [
          {
            "node": "Save for Rosa",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Guardrail: hand to Rosa?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Guardrail: hand to Rosa?": {
      "main": [
        [
          {
            "node": "Save for Rosa",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Alba",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Alba",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Save for Rosa": {
      "main": [
        [
          {
            "node": "Email Rosa",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Email Rosa": {
      "main": [
        [
          {
            "node": "Send base reply",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Alba": {
      "main": [
        [
          {
            "node": "Send reply",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Model (classifier)": {
      "ai_languageModel": [
        [
          {
            "node": "Guardrail: hand to Rosa?",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Model (Alba)": {
      "ai_languageModel": [
        [
          {
            "node": "Alba",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Memory per customer": {
      "ai_memory": [
        [
          {
            "node": "Alba",
            "type": "ai_memory",
            "index": 0
          }
        ]
      ]
    },
    "save_order": {
      "ai_tool": [
        [
          {
            "node": "Alba",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "7:45 AM, Monday to Saturday": {
      "main": [
        [
          {
            "node": "Prepare table (summary)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Prepare table (summary)": {
      "main": [
        [
          {
            "node": "Last night's rows",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Last night's rows": {
      "main": [
        [
          {
            "node": "Build summary",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Build summary": {
      "main": [
        [
          {
            "node": "Anything?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Anything?": {
      "main": [
        [
          {
            "node": "Summary to Rosa",
            "type": "main",
            "index": 0
          }
        ],
        []
      ]
    },
    "Summary to Rosa": {
      "main": [
        [
          {
            "node": "Mark as sent",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "settings": {
    "executionOrder": "v1",
    "timezone": "America/Chicago"
  },
  "pinData": {},
  "meta": {
    "templateCredsSetupCompleted": false,
    "generatedBy": "tools/material_flujo_nocturno.py"
  }
}
