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. Returnsvoid.
close()
Closes the chat widget if it is currently open. Returnsvoid.
toggle()
Toggles the widget between open and closed. Returnsvoid.
isOpen()
Returnsboolean — whether the widget is currently open. Does not change the UI.
isReady()
Returnsboolean — 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 aPromise.
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 aPromise 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. Returnsvoid. If the iframe is not yet ready, the metadata is queued and sent automatically once the iframe initializes. Multiple calls merge.
Merging and removing keys
- Existing keys can be overwritten with new values.
- Keys are removed by passing
nullas the value. - Multiple calls are merged — new keys are added, existing keys are updated.
sendCustomPdpQuestion(questionSetId)
Opens the chat and triggers the custom product-question flow for a given question set. Returns aPromise. This method backs the “ask something else” button rendered by the product-questions widget.
trackPdpQuestionsView(element, questionSetId)
Reports a qualified view (impression) for self-rendered product questions. Returnsvoid. 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
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.