---
title: "Chat Widgets"
description: "Liquid HTML UIs rendered inside chat messages for interactive agent turns."
canonical_url: "https://docs.vettero.com/build/chat-widgets"
---
# Chat Widgets

> Liquid HTML UIs rendered inside chat messages for interactive agent turns.

**Chat Widgets** are interactive **Liquid HTML + CSS** UIs rendered **inside an agent chat message**. An agent shows one during a turn to present data in a richer layout; the end user can interact, and configured **events** turn clicks into a chat message back to the AI.

These are **not** [iframe widgets](https://docs.vettero.com/build/widgets) (dashboard and sidebar pages with `window.vt`).

## When to use

- Display data in a UI-friendly format instead of plain chat text
- Collect input from the user and send it as a message to the AI
- Offer clicks and picks in-chat so the user does not have to type a free-text reply

## Create a chat widget

Open **Build → Chat Widgets** for a workspace-wide widget, or open an agent’s builder and use the **Chat Widgets** panel for one scoped to that agent.

1. Click **Create Widget** (or **Build With AI** to draft it in [Studio](https://docs.vettero.com/build/studio)).
2. Enter a **Name** and optional **Description**.
3. Click **Create** — Vettero opens the chat widget detail page.

Workspace chat widgets appear under **Global** in the agent tools picker; agent-scoped ones appear under **Local**.

## Configure the chat widget

From the detail page, click **Edit**. Use the sticky **Live preview** with sample args from your schema.

<table>
<thead>
  <tr>
    <th>
      Section
    </th>
    
    <th>
      What you configure
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <strong>
        Name
      </strong>
      
       / <strong>
        Description
      </strong>
    </td>
    
    <td>
      Identity; the description becomes agent tool help text
    </td>
  </tr>
  
  <tr>
    <td>
      <strong>
        Input arguments (schema)
      </strong>
    </td>
    
    <td>
      JSON Schema for render-time <code>
        args
      </code>
      
       → <code>
        {{ args.* }}
      </code>
      
       in HTML
    </td>
  </tr>
  
  <tr>
    <td>
      <strong>
        Events
      </strong>
    </td>
    
    <td>
      Maps <code>
        emit("id", …)
      </code>
      
       to chat text the user and AI see
    </td>
  </tr>
  
  <tr>
    <td>
      <strong>
        HTML (Liquid)
      </strong>
    </td>
    
    <td>
      Markup fragment — no <code>
        <script>
      </code>
      
       tags. Prefer <code>
        vt-card
      </code>
      
      , <code>
        vt-btn
      </code>
      
      , and the other <code>
        vt-*
      </code>
      
       classes
    </td>
  </tr>
  
  <tr>
    <td>
      <strong>
        CSS
      </strong>
    </td>
    
    <td>
      Optional custom rules. Use <code>
        var(--vt-surface)
      </code>
      
      , <code>
        var(--vt-text)
      </code>
      
      , <code>
        var(--vt-primary)
      </code>
      
      , and the other theme variables
    </td>
  </tr>
</tbody>
</table>

### Define events

Click **Add event** for each interaction you want to send back into chat.

<table>
<thead>
  <tr>
    <th>
      Field
    </th>
    
    <th>
      What it does
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <strong>
        Event ID
      </strong>
    </td>
    
    <td>
      The string you pass to <code>
        emit("…")
      </code>
      
       in HTML
    </td>
  </tr>
  
  <tr>
    <td>
      <strong>
        Display Message
      </strong>
    </td>
    
    <td>
      What the user sees in the chat transcript
    </td>
  </tr>
  
  <tr>
    <td>
      <strong>
        AI Message (optional)
      </strong>
    </td>
    
    <td>
      What the model receives; defaults to the display message when empty
    </td>
  </tr>
</tbody>
</table>

Message fields support simple `{{ path }}` placeholders over the **emit payload** (for example `{{ orderId }}`), not full Liquid.

### Write HTML and CSS

Use Liquid against `args`, `state`, and `decision`. Interactivity uses allowlisted handlers only:

<table>
<thead>
  <tr>
    <th>
      Helper
    </th>
    
    <th>
      What it does
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <code>
        updateState({…})
      </code>
    </td>
    
    <td>
      Merge into local widget state
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        setState({ path, value })
      </code>
    </td>
    
    <td>
      Set a single state path
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        emit("eventId", {…})
      </code>
    </td>
    
    <td>
      Fire a configured event and post chat text
    </td>
  </tr>
</tbody>
</table>

Allowed DOM events: `@click`, `@input`, `@change`, `@submit`. HTML is sanitized — no scripts. Write the handler in single quotes, for example `@click='emit("confirm", {"orderId": args.orderId})'`. The object can use `args.*`, `state.*`, and `event.target.value`.

The chat UI injects the current theme (company primary color and dark mode) before your CSS. Prefer the built-in classes so the widget matches the rest of the app.

<table>
<thead>
  <tr>
    <th>
      Class
    </th>
    
    <th>
      What it is
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <code>
        vt-grid
      </code>
    </td>
    
    <td>
      Auto-fit card grid
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        vt-card
      </code>
    </td>
    
    <td>
      Bordered panel
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        vt-label
      </code>
      
       / <code>
        vt-value
      </code>
    </td>
    
    <td>
      Metric label and value
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        vt-muted
      </code>
    </td>
    
    <td>
      Secondary text
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        vt-btn
      </code>
      
       / <code>
        vt-btn-primary
      </code>
    </td>
    
    <td>
      Buttons
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        vt-input
      </code>
    </td>
    
    <td>
      Text input
    </td>
  </tr>
</tbody>
</table>

```html
<div class="vt-card">
  <div class="vt-label">Order</div>
  <div class="vt-value">{{ args.orderId }}</div>
  <button type="button" class="vt-btn-primary" @click='emit("confirm", {"orderId": args.orderId})'>
    Confirm
  </button>
</div>
```

For custom layout, use the theme variables. They follow dark mode without a separate palette:

```css
.note {
  background: var(--vt-surface-muted);
  color: var(--vt-text);
  border-radius: var(--vt-radius);
  padding: var(--vt-space);
}
```

## Attach to an agent

In the agent builder, open **Config → Tools → Manage Tools → Chat Widget**. Pick a chat widget.

When the agent calls the tool, the chat UI renders the HTML/CSS as an in-message widget. User events post a text message back into the conversation.

You can also type `#` in the agent **Task** and select the chat widget to mention and attach it.

When at least one chat widget is attached, a short catalog is available as `{{ ctx.prompts.chatWidget }}` in Task (same place-or-append pattern as `{{ ctx.prompts.rejectionPolicy }}` and `{{ ctx.prompts.skill }}`). If you omit that placeholder, the catalog is appended.

## Limits

- Name is required (cannot be empty).
- No `<script>` tags — only allowlisted event attributes and the three runtime helpers.
- CSS is isolated to the Shadow DOM.
- Only usable in **agent chat**.
- Delete moves the widget to [trash](https://docs.vettero.com/activity/trash) for the workspace retention period.

## Where chat widgets are used

<table>
<thead>
  <tr>
    <th>
      Place
    </th>
    
    <th>
      How
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <strong>
        <a href="https://docs.vettero.com/build/agents">
          Agents
        </a>
      </strong>
    </td>
    
    <td>
      Tools → <strong>
        Chat Widget
      </strong>
      
      , or <code>
        #
      </code>
      
       mention in the Task
    </td>
  </tr>
</tbody>
</table>


## Sitemap

See the full [sitemap](https://docs.vettero.com/sitemap.md) for all pages.
