# v0.1.5 Phone Capture Fix

This patch fixes cases where Telnyx AI Assistant saves a lead but the callback phone is missing.

## What changed

- Accepts more phone field names from Telnyx tool calls:
  - `customer_phone`
  - `phone`
  - `phone_number`
  - `callback_number`
  - `callback_phone`
  - `best_callback_number`
  - `best_callback_phone`
  - `caller_phone`
  - `caller_number`
  - `caller_id`
  - `from_number`
  - `from`
  - `ani`
  - `contact_phone`
  - `mobile`
  - `mobile_phone`
- Extracts phone numbers from `ai_summary`, `summary`, `call_summary`, `transcript`, notes, or the raw tool payload if the phone was included in text instead of a structured field.
- Flattens nested Telnyx tool payloads if the arguments are sent under `arguments`, `args`, `parameters`, `params`, `data`, or `payload`.
- Stores the raw tool payload on the lead for easier diagnostics.
- Adds a callback-phone field on the lead detail page so admins/dispatchers can manually save a missing number.
- Updates the pest-control assistant prompt to explicitly require `customer_phone` before saving the lead.

## Telnyx tool setup reminder

In the Telnyx `submit_lead` tool, keep this Body Parameter:

```text
customer_phone
```

Description:

```text
Best callback phone number. Use caller ID if available, or the number the caller confirms. E.164 format preferred, for example +17345550123.
```

Make it required.

Also add `customer_phone` to the `escalate_urgent` tool.

## Existing leads

This patch fixes future tool calls. Existing leads that were already saved without a phone will not automatically get a number unless it appears in the saved transcript/summary. Open the lead detail page and use the new **Callback phone** field to add it manually.
