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;
}): void

Opens 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 (default true) — when no explicit query is 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 to false to open the panel only.

Parameters

typestringdefault: search

What to open. Use OverlayTarget.Search ('search') to open the search overlay, or OverlayTarget.Widget ('widget') to open the sticky widget panel. See OverlayTarget.

options.querystring

A 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: true

When 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"): void

Closes the search overlay or the sticky widget. If the specified panel is already closed, the call is a no-op.

Parameters

typestringdefault: search

What 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);

You can listen for the search:open, search:close, widget:open, and widget:close events to react when the overlay state changes, whether triggered by your code or by the user. See on() and off() for details.

© 2026 Inline AI