> For the complete documentation index, see [llms.txt](https://docs.sprinthub.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.sprinthub.com/en/topics/artificial-intelligence/ai-agents/ai-agents-responding-to-the-message-that-opened-the-conversation.md).

# AI Agents - Responding to the Message that Opened the Conversation

How to make the AI agent start the conversation by replying to the lead's last message.

## Prerequisites

To allow the agent to start by responding to the lead's message, some conditions must be met. They are:

1. The option "**Greet the lead?**" must be enabled, causing the AI to send a message as soon as it is triggered;
2. The agent must have been initialized through a Chatbot, with the trigger "**The lead opens a new support ticket**";
3. The block "**AI Agent**" be the first block in the Chatbot.

<figure><img src="https://684109703-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F9FzUKkagBNy5uQ7AtGNa%2Fuploads%2FUIC0Awbz9LmbYTS6oIq9%2F1.png?alt=media&amp;token=862a6ef3-84f0-4477-a4de-597ad7d07d59" alt=""><figcaption><p><em>1 - Enabling "Greet the lead?".</em></p></figcaption></figure>

<figure><img src="https://684109703-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F9FzUKkagBNy5uQ7AtGNa%2Fuploads%2Ftotru476dLXlXiBHgda9%2F2.png?alt=media&amp;token=4e91ca4a-0767-4dd4-9fcb-43a1ae4ad009" alt=""><figcaption><p><em>2 - Configuring the trigger.</em></p></figcaption></figure>

<figure><img src="https://684109703-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F9FzUKkagBNy5uQ7AtGNa%2Fuploads%2Fxy5QIYhcpYKnp7oQtxFD%2F3.png?alt=media&amp;token=d9154c25-3264-4ac0-8ce6-2e3891acb88b" alt=""><figcaption><p><em>2 - Configuring the trigger.</em></p></figcaption></figure>

<figure><img src="https://684109703-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F9FzUKkagBNy5uQ7AtGNa%2Fuploads%2FzkOTSOmJk2uOHJzTzXNT%2F4.png?alt=media&amp;token=9990908c-b252-45af-9181-24a5836f96d8" alt=""><figcaption><p><em>3 - Adding the block in the Builder.</em></p></figcaption></figure>

## Testing the Agent

This trigger will activate the Chatbot and, consequently, the AI agent, as soon as the lead contacts you through the channel and account defined in the trigger, provided they do not have an active support ticket.

An important consideration about initializing the agent is that, with the option **"Use previous messages"** enabled, it will also consider messages sent in past support interactions, which provides greater accuracy in the responses.

<figure><img src="https://684109703-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F9FzUKkagBNy5uQ7AtGNa%2Fuploads%2F1xBZGryvlcB686rPSrBz%2Fimage.png?alt=media&amp;token=3864c681-1d41-4357-8b8b-4237a03fb1fb" alt=""><figcaption><p><em>Testing agent.</em></p></figcaption></figure>


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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, and the optional `goal` query parameter:

```
GET https://docs.sprinthub.com/en/topics/artificial-intelligence/ai-agents/ai-agents-responding-to-the-message-that-opened-the-conversation.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
