# v0.1.8 Telnyx Tool Reliability Fix

## Why this patch exists

If `lead_final`, `lead_capture_stage`, or `customer_phone` are marked Required in Telnyx, the assistant may skip the tool call when it cannot confidently populate every required field. When the tool is skipped, the dashboard receives no lead and no email/push notification is sent.

## Safe Telnyx setup

For `submit_lead`, keep these required only:

- `service_needed`
- `ai_summary`

Recommended but not required:

- `customer_name`
- `customer_phone`
- `telnyx_end_user_target`
- `call_control_id`
- `city`
- `service_address`
- `urgency`
- `property_type`
- `preferred_time`
- `lead_final`
- `lead_capture_stage`
- `transcript`
- `recommended_action`

For `escalate_urgent`, keep these required only:

- `service_needed`
- `ai_summary`

Set `lead_final=true` and `lead_capture_stage=final` when possible, but do not make them required in Telnyx. The app can still accept and debug draft/final calls.

## Debug endpoint

After a test call, open:

```text
https://pestdemo.recovermissedcall.com/api/ai-tools/recent-requests?api_key=YOUR_ADMIN_KEY
```

Interpretation:

- Empty `tool_requests`: Telnyx Assistant did not call the tool.
- `status=unauthorized`: `x-tool-secret` does not match `ADMIN_API_KEY`.
- `status=saved` and `lead_final=false`: lead saved as draft, notification may be suppressed.
- `status=saved` and `lead_final=true`: lead should appear and notify.
