Documentation Index
Fetch the complete documentation index at: https://algolia.com/llms.txt
Use this file to discover all available pages before exploring further.
This widget is and is subject to change in minor versions.
- An “AI Mode” button on the search box that opens a chat panel loaded with the user’s query.
- The
chatwidget itself, with hidden context to share session metadata. - AI-generated prompt suggestions in the autocomplete drop-down menu.
- Streaming controls so you can stop or resume an in-flight response.
Prerequisites
- An Agent Studio agent ID.
- An
instantsearchinstance with an Algolia search client. instantsearch.jsinstalled at a version that ships AI Mode (for example, the release from PRalgolia/instantsearch#6982or later).
Mount the chat widget
Add the
chat widget on the same instantsearch instance as your search UI. The other widgets in this guide rely on it being present.JavaScript
Enable AI Mode on the search box
Set
aiMode on searchBox to render an AI Mode button next to the input. Clicking it opens the chat widget and forwards the current query.JavaScript
Show prompt suggestions in autocomplete (optional)
If you use Selecting a prompt suggestion opens the chat widget on the same index and sends the suggestion as the first message.
EXPERIMENTAL_autocomplete, surface AI-generated prompt suggestions alongside hits. See showPromptSuggestions for the full configuration surface.JavaScript
Pass session metadata with hidden context
Use the
context option to share metadata with the agent on every message. The widget serializes the value as JSON and adds it to the user message as a hidden text part. Users don’t see it in the chat UI, but the agent does.Handle the streaming lifecycle
Listen for response completion with Set
onFinish, and use the connectChat connector if you need a custom Stop button or to call resumeStream() manually. See Streaming and resumption on the chat widget reference for the full status surface.JavaScript
resume: true to reconnect to an in-flight assistant response after a page reload.End-to-end example
JavaScript