JavaScript API

The widget exposes a command API through window.RogerIQ.

js
RogerIQ("open");RogerIQ("navigate", "/ask");RogerIQ("search", "refund policy");

Commands

CommandDescription
initInitialize the widget.
destroyRemove the widget from the page.
open, close, toggleControl visibility.
navigateMove to a widget route.
searchRun a docs search.
articleOpen an article by ID.
suggestShow suggested links or questions.
ask-questionSubmit an AI answer question.
identifyAttach customer identity.
prefillPrefill message form fields.
resetReset local widget state.
logoutClear identity and optionally active chat/messages.
configApply runtime config overrides.
consentUpdate analytics consent.
session-dataStore string key-value session context.
eventSend a widget event.
infoRead current widget state.
show-messageShow a proactive message by ID.
trackTrack a custom analytics event.
on, once, offManage event listeners.

Routes

txt
//ask/ask/message/ask/chat/answers/ai-answers/previous-messages/profile/docs/search?query=refund/docs/article/kba_123

Examples

js
RogerIQ("on", "chat-started", ({ chatId }) => { analytics.track("Support chat started", { chatId });});RogerIQ("prefill", { name: "Ada Lovelace", email: "ada@example.com", subject: "Billing question", text: "I need help with my invoice."});const info = RogerIQ("info");console.log(info.state.open, info.visitor.identified);

Typed SDK

ts
import { RogerIQ } from "@rogeriq/widget-sdk";const widget = RogerIQ.init({ projectId: "prj_..." });widget.on("identity-updated", (identity) => { console.log(identity.verified);});widget.askQuestion("How do refunds work?");
Ask a question... ⌘I