> ## Documentation Index
> Fetch the complete documentation index at: https://docs.newlead.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Agent skills

> What the agent can do during a conversation, where the data it sends comes from, and how your system receives it.

A skill is an action the agent can take in the middle of a conversation: record a qualification answer, book an appointment, notify the team, stop contact or call your own system. On each reply, the AI decides whether to use one, from the conversation and the skill's description, and writes the values it sends.

Skills are set up in the dashboard, in the agent's settings. The API reads agents but does not configure them, so it never turns a skill on or changes it. What it gives you is what skills produce: [webhook events](https://docs.newlead.ai/webhook-events.md), the lead's `variables` and `qualification`, and a trace of each run in the conversation.

> [!NOTE]
>
> To copy leads into your CRM, use [webhooks](https://docs.newlead.ai/webhooks.md), as in [Sync leads to a CRM](https://docs.newlead.ai/sync-leads-to-crm.md): they are [signed](https://docs.newlead.ai/webhook-signatures.md) and retried. Use an [advanced skill](#advanced-skills) only when the agent needs an answer from your system before it replies, such as stock, a price or a free slot. Its requests are not signed or retried, and the AI writes the values in them.

## The skills

| Skill | Where it is set up | What the agent does | What you receive |
| - | - | - | - |
| [Qualification](#qualification) | **Qualification questions** | Records each answer the lead gives to the agent's questions | `lead.qualified`, and `qualification` in every lead event |
| [Google Calendar](#google-calendar) | **Google Calendar** | Checks free slots, and books, moves or cancels appointments | `lead.appointment_booked` when it books |
| [Team notifications](#team-notifications) | **Team notifications** | Tells the team a lead needs a person: always in the dashboard, and by email or WhatsApp if set up | `lead.handoff` |
| [Do not contact](#do-not-contact) | **Finish conversation** | Stops all contact when the lead asks for it | `lead.do_not_contact_changed` |
| [Close the conversation](#close-the-conversation) | **Finish conversation** | Sends the **Farewell message** when someone on the team closes the conversation | Nothing: the lead's `status` becomes `closed` |
| [Properties](#properties) | **Properties** | Finds the property the lead is talking about in your listings | `property_reference`, `property_url` and `property_address` in `variables` |
| Web search | Nothing to set up | Searches the web to answer a question | Nothing |
| [Advanced skills](#advanced-skills) | **Advanced skills** | Calls a URL of yours and uses the response | A `POST` to your URL |

Team notifications and web search are on in every text agent, and Do not contact is on until the customer turns it off in **Finish conversation**. The rest are switched on per agent.

### In calls

A voice agent has its own skills: it can end the call, check and book in Google Calendar, notify the team, search properties, mark the caller as Do not contact and call advanced skills. It does not qualify leads or close conversations, and it does not move or cancel appointments. Lead events fire for a call only when the call's lead belongs to a text agent, as in a web call from a text agent's widget: they go to that agent's endpoints. A lead of a voice agent with no text agent has `text_agent_id: null`.

### In test conversations

In **Test your agent**, notices to the team and calendar writes are simulated, and no webhook event fires. Advanced skills are the exception: they call your URL for real, from **Test your agent** and from the agent's demo link, and nothing in the request marks it as a test.

## How the agent gets the data

The AI writes every value a skill sends. On each reply it has:

| Source | What it holds |
| - | - |
| The conversation | The last 15 messages and a summary of earlier ones |
| The lead | Its ID, the agent's ID, name, phone, channel and status |
| The person | A summary, or the last messages, of up to three other conversations of the same person, and their recent calls |
| [Variables](#variables) | Form fields, values you send through the API, custom fields and the property found |
| [Qualification](#qualification-answers) | The answers recorded so far |
| The agent's instructions | What the customer wrote for the agent in the dashboard |

In a call, the voice agent has the caller's number, the lead's name, summary and variables, and the recent messages of the lead's chat.

### Variables

`variables` is the same object in [`GET /v1/leads/{lead_id}`](https://docs.newlead.ai/api-reference/leads/retrieve-a-lead) and in the [`lead` object](https://docs.newlead.ai/webhook-events#the-lead-object) of every event. Each value comes from one of these:

| Who writes it | When |
| - | - |
| The lead source: the fields of a Lead Ads form, or the data read from the email a lead arrives in | When the lead is created |
| You: `variables` in [`POST /v1/leads`](https://docs.newlead.ai/api-reference/leads/create-or-update-a-lead) and [`PATCH /v1/leads/{lead_id}`](https://docs.newlead.ai/api-reference/leads/update-a-lead), `lead_variables` with a template, `lead.variables` with a call | On your request |
| The AI, for each [custom field](#custom-fields) the agent declares | In a chat, about 5 minutes after the lead's last message. In a call, after it ends |
| [Properties](#properties) | When the agent identifies a single property |

A variable called `caller_name`, `lead_name`, `contact_name`, `name` or `nombre` sets the lead's `name` if it has none. `email` on the lead is the first valid address among the variables `email`, `correo`, `correo_electronico`, `e_mail` and `mail`.

### Custom fields

The customer declares, in the agent's **Custom fields**, the data the AI looks for in its conversations. [`GET /v1/text_agents/{text_agent_id}/lead_fields`](https://docs.newlead.ai/api-reference/text-agents/list-lead-fields) lists them:

```json theme={null}
{
  "object": "list",
  "data": [
    {
      "object": "lead_field",
      "id": "00000000-0000-4000-8000-000000000015",
      "key": "budget",
      "description": "The most the lead can spend, in euros",
      "default_value": null,
      "category": "data"
    }
  ],
  "has_more": false,
  "next_cursor": null
}
```

* `key` is the key in `variables`. `description` is what the AI looks for: a field without one is never filled by the AI. `category` is `data` for an attribute of the lead and `tag` for a label used to filter.
* In a chat on WhatsApp, Instagram or the web chat, the AI reads the messages written since its last pass, about 5 minutes after the lead's last message. It does so even while the AI is paused.
* In a call, it reads the whole transcript once the call ends. [`call.analyzed`](https://docs.newlead.ai/webhook-events#call-analyzed) carries what it found, with a `confidence` for each value.
* It keeps a value only when its confidence is 0.75 or more. A new value replaces the old one, and a field the lead does not mention again keeps its value. A correction the team makes by hand stays until the lead says something new.
* It does not run when the agent is switched off, the account is stopped or the wallet has no balance.
* It does not read the email that brought a lead in or a Lead Ads form: their data is stored as it came. Test leads are not read either.

> [!WARNING]
>
> No event fires when the AI fills a custom field in a chat. The value arrives with the next event that carries the lead, or read it with [`GET /v1/leads/{lead_id}`](https://docs.newlead.ai/api-reference/leads/retrieve-a-lead). A `lead.handoff` sent right after a message can come before the fields of that message.

### Qualification answers

[`GET /v1/text_agents/{text_agent_id}/qualification`](https://docs.newlead.ai/api-reference/text-agents/get-qualification-questions) returns the agent's questions in the order it asks them. Each answer lands in `qualification.answers`, not in `variables`, with the `question_id` of its question.

* The agent records an answer as soon as the lead gives one it is confident about, 0.75 or more. If the answer is vague, it asks again.
* The value must fit the question: `true` or `false`, a number, a date such as `2026-12-02`, the `value` of one of the choices, or text. Otherwise the answer is rejected and the agent asks again.
* A question can be answered in advance from the lead's phone or from one of its variables, such as a form field. The agent then does not ask it.
* `value` is `null` when the lead declined to answer.

## What each skill sends

The events below are described in full in [Webhook events](https://docs.newlead.ai/webhook-events.md). Here, for each skill: when the agent uses it, what it fills in and where each value comes from.

### Qualification

The agent asks the questions in **Qualification questions** and records each answer. Every lead event carries the result:

```json theme={null}
"qualification": {
  "status": "completed",
  "completed_at": "2026-11-13T09:12:40.000Z",
  "answers": [
    { "question_id": "q1", "question": "Is your mortgage approved?", "value": true, "value_label": null },
    { "question_id": "q2", "question": "What are you looking for?", "value": "buy", "value_label": "Buy" }
  ]
}
```

| Field | Where it comes from |
| - | - |
| `status` | `in_progress` from the first answer. `completed` when the required questions are answered, all of them or the minimum the customer set, and nothing disqualifies the lead. `disqualified` when an answer does. `skipped` when the team skips it |
| `question_id`, `question` | The question, as in `GET /v1/text_agents/{text_agent_id}/qualification` |
| `value` | The AI's reading of the lead's words, in the question's type |
| `value_label` | The label of the chosen option |

What fires:

* [`lead.qualified`](https://docs.newlead.ai/webhook-events#lead-qualified) when `status` becomes `completed`.
* [`lead.handoff`](https://docs.newlead.ai/webhook-events#lead-handoff) with `reason: qualified` at the same moment, unless the agent does not notify the team about qualified leads.
* `lead.handoff` with `reason: disqualified` when an answer disqualifies the lead, and with `qualification_declined` when the lead refuses a required question twice.

### Google Calendar

The agent offers free slots from the connected calendar, the lead picks one, and the agent books it. The calendar is checked again before booking, so a busy slot is never booked. The appointment goes to the Google Calendar of the connected account, to the team by email if they set it up, and to you in [`lead.appointment_booked`](https://docs.newlead.ai/webhook-events#lead-appointment_booked):

```json theme={null}
"appointment": {
  "event_id": "7k2f9q0d1s",
  "title": "Viewing with Ana Ferrer",
  "starts_at": "2026-11-15T10:00:00.000Z",
  "ends_at": "2026-11-15T10:30:00.000Z",
  "timezone": "Europe/Madrid",
  "location": "1 Main Street, Madrid",
  "meet_link": null
}
```

| Field | Where it comes from |
| - | - |
| `event_id` | The Google Calendar event |
| `title` | Written by the AI, usually with the lead's name and what the appointment is for |
| `starts_at` | The slot the lead picked |
| `ends_at` | The appointment length set in the agent, unless the AI gives an end |
| `timezone` | The agent's time zone |
| `location` | Written by the AI from the conversation or its instructions. `null` if it gives none |
| `meet_link` | A Google Meet link, when the agent adds one to every appointment |

The agent can also move or cancel the appointment later in the conversation. Neither fires an event.

### Team notifications

By default, the agent notifies the team when the lead asks for a person, is angry, distrusts it, needs information it does not have, or cancels or changes something. The customer can change those cases in **Team notifications**. The notice always reaches the dashboard, by email or WhatsApp if the team set them up, and reaches you in [`lead.handoff`](https://docs.newlead.ai/webhook-events#lead-handoff):

```json theme={null}
"handoff": {
  "notification_id": "00000000-0000-4000-8000-000000000008",
  "reason": "human_requested",
  "message": "The lead wants to talk to a person about financing.",
  "requires_human": true
}
```

| Field | Where it comes from |
| - | - |
| `reason` | The rule the agent picked. `other` if it picked none |
| `message` | The agent's summary of what the lead needs, in its own words, up to 500 characters. From the qualification, a text of its own |
| `requires_human` | Follows from `reason`, as listed in [`lead.handoff`](https://docs.newlead.ai/webhook-events#lead-handoff) |
| `notification_id` | The notice in the dashboard |

* A second notice for the same lead within the cooldown, 15 minutes by default, is not saved and fires nothing. Notices that ask for a person (`requires_human: true`) share one cooldown, and the informative ones (`qualified`, `disqualified`, `appointment`) share another. A notice over the daily limit, 5 per lead by default, fires nothing either.
* After the agent books, moves or cancels an appointment, it is told not to notify the team in the same reply: the calendar skill already notifies them.
* The property reference and link the agent writes in a notice go only to the team's email. When the agent found the property with [Properties](#properties), read it from `lead.variables.property_reference`.

### Do not contact

The agent uses it when the lead asks clearly to stop, for example «stop writing to me» or «unsubscribe». Saying they are not interested is not enough. Every live lead of the same person in the same subaccount changes, and each one fires [`lead.do_not_contact_changed`](https://docs.newlead.ai/webhook-events#lead-do_not_contact_changed):

```json theme={null}
{
  "do_not_contact": true,
  "do_not_contact_reason": "user_requested_stop",
  "origin": "ai"
}
```

`do_not_contact_reason` is the reason the agent gives, often a short code such as `user_requested_stop`. `origin` is `ai` in a chat and in a call. What changes for the lead is in [When a lead asks not to be contacted](https://docs.newlead.ai/messages-and-calls.md#when-a-lead-asks-not-to-be-contacted).

### Close the conversation

The agent does not close conversations on its own: a person does, from **Conversations** or **Funnels**. What **Finish conversation** sets is the **Farewell message**, under **Close the conversation once it is resolved**. When someone on the team closes a conversation, the agent sends that message to the lead.

Closing fires no webhook event. The lead keeps its `id`, messages and variables, and its `status` becomes `closed`. If the lead writes again on WhatsApp or Instagram, the conversation opens again and `status` goes back to `active`.

### Properties

When the lead mentions a property or describes what they want, the agent searches your listings: the ones on Idealista and the ones you send with [`PUT /v1/properties/{reference}`](https://docs.newlead.ai/api-reference/properties/create-or-replace-a-property). When exactly one property fits, it saves it in the lead's `variables`. `property_reference` is `null` if that listing has no code:

```json theme={null}
"variables": {
  "property_reference": "MAD-0042",
  "property_url": "https://www.example.com/properties/mad-0042",
  "property_address": "Calle Mayor 1, Madrid"
}
```

A later match replaces the three values. A search that finds several properties, or none, changes nothing, and neither do the suggestions the agent makes when the customer turned on **Suggest properties** in **Properties**.

## Advanced skills

An advanced skill connects the agent to your system. When the AI decides to use it, NewLead sends a `POST` to your URL with the values the AI wrote, waits for your response and gives it to the AI, which then replies to the lead.

### Set it up

In the dashboard, open the agent and go to **Advanced skills**, or **Skills** in a voice agent:

| Field | What it is |
| - | - |
| Name | The function name the AI calls: lowercase letters, digits and underscores, such as `register_visit_request` |
| Description | What the AI reads to decide when to call the skill: say what it does and when to use it. A text agent reads its first 1,024 characters |
| Webhook URL | Where NewLead sends the `POST` |
| Parameters | The values the AI must write, as a JSON Schema. The dashboard builds it as a form, or takes the JSON |

```json theme={null}
{
  "type": "object",
  "properties": {
    "lead_id": { "type": "string", "description": "The ID of this lead." },
    "property_reference": { "type": "string", "description": "The reference of the property the lead wants to visit." },
    "preferred_date": { "type": "string", "description": "The day the lead prefers, as YYYY-MM-DD." },
    "needs_mortgage": { "type": "boolean", "description": "Whether the lead says they need a mortgage." }
  },
  "required": ["lead_id", "property_reference"]
}
```

The description of each parameter is what the AI follows to fill it: say where the value comes from and its format.

### The request from a text agent

The body is the values the AI wrote, and nothing else:

```http theme={null}
POST /newlead/visit-request HTTP/1.1
Host: crm.example.com
Content-Type: application/json

{
  "lead_id": "00000000-0000-4000-8000-000000000003",
  "property_reference": "MAD-0042",
  "preferred_date": "2026-12-02",
  "needs_mortgage": true
}
```

The request does not say which lead or agent it is about. To get the lead, declare a parameter for it, as `lead_id` above: the agent knows the lead's ID, name and phone, and its [variables](#variables). The AI copies the value into the request, and NewLead does not check it.

### The request from a voice agent

A voice agent wraps the values in `args`, and adds the lead of the call, set by NewLead:

```json theme={null}
{
  "voice_agent_id": "00000000-0000-4000-8000-000000000002",
  "voice_skill_id": "00000000-0000-4000-8000-000000000013",
  "skill_name": "register_visit_request",
  "lead_id": "00000000-0000-4000-8000-000000000003",
  "args": {
    "property_reference": "MAD-0042",
    "preferred_date": "2026-12-02",
    "needs_mortgage": true
  }
}
```

`lead_id` is `null` when the call has no lead, for example when the number is hidden.

### Respond

| | Text agent | Voice agent |
| - | - | - |
| Time limit | 60 seconds | 10 seconds |
| What the AI reads | Your body, up to 8,000 characters | Your body: the JSON when `Content-Type` is `application/json`, the text otherwise |
| A response outside `2xx` or a redirect | A failure | A failure: up to 500 characters of your body reach the AI |
| No response in time | A failure: the agent asks the lead to try again | The agent tells the caller it will check and carries on. A late response is not used |

Respond with a `2xx` and a short JSON body. The AI replies to the lead from it, so name the fields clearly. A text agent cuts a longer body at 8,000 characters, even in the middle of the JSON.

A text agent also reads these `2xx` responses as a failure:

| Your body | How the agent takes it |
| - | - |
| Empty, `{}`, `[]` or `null` | Your system returned no data |
| An HTML page | A technical problem |
| JSON with `error`, or with `status` set to `error` or `failed` | An error: it may tell the lead what `error` or `message` says |
| JSON with `"found": false` | Nothing was found: it asks the lead to check the details |
| JSON with `"success": false` | A refusal: it follows what your `message` says, without mentioning the refusal to the lead |

```json theme={null}
{ "success": false, "message": "That property is already reserved. Offer the lead the similar ones in the same street." }
```

> [!WARNING]
>
> Keep internal details out of `error` and `message`: the agent may repeat them to the lead.

### Security

NewLead does not sign these requests and sends no secret, so anyone who knows the URL can call it.

* Use `https` and a URL that is hard to guess, with a long random token in the path or the query string. Check the token on every request.
* Treat every value as user input. A lead can try to steer what the agent sends.
* Check the IDs you receive. [`GET /v1/leads/{lead_id}`](https://docs.newlead.ai/api-reference/leads/retrieve-a-lead) with your key returns `404` for a lead outside your subaccount.
* The URL must resolve to a public address. A redirect is not followed and counts as a failure.

### Retries

NewLead does not retry a request that fails or times out. The AI is told, and it tells the lead.

Within one reply, the same call with the same values runs once. In a later reply, the agent can call your skill again with the same values, and the request carries no idempotency key. Make the operation safe to repeat, for example by keying it on the lead and the values.

### See each run

In a text conversation, each skill run, platform or advanced, adds a message to [`GET /v1/leads/{lead_id}/messages`](https://docs.newlead.ai/api-reference/messages/list-messages). Web search does not:

| Field | Value |
| - | - |
| `sender` | `skills` |
| `origin` | `system` |
| `direction` | `outbound` |
| `text` | The skill and its outcome, such as `[skills] register_visit_request executed` or `[skills] register_visit_request: error (timeout)` |

Read `text` as a log line: its wording can change. These messages are never sent to the lead.

## Follow it from outside

| To | Use |
| - | - |
| Know when the agent qualifies, books, notifies or stops contact | [`lead.qualified`](https://docs.newlead.ai/webhook-events#lead-qualified), [`lead.appointment_booked`](https://docs.newlead.ai/webhook-events#lead-appointment_booked), [`lead.handoff`](https://docs.newlead.ai/webhook-events#lead-handoff) and [`lead.do_not_contact_changed`](https://docs.newlead.ai/webhook-events#lead-do_not_contact_changed) |
| Know whether a conversation is closed | `status` in [`GET /v1/leads/{lead_id}`](https://docs.newlead.ai/api-reference/leads/retrieve-a-lead) |
| Read the custom fields and the qualification at any time | [`GET /v1/leads/{lead_id}`](https://docs.newlead.ai/api-reference/leads/retrieve-a-lead) |
| Know what the AI looks for | [`GET /v1/text_agents/{text_agent_id}/lead_fields`](https://docs.newlead.ai/api-reference/text-agents/list-lead-fields) and [`GET /v1/text_agents/{text_agent_id}/qualification`](https://docs.newlead.ai/api-reference/text-agents/get-qualification-questions) |
| Get what the AI found in a call | [`call.analyzed`](https://docs.newlead.ai/webhook-events#call-analyzed) |
| See which skills ran in a chat | [`GET /v1/leads/{lead_id}/messages`](https://docs.newlead.ai/api-reference/messages/list-messages), messages with `sender: skills` |

## Not available yet

* Turning skills on or setting them up through the API, or listing which ones an agent has.
* An event when the agent moves or cancels an appointment, or when it fills a custom field in a chat.
* Reading a lead's appointments through the API: they only travel in `lead.appointment_booked`.
* Signing the requests of advanced skills, or telling a test conversation apart in them.

## Related

> [card] [Webhook events](https://docs.newlead.ai/webhook-events.md)
>
> The full payload of each event a skill fires.

> [card] [Sync leads to a CRM](https://docs.newlead.ai/sync-leads-to-crm.md)
>
> Keep a CRM up to date from lead events.

> [card] [Send messages and place calls](https://docs.newlead.ai/messages-and-calls.md)
>
> Write to leads and read the conversation, skill runs included.

> [card] [Show your properties on your website](https://docs.newlead.ai/website-properties.md)
>
> The listings the Properties skill searches.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.