JavaScript API
Commands, routes, events, and typed SDK methods available through the RogerIQ widget.
JavaScript API
The widget exposes a command API through window.RogerIQ.
jsRogerIQ("open");RogerIQ("navigate", "/ask");RogerIQ("search", "refund policy");
Commands
| Command | Description |
|---|---|
init | Initialize the widget. |
destroy | Remove the widget from the page. |
open, close, toggle | Control visibility. |
navigate | Move to a widget route. |
search | Run a docs search. |
article | Open an article by ID. |
suggest | Show suggested links or questions. |
ask-question | Submit an AI answer question. |
identify | Attach customer identity. |
prefill | Prefill message form fields. |
reset | Reset local widget state. |
logout | Clear identity and optionally active chat/messages. |
config | Apply runtime config overrides. |
consent | Update analytics consent. |
session-data | Store string key-value session context. |
event | Send a widget event. |
info | Read current widget state. |
show-message | Show a proactive message by ID. |
track | Track a custom analytics event. |
on, once, off | Manage event listeners. |
Routes
txt//ask/ask/message/ask/chat/answers/ai-answers/previous-messages/profile/docs/search?query=refund/docs/article/kba_123
Examples
jsRogerIQ("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
tsimport { 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?");