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

# Chat Interface

> Chat with your agents, see streaming responses, and explore source citations.

The chat interface is where you and your users interact with agents. It supports real-time streaming, file attachments, knowledge base citations, and full conversation history.

## Starting a Conversation

To chat with an agent:

1. Navigate to your agent's page.
2. Click **Chat** to open the chat interface.
3. If the agent has a welcome message configured, it appears automatically as the first message.
4. Type your message and press Enter or click Send.

Each conversation is a separate session with its own context and memory. The agent remembers everything said within a conversation but starts fresh in a new one.

## Streaming Responses

When streaming is enabled, you see the agent's response appear word-by-word in real time rather than waiting for the full response to generate. This makes conversations feel more natural and responsive.

Streaming is active when:

* The agent has `streaming_enabled` turned on (default: yes)
* The client supports streaming (the web interface always does)

<Info>
  If your agent is deployed through channels like Telegram or WhatsApp, responses are delivered in full once generation completes, since those platforms do not support real-time streaming.
</Info>

## Citations and Sources

When your agent has linked knowledge bases, responses may include numbered citations like `[1]`, `[2]`, `[3]`. These indicate that the agent used specific content from your knowledge base to generate its answer.

### Citation Tooltips

Hover over any citation number in a response to see a tooltip with:

* **Knowledge base name** — Which KB the source came from
* **Source document** — The filename or URL of the original document
* **Relevance score** — How closely the content matched the query (0-100%)
* **Chunk text** — A preview of the actual content that was retrieved

### Sources Panel

Click the **Sources** button (or a citation) to open the Sources Panel — a slide-in sidebar that shows all sources used in the current response:

* Sources are **grouped by knowledge base**
* Each source card is expandable to show the full chunk text
* Relevance scores are displayed as color-coded bars:
  * Green (high relevance) — Strong match
  * Yellow (medium) — Moderate match
  * Red (low) — Weaker match but still above threshold
* Platform badges show the original source type (PDF, URL, Instagram, etc.)
* **View Original** links take you to the source document or URL when available

<Tip>
  The sources panel is the best way to verify your agent's responses. If a citation does not support the claim, you may need to adjust your knowledge base content or system prompt.
</Tip>

## Conversation Memory

Each conversation maintains context through LangChain conversation memory:

* The agent remembers all previous messages in the current conversation
* Context accumulates over the conversation, allowing follow-up questions
* Knowledge base search uses the **last 5 messages** as context for better retrieval

Memory is conversation-scoped — starting a new conversation resets the context.

## Dynamic Variables in Chat

If your agent uses dynamic variables (`{{variable_name}}`), you can pass them through:

* **Query parameters** when linking to the chat (using `var_` prefix)
* **Widget configuration** when embedding the agent
* **API calls** when using the chat endpoint programmatically

Variables can also be updated mid-conversation by including a `variables` field in subsequent messages. This enables dynamic experiences where context changes as the conversation progresses (e.g., updating the current page the user is on).

## Public Agent Pages

Published agents are accessible at `/a/your-agent-slug`. These pages:

* Require no authentication
* Show the agent's name and description
* Provide a full chat interface
* Support all features including citations, streaming, and attachments

## Chat via API

You can also interact with agents programmatically:

```
POST /api/bots/:id/chat
{
  "message": "What is your return policy?",
  "conversationId": "existing-conversation-id",
  "stream": true,
  "variables": {
    "user_name": "John"
  }
}
```

The API returns the same response structure as the web interface, including the message text and any sources/citations.
