Skip to main content
The <Chat> component provides an AI-powered conversational search interface for interacting with your search results using natural language.

Import

import { Chat } from 'react-instantsearch';

Props

title
string
The title displayed in the chat header.
<Chat title="Ask about our products" />
tools
UserClientSideTools
Custom tools for the chat agent to use.
import { SearchIndexToolType } from 'react-instantsearch';

<Chat
  tools={{
    [SearchIndexToolType]: {
      // custom tool configuration
    },
  }}
/>
itemComponent
React.Component
Component to render individual items in search results.
<Chat
  itemComponent={({ item }) => (
    <div>
      <h4>{item.name}</h4>
      <p>{item.description}</p>
    </div>
  )}
/>
getSearchPageURL
function
Function to generate URLs for search result pages.
<Chat
  getSearchPageURL={(uiState) => `/search?q=${uiState.query}`}
/>
toggleButtonProps
object
Props to customize the toggle button.
headerProps
object
Props to customize the chat header.
messagesProps
object
Props to customize the messages area.
promptProps
object
Props to customize the prompt input area.
toggleButtonComponent
React.Component
Custom component for the toggle button.
headerComponent
React.Component
Custom component for the chat header.
promptComponent
React.Component
Custom component for the prompt input.
suggestionsComponent
React.Component
Custom component for displaying suggestions.
translations
object
Customize the text strings.
<Chat
  translations={{
    prompt: { placeholder: 'Ask me anything...' },
    header: { title: 'Search Assistant' },
  }}
/>
classNames
object
CSS classes to customize the component styling.

Example

import { InstantSearch, Chat } from 'react-instantsearch';
import { liteClient as algoliasearch } from 'algoliasearch/lite';

const searchClient = algoliasearch(
  'YourApplicationID',
  'YourSearchOnlyAPIKey'
);

function App() {
  return (
    <InstantSearch searchClient={searchClient} indexName="products">
      <Chat
        title="Product Assistant"
        itemComponent={({ item }) => (
          <div>
            <img src={item.image} alt={item.name} />
            <h4>{item.name}</h4>
            <p>${item.price}</p>
          </div>
        )}
      />
    </InstantSearch>
  );
}

Build docs developers (and LLMs) love