chat - Algolia
Documentation Index
Fetch the complete documentation index at: /llms.txt
Use this file to discover all available pages before exploring further.
JavaScript
This widget is in beta and is subject to change in minor versions.
For more information, see Agent Studio.
Signature
chat({
container: string | HTMLElement,
// Required parameter, either one of
agentId?: string,
transport?: object,
// Optional parameters (agentId only)
feedback?: boolean,
requestOptions?: object,
// Optional parameters
getSearchPageURL?: function,
tools?: object,
context?: object | function,
initialMessages?: array,
initialUserMessage?: string,
resume?: boolean,
persistence?: boolean,
disableTriggerValidation?: boolean,
onFinish?: function,
requiresSearch?: boolean,
showReasoning?: boolean,
templates?: object,
cssClasses?: object,
});
Import
Package manager
CDN
import { chat } from 'instantsearch.js/es/widgets';
// "chat" is not available from the UMD build.
// Please use InstantSearch.js with a packaging system.
About this widget
Use the chat widget to display a chat interface that interacts with a generative AI assistant. See also: Agent Studio
The chat widget renders the chat panel but doesn’t provide a way to open it. Add one entry point to the same InstantSearch instance: the chatTrigger widget, AI mode on a searchBox or autocomplete, or an inline layout. Otherwise, the widget logs a development warning. To silence it, set disableTriggerValidation to true.
Examples
JavaScript
chat({
container: '#chat',
agentId: '8f7c4a2d-3b1e-4d5f-9a6c-e2b1f5d0c3e9',
});
chatTrigger({
container: '#chat-trigger',
});
Options
container
string | HTMLElement
Required
The CSS Selector or HTMLElement to insert the widget into.
chat({
container: '#chat',
});
chat({
container: document.querySelector('#chat'),
});
agentId
string
The unique identifier of the agent to connect to. You can find the agentId in the Agent Studio dashboard.
chat({
// ...
agentId: '8f7c4a2d-3b1e-4d5f-9a6c-e2b1f5d0c3e9',
});
feedback
boolean
Whether to enable feedback (thumbs up/down) on assistant messages. Only available when using agentId.
chat({
// ...
agentId: '8f7c4a2d-3b1e-4d5f-9a6c-e2b1f5d0c3e9',
feedback: true,
});
transport
object
A custom transport object to handle the communication between the chat widget and the agent. The API endpoint must be compatible with Vercel AI SDK 5.
chat({
// ...
transport: {
api: 'https://chatapi.example.com/api/v1/chat',
headers: {
'X-Session-Id': '8f7c4a2d-3b1e-4d5f-9a6c-e2b1f5d0c3e9',
'X-Api-Version': '2025-01-01',
},
},
});
... (truncated for brevity)