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

# Introduction

> Control the embedded homie chat widget from your website using the global browser API window.homieBot.

The Client API is a browser-side JavaScript interface exposed by the homie embed script. Once the script loads, a global `window.homieBot` object becomes available so you can open or close the widget, check its state, send messages programmatically, attach metadata, and read the chat history — all from your own page code.

> [!NOTE]
>
> This page documents the client-side browser API exposed by the embed script. For server-side REST endpoints, see the
> [REST API](https://docs.yourhomie.ai/en/api-reference/backend/overview.md).

## Install the embed script

Add the embed script to your page. Styling and behavior are managed from the homie platform and pulled in automatically by the embed.

```html theme={null}
<script
  src="https://cdn.yourhomie.ai/embed.min.js"
  chatbotId="YOUR-CHATBOT-ID"
  defer
></script>
```

For platform-specific install steps, see the [Installation overview](https://docs.yourhomie.ai/en/user-guide/installation/overview.md).

## Requirements

1. The script must be embedded on your page.
2. `chatbotId` must be set (on the script tag or via `window.homieBotConfig`).

See [Configuration](https://docs.yourhomie.ai/en/api-reference/client/configuration.md) for all script attributes and global config objects.

## When the API is available

The `window.homieBot` object only exists **after** the embed has initialized. Do not assume it is present at page load.

> [!WARNING]
>
> Reading `window.homieBot` immediately on page load may return `undefined`. Listen for the `homiebot:api-ready` event,
> or use the `waitForHomie()` polling fallback shown in the [examples](https://docs.yourhomie.ai/en/api-reference/client/examples.md).

The embed dispatches browser events as it reaches each lifecycle stage:

| Event | When |
| - | - |
| `homiebot:api-ready` | `window.homieBot` is available |
| `homiebot:assistant-ready` | Chat iframe is ready for `sendMessage` / `getHistory` |
| `homiebot:opened` | Chat widget was opened |
| `homiebot:closed` | Chat widget was closed |
| `homiebot:chat-started` | A new conversation was created |
| `homiebot:message-sent` | A user message was sent |
| `homiebot:message-received` | A complete assistant response was received |
| `homiebot:chat-reset` | An existing conversation was cleared |
| `homiebot:product-clicked` | A recommended product was selected |
| `homiebot:feedback-submitted` | Like or dislike feedback was submitted |

Every event carries `chatbotId` and `occurredAt` in `event.detail`, plus context-specific fields. See
[Events](https://docs.yourhomie.ai/en/api-reference/client/events.md) for full details.

## Methods at a glance

| Method | Purpose |
| - | - |
| `open()` | Open the chat |
| `close()` | Close the chat |
| `resetChat()` | Clear the current conversation and locally stored history |
| `toggle()` | Toggle open/closed |
| `isOpen()` | Read whether the widget is open |
| `isReady()` | Read whether the iframe is ready for messages |
| `sendMessage(input, options?)` | Inject a message into the chat |
| `getHistory()` | Read the current chat history |
| `updateMessageMetadata(metadata)` | Attach metadata to the next user message |
| `sendCustomPdpQuestion(questionSetId)` | Open the custom product-question flow |
| `initializePdpQuestions()` | Render the product questions again after a client-side page change |
| `trackPdpQuestionsView(element, questionSetId)` | Report a view for self-rendered product questions |

See [Methods](https://docs.yourhomie.ai/en/api-reference/client/methods.md) for the full reference.

## Explore the Client API

> [card] [Configuration](https://docs.yourhomie.ai/en/api-reference/client/configuration.md)
>
> Script attributes, global config objects, language and Shopify market resolution.

> [card] [Methods](https://docs.yourhomie.ai/en/api-reference/client/methods.md)
>
> Full reference for every method on `window.homieBot`.

> [card] [Events](https://docs.yourhomie.ai/en/api-reference/client/events.md)
>
> Browser events dispatched by the embed for lifecycle and interaction.

> [card] [Examples](https://docs.yourhomie.ai/en/api-reference/client/examples.md)
>
> Practical recipes for opening, messaging, and tracking.

> [card] [Troubleshooting](https://docs.yourhomie.ai/en/api-reference/client/troubleshooting.md)
>
> Fixes for the most common integration issues.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.