{
  "name": "capture_lead",
  "description": "Take a message and send it to the restaurant. This is your universal fallback — use it whenever you cannot do something yourself, whenever another tool fails, whenever a question is outside your knowledge, and whenever a caller needs to be called back. Capture what they said in their own words. Never end a call without either a booking, a message, a transfer, or a clear answer.",
  "speak_during_execution": false,
  "speak_after_execution": false,
  "parameters": {
    "type": "object",
    "properties": {
      "caller_name": { "type": "string", "description": "As they said it." },
      "caller_phone": {
        "type": "string",
        "description": "Read it back digit by digit before submitting. A message with a corrupted number is worthless."
      },
      "intent": {
        "type": "string",
        "enum": ["booking", "inquiry", "complaint", "takeaway_order", "large_party", "job_application", "supplier", "other"],
        "description": "complaint, booking, large_party and takeaway_order are delivered INSTANTLY. inquiry, job_application and supplier are batched daily. Choose honestly — marking a complaint as an inquiry delays it by a day."
      },
      "summary": {
        "type": "string",
        "description": "Two sentences, plain language, faithful to what the caller actually said. Do not soften a complaint. Do not tidy a takeaway order into dishes you recognise."
      },
      "urgent": {
        "type": "boolean",
        "default": false,
        "description": "True for illness, injury, allergic reaction, anything involving a lawyer, journalist or regulator, and any complaint you could not transfer. This puts it at the top of the owner's alert."
      },
      "vertical_fields": {
        "type": "object",
        "description": "Restaurant-specific detail where relevant.",
        "properties": {
          "requested_date": { "type": "string" },
          "requested_time": { "type": "string" },
          "party_size": { "type": "integer" },
          "occasion": { "type": "string" },
          "order_items": {
            "type": "string",
            "description": "Takeaway only. Verbatim as spoken. Do not correct dish names — staff can read an odd transcription, but a wrongly 'corrected' order arrives as the wrong food."
          },
          "pickup_or_delivery": { "type": "string", "enum": ["pickup", "delivery"] }
        }
      }
    },
    "required": ["caller_phone", "intent", "summary"]
  },
  "response_schema": {
    "type": "object",
    "properties": {
      "delivered": { "type": "boolean" },
      "error": {
        "type": "string",
        "description": "Present only on failure. Still tell the caller their message has been taken — the retry and alert path will get it through. Do not ask them to call back."
      }
    }
  },
  "_notes": {
    "payload": "Maps to the standard lead payload in API_CONTRACT.md §3. The n8n flow adds client_id, call_id, captured_at, channel and transcript_url — the assistant does not supply those.",
    "destinations": "Preference order per API_CONTRACT.md §3: client CRM webhook → Google Sheet via n8n → email (discouraged). Takeaway orders additionally go to the staff WhatsApp from knowledge pack §H.",
    "delivery_timing": "Instant for booking | complaint | large_party | takeaway_order; batched daily otherwise.",
    "reliability": "Retry ×3 with backoff. A dead webhook alerts the founder on WhatsApp — never fails silently. Tested at go-live by killing the endpoint (RELEASE_CHECKLIST.md §C).",
    "qa": "Exercised by TEST_PLAN.md cases 3, 5, 8, 10, 12, 18, 20."
  }
}
