open() & close()
Programmatically open or close the search overlay and sticky widget using open() and close(), with optional query prefill and catalog auto-answer for both targets.
The open() and close() methods let you control the search overlay and the sticky widget from your own JavaScript. Use them to wire up custom search buttons, trigger a search from a navigation event, or open the widget in response to user behavior, all without requiring the user to interact directly with Inline AI UI elements.
Both methods accept a type argument that maps to the OverlayTarget enum: OverlayTarget.Search for the search overlay and OverlayTarget.Widget for the sticky widget panel. The type defaults to 'search' if omitted.
open(type?, options?)
open(type?: "search" | "widget", options?: {
query?: string;
autoAnswer?: boolean;
}): voidOpens the search overlay or the sticky widget. The options object is shared across both targets:
query— for'search', submits this question immediately when the overlay opens. For'widget', reserved for future use.autoAnswer(defaulttrue) — when no explicitqueryis provided, picks the next pending catalog question (the FAB notification question first, then the first unviewed question from page config) and answers it automatically. For'search'the question is submitted into the overlay; for'widget'it is streamed in the panel, equivalent to the user tapping See Answer. Set tofalseto open the panel only.
Parameters
typestringdefault: searchWhat to open. Use OverlayTarget.Search ('search') to open the search overlay, or OverlayTarget.Widget ('widget') to open the sticky widget panel. See OverlayTarget.
options.querystringA question to submit immediately on open. Only applies when type is 'search'. When provided, the catalog auto-answer is skipped — this explicit question is submitted instead.
options.autoAnswerbooleandefault: trueWhen true (default) and no query is provided, picks the next pending catalog question and answers it automatically. Works for both 'search' and 'widget'. Set to false to open the panel without starting any stream.
close(type?)
close(type: "search" | "widget" = "search"): voidCloses the search overlay or the sticky widget. If the specified panel is already closed, the call is a no-op.
Parameters
typestringdefault: searchWhat to close. Use OverlayTarget.Search ('search') or OverlayTarget.Widget ('widget'). See OverlayTarget.
Examples
// Opens search and auto-submits the next pending catalog question (default behavior)
window.InlineAI.open(window.InlineAI.OverlayTarget.Search);