> For the complete documentation index, see [llms.txt](https://docs.uibakery.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.uibakery.io/reference/working-with-components/chat.md).

# Chat

## Overview

The Chat component is an interface element designed for communicating within an application. It provides users with the ability to exchange messages with chatbots in real time.

<figure><img src="https://837703843-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FUX6zPRMFFK0yrTghj7cY%2Fuploads%2FRMMW8s5BdMUK528AsOOf%2FCleanShot%202025-07-22%20at%2013.27.16%402x-min.png?alt=media&amp;token=3e484346-e97f-48e2-9df1-97fe4949c410" alt=""><figcaption></figcaption></figure>

### Properties

<table><thead><tr><th width="166.23828125">Name</th><th width="165.078125">Type</th><th>Description</th></tr></thead><tbody><tr><td><code>name</code></td><td><code>string</code></td><td>Component name</td></tr><tr><td><code>messages</code></td><td><code>chatMessage[]</code></td><td>Full array of chat messages with metadata</td></tr><tr><td><code>lastUserMessage</code></td><td><code>string</code></td><td>Last message entered by the user</td></tr><tr><td><code>briefMessages</code></td><td><code>briefMessage[]</code></td><td>Simplified message list with only <code>role</code> and <code>content</code> .<br><em><mark style="background-color:blue;">Useful for integrating with ChatGPT and similar APIs.</mark></em></td></tr></tbody></table>

### Methods

<table><thead><tr><th width="174.578125">Name</th><th width="258.578125">Parameters</th><th width="103.3359375">Returns</th><th>Description</th></tr></thead><tbody><tr><td><code>setMessages</code></td><td><code>value: { role: string; content: string; created_at: Date; id?: string; avatar?: string }[]</code></td><td><code>void</code></td><td>Set messages</td></tr><tr><td><code>addMessage</code></td><td><code>value: { role: string; content: string; id?: string; avatar?: string }</code></td><td><code>void</code></td><td>Add a new message to the messages array</td></tr><tr><td><code>upsertLastMessage</code></td><td><code>value: { role: string; content: string; id?: string; avatar?: string }</code></td><td><code>void</code></td><td>Insert or append to last message</td></tr><tr><td><code>updateLastMessage</code></td><td><code>value: { role: string; content: string; id?: string; avatar?: string }</code></td><td><code>void</code></td><td>Insert or update last message</td></tr><tr><td><code>startReceiving</code></td><td>–</td><td><code>void</code></td><td>Start receiving messages</td></tr><tr><td><code>stopReceiving</code></td><td>–</td><td><code>void</code></td><td>Stop receiving messages</td></tr></tbody></table>

### Triggers

<table><thead><tr><th width="191.2890625">Name</th><th>Description</th></tr></thead><tbody><tr><td><strong>On Init</strong></td><td>Triggered when the component is initialized</td></tr><tr><td><strong>On Message Sent</strong></td><td>Triggered when the user sends a message</td></tr><tr><td><strong>On Stop Receiving</strong></td><td>Triggered when message receiving is stopped</td></tr></tbody></table>


---

# 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 by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.uibakery.io/reference/working-with-components/chat.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
