Handle non-booking requests: take a message, log a callback note

A caller asking if their already-purchased frames were ready got railroaded
through the booking script and hung up. AVA had no path for requests it can't do
on the phone.

- Prompt: classify intent first — question (answer it), can't-do request (take
  name + a one-line note, confirm callback number, promise a staff callback;
  never force booking questions), or booking (the ordered steps).
- extract.py: request_type = appointment | callback | none. Callback gate needs
  a name or a request note. Records kind.
- practice.py / odoo_client.py: callbacks write a "📞 Callback request" lead
  (name, callback number, what they need) instead of an appointment card.

Verified the classifier: frames-status -> callback, booking -> appointment,
pure question -> none.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
tocmo0nlord
2026-06-29 14:46:23 +00:00
parent 2f7e2629fe
commit 97e109ed89
5 changed files with 90 additions and 37 deletions

View File

@@ -101,19 +101,25 @@ def persist_appointment(record: dict) -> str:
JSONL fallback so a request is never lost. Returns where it landed. Used by both
the post-call extraction and the (optional) in-call tool."""
record.setdefault("ts", datetime.now(timezone.utc).isoformat())
kind = record.get("kind", "appointment")
if os.environ.get("ODOO_USER") and os.environ.get("ODOO_API_KEY"):
try:
from odoo_client import create_appointment_request
if kind == "callback":
reason = record.get("reason") or "callback request"
else:
reason = f"[{record.get('location') or 'location TBD'}] {record.get('reason') or ''}".strip()
model, rec_id = create_appointment_request(
patient_name=record.get("patient_name"),
callback_number=record.get("callback_number"),
reason=f"[{record.get('location') or 'location TBD'}] {record.get('reason') or ''}".strip(),
reason=reason,
preferred_time=record.get("preferred_time"),
insurance=record.get("insurance"),
call_sid=record.get("call_sid"),
kind=kind,
)
logger.info(f"Appointment -> Odoo {model} id={rec_id}: {record.get('patient_name')}")
logger.info(f"{kind.capitalize()} -> Odoo {model} id={rec_id}: {record.get('patient_name')}")
return f"odoo:{model}:{rec_id}"
except Exception as e:
logger.warning(f"Odoo write failed ({e!r}); falling back to local log")
@@ -121,7 +127,7 @@ def persist_appointment(record: dict) -> str:
with open(REQUESTS_LOG, "a") as fh:
fh.write(json.dumps(record) + "\n")
logger.info(f"Appointment -> JSONL: {record.get('patient_name')}")
logger.info(f"{kind.capitalize()} -> JSONL: {record.get('patient_name')}")
return "jsonl"