Skip to main content

DocSearchAskAi Configuration

The DocSearchAskAi type defines configuration options for enabling AI-powered conversational search in DocSearch. This feature allows users to ask questions and receive AI-generated answers based on your documentation.

Required Properties

assistantId
string
required
The assistant ID to use for the Ask AI feature. This identifies your configured AI assistant.
<DocSearch
  appId="YOUR_APP_ID"
  apiKey="YOUR_SEARCH_API_KEY"
  indexName="docs"
  askAi={{
    assistantId: 'your-assistant-id'
  }}
/>

Optional Algolia Configuration

By default, Ask AI uses the same Algolia credentials (appId, apiKey, indexName) as the main search. You can override these for Ask AI if needed.
indexName
string
The index name to use for the Ask AI feature. Your assistant will search this index for relevant documents.If not provided, the main indexName from DocSearchProps will be used.
<DocSearch
  appId="YOUR_APP_ID"
  apiKey="YOUR_SEARCH_API_KEY"
  indexName="docs"
  askAi={{
    assistantId: 'your-assistant-id',
    indexName: 'docs-ai' // Use a different index for AI
  }}
/>
apiKey
string
The API key to use for the Ask AI feature. Your assistant will use this API key to search the index.If not provided, the main apiKey from DocSearchProps will be used.
appId
string
The app ID to use for the Ask AI feature. Your assistant will use this app ID to search the index.If not provided, the main appId from DocSearchProps will be used.

Features

suggestedQuestions
boolean
Enables displaying suggested questions on Ask AI’s new conversation screen.Default: falseWhen enabled, users will see suggested questions they can click to start a conversation.
<DocSearch
  appId="YOUR_APP_ID"
  apiKey="YOUR_SEARCH_API_KEY"
  indexName="docs"
  askAi={{
    assistantId: 'your-assistant-id',
    suggestedQuestions: true
  }}
/>

Search Parameters

The searchParameters configuration varies based on whether you’re using the standard Ask AI backend or the experimental Agent Studio backend.

Standard Configuration (Default)

searchParameters
AskAiSearchParameters
The search parameters to use for the Ask AI feature when agentStudio is not enabled or is false.
<DocSearch
  appId="YOUR_APP_ID"
  apiKey="YOUR_SEARCH_API_KEY"
  indexName="docs"
  askAi={{
    assistantId: 'your-assistant-id',
    searchParameters: {
      filters: 'version:latest',
      facetFilters: ['language:en'],
      distinct: true
    }
  }}
/>

Agent Studio Configuration (Experimental)

agentStudio
boolean
Experimental: Whether to use Agent Studio as the chat backend.This is an experimental feature and its API may change without notice in future releases. Use with caution in production environments.Default: falseWhen set to true, the searchParameters structure changes to be keyed by index name.
searchParameters
AgentStudioSearchParameters
When agentStudio: true, search parameters must be keyed by index name.
<DocSearch
  appId="YOUR_APP_ID"
  apiKey="YOUR_SEARCH_API_KEY"
  indexName="docs"
  askAi={{
    assistantId: 'your-assistant-id',
    agentStudio: true,
    searchParameters: {
      'docs': {
        distinct: false,
        filters: 'version:latest'
      },
      'api-reference': {
        distinct: true,
        restrictSearchableAttributes: ['content', 'title']
      }
    }
  }}
/>

Internal/Testing Properties

useStagingEnv
boolean
Internal testing property. Do not use in production.Note: This is a temporary hack for testing staging environments and will be removed before release.

Type Variants

The DocSearchAskAi type uses TypeScript discriminated unions to ensure type safety based on the agentStudio setting:
type DocSearchAskAi = {
  assistantId: string;
  indexName?: string;
  apiKey?: string;
  appId?: string;
  suggestedQuestions?: boolean;
  useStagingEnv?: boolean;
  agentStudio?: never;
  searchParameters?: AskAiSearchParameters;
}

Simple String Configuration

In addition to the full DocSearchAskAi configuration object, you can pass a simple string assistant ID:
<DocSearch
  appId="YOUR_APP_ID"
  apiKey="YOUR_SEARCH_API_KEY"
  indexName="docs"
  askAi="your-assistant-id"
/>
This is equivalent to:
<DocSearch
  appId="YOUR_APP_ID"
  apiKey="YOUR_SEARCH_API_KEY"
  indexName="docs"
  askAi={{
    assistantId: 'your-assistant-id'
  }}
/>

Complete Examples

<DocSearch
  appId="YOUR_APP_ID"
  apiKey="YOUR_SEARCH_API_KEY"
  indexName="docs"
  askAi="your-assistant-id"
/>

Build docs developers (and LLMs) love