# A.I. Agents - Automatically Qualifying Leads with AI

{% hint style="info" %}
The automation presented in this tutorial assumes that the AI Agent follows a standard service flow, in which it collects information and records it in the corresponding lead fields during the first contact.
{% endhint %}

## Fields that will be considered

In this example, three criteria will be considered for lead qualification: **business segment**, **number of employees** and **level of urgency**.\
\
The classification will be done as follows:

* **High**: Relevant segment, more than 10 employees and immediate urgency.
* **Average**: Meets two of the criteria or shows potential, even with an average timeframe.
* **Low**: Is just researching, has few employees and does not demonstrate urgency.

<figure><img src="/files/12e0e206df5867b3b0b63dbe94a28b4f1874b2f3" alt=""><figcaption><p><em>Lead fields.</em></p></figcaption></figure>

## Configuring 360° SAC automation

According to the trigger, the lead qualification will be performed when the AI Agent moves the service to the stage **"\[AI - First Contact] Completion"**.

At that moment, two actions will be executed:

1. **Run task with Copilot**\
   This action will generate the lead classification and save the result in the token `{copilotdb=classificacao_lead}`, as defined in the automation key.

   > Note: In this case, the task return must contain **only one word**, exactly matching one of the predefined values in the field **"Lead Classification"**, which is of type **selector**.
2. **Update lead data**\
   Then, the second action will save the value returned by Copilot directly into the corresponding lead field, using the action **"Update lead data"**.

<figure><img src="/files/40a1d61680eff193db0f1ccab6f1f1fbffdd3155" alt=""><figcaption></figcaption></figure>

<figure><img src="/files/7ae7bf64296f977ba239da4cd800cf6d8b9c158f" alt=""><figcaption><p><em>Action 'Run task with Copilot'.</em></p></figcaption></figure>

<figure><img src="/files/b552fb379b5c31e667e68e91fd2a0912f1786392" alt=""><figcaption><p><em>Action 'Update lead data'.</em></p></figcaption></figure>

## Testing automation

To verify if the automation is working correctly, you can check the lead's history. There, you will be able to see whether the actions were executed as expected or if any error occurred during the process.

<figure><img src="/files/2b3bbf741efada38e8ade52cee51689af0cddbbf" alt=""><figcaption><p><em>Lead history.</em></p></figcaption></figure>

<figure><img src="/files/68d31f1d6707fdea7f1495dff754f6646be01558" alt=""><figcaption><p><em>Qualified lead.</em></p></figcaption></figure>


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.sprinthub.com/en/topics/artificial-intelligence/ai-agents/ai-agents-execute-automations/ai-agents-automatically-qualifying-leads-with-ai.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
