# v0.1.4 Telnyx Tool Troubleshooting

Use this when the AI answers the phone and collects information, but no lead appears in the dashboard.

## 1. Confirm the app can save a lead

Open this in your browser, replacing `YOUR_ADMIN_KEY` with your real `.env` `ADMIN_API_KEY`:

```text
https://pestdemo.recovermissedcall.com/api/ai-tools/test-submit-lead?api_key=YOUR_ADMIN_KEY
```

Expected result: JSON with `ok: true` and a `lead` object. Then refresh the dashboard.

If this works, the app/database/dashboard are fine. The issue is Telnyx Assistant tool configuration.

## 2. Confirm the tool secret is accepted

Open:

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

Expected result: `ok: true`.

## 3. Confirm Telnyx Assistant tools

Inside the Telnyx AI Assistant, make sure these tools exist and are enabled.

### submit_lead

Method:

```text
POST
```

URL:

```text
https://pestdemo.recovermissedcall.com/api/ai-tools/submit-lead
```

Headers:

```text
Content-Type: application/json
x-tool-secret: YOUR_ADMIN_KEY
```

### escalate_urgent

Method:

```text
POST
```

URL:

```text
https://pestdemo.recovermissedcall.com/api/ai-tools/escalate-urgent
```

Headers:

```text
Content-Type: application/json
x-tool-secret: YOUR_ADMIN_KEY
```

## 4. Common mistakes

- The tool URL still says `{{APP_BASE_URL}}`.
- The header still says `{{ADMIN_API_KEY}}`.
- The header name is not exactly `x-tool-secret`.
- The tool was created but not attached/enabled for the assistant.
- The assistant prompt was pasted, but the tool schema was not added.
- The call used a different assistant than the one you configured.

## 5. What v0.1.4 added

- `GET /api/ai-tools/ping` to test the secret from a browser.
- `GET /api/ai-tools/test-submit-lead` to create a dashboard lead from a browser.
- Alias routes for `/submit_lead` and `/escalate_urgent` in case a Telnyx tool URL was copied with underscores.
- Better server logging when a Telnyx tool request is unauthorized.
