Skip to main content
All methods live on window.homieBot, which becomes available after the homiebot:api-ready event. Methods that send or read messages (sendMessage, getHistory, sendCustomPdpQuestion) require the iframe to be ready — they wait internally, but you can check readiness with isReady() or listen for homiebot:assistant-ready.
Always guard against window.homieBot being undefined at page load. See Examples for a wait-for-ready pattern.

open()

Opens the chat widget if it is currently closed. Returns void.

close()

Closes the chat widget if it is currently open. Returns void.

toggle()

Toggles the widget between open and closed. Returns void.

isOpen()

Returns boolean — whether the widget is currently open. Does not change the UI.

isReady()

Returns boolean — whether the chat iframe is fully loaded and ready to accept sendMessage and getHistory. Use this before sending messages from late-bound code.

sendMessage(input, options?)

Injects a message directly into the chat — ideal for product detail pages (PDPs) or context-driven prompts. Opens the chat first if it is closed. Returns a Promise.
input (required: text) options
The signature documented above is the supported public contract. The current embed source exposes a simplified sendMessage(input) form where input accepts text, questionSetId, questionId, type ('DEFAULT' | 'PDP_QUESTION'), and newChat, and no options argument. If you target the latest embed, prefer the text / newChat fields, which are stable across both.

getHistory()

Returns a Promise resolving to the current chat history payload from the iframe. Useful for custom tracking. The request times out after a few seconds if the iframe does not respond.

updateMessageMetadata(metadata)

Attaches metadata to the next user message as key-value pairs. Returns void. If the iframe is not yet ready, the metadata is queued and sent automatically once the iframe initializes. Multiple calls merge.
Limits and validation Merging and removing keys
  • Existing keys can be overwritten with new values.
  • Keys are removed by passing null as the value.
  • Multiple calls are merged — new keys are added, existing keys are updated.
Single-page applications (SPAs): metadata keys persist across navigation because they live in the global window context. When you navigate between pages, clear stale metadata manually by calling updateMessageMetadata() with null values to avoid unintended persistence.

sendCustomPdpQuestion(questionSetId)

Opens the chat and triggers the custom product-question flow for a given question set. Returns a Promise. This method backs the “ask something else” button rendered by the product-questions widget.
This method is exposed on window.homieBot but is primarily intended for the built-in product-questions widget. Use it only if you render your own custom product-question entry point.

trackPdpQuestionsView(element, questionSetId)

Reports a qualified view (impression) for self-rendered product questions. Returns void. Use this when your shop fetches the product questions from the REST API and renders them with its own markup — it applies the same viewability rules as the built-in rendering, so your views and click-through rates stay comparable in the platform’s analytics:
  • counts only when the element has been at least 50% visible in the viewport for 1 second
  • counts at most once per page visit (per product URL)
  • safe to call again on framework re-renders — a pending measurement is re-armed on the new element, a counted visit never fires twice
Call it once right after rendering your questions element:
Views are the denominator of the click-through rate. If you render questions yourself and never call this method, your product pages will show clicks but no views in the analytics.