Overview
Ask AI uses large language models to:- Understand natural language questions
- Search your documentation index
- Generate accurate, contextual answers
- Cite sources with links to your docs
- Support follow-up questions in context
Ask AI requires an assistant ID from Algolia and is available on compatible plans.
Enabling Ask AI
1
Get an Assistant ID
Contact Algolia or configure an assistant in your dashboard to get your assistant ID.
2
Add to DocSearch Config
Pass the assistant ID to enable Ask AI features.
3
Configure Search Parameters
Optionally customize which content the AI searches.
React Integration
JavaScript Integration
Configuration Options
Customize Ask AI behavior with additional options:Configuration Reference
Configuration Reference
Search Parameters
Control what content the AI can search:User Experience
Opening Ask AI
Users can activate Ask AI in several ways:- Search Modal: Click the AI button in the search interface
- Direct Button: Click an “Ask AI” button you add to your site
- Keyboard Shortcut: Configurable shortcut (e.g., Cmd+Shift+K)
- Programmatic: Call the API from your code
Conversation Flow
1
User asks a question
Natural language query like “How do I style the search modal?”
2
AI searches your docs
The assistant queries your Algolia index for relevant content.
3
AI generates answer
Streams a response synthesized from your documentation.
4
Sources are cited
Links to source pages appear below the answer.
5
Follow-up questions
Users can ask additional questions in context.
Ask AI Screen Component
The Ask AI interface is built with theAskAiScreen component:
Message Structure
Conversations consist of user and assistant messages:Exchanges
Messages are grouped into user-assistant exchanges:useAskAi Hook
TheuseAskAi hook manages AI chat state:
The hook uses the AI SDK for streaming responses and automatically handles conversation state.
Customizing Translations
Customize AI interface text:Feedback System
Users can provide feedback on answers:Advanced: Agent Studio
Experimental Agent Studio Backend
Experimental Agent Studio Backend
Agent Studio is an experimental backend for Ask AI:
Intercepting Ask AI Events
Handle Ask AI activation in custom ways:Conversation History
Recent conversations are stored locally:Error Handling
Handle errors gracefully:- Invalid assistant ID
- Network issues
- Rate limiting
- Thread depth exceeded (too many follow-ups)
Thread depth errors occur after many consecutive follow-up questions. Start a new conversation to continue.
Best Practices
Clear Documentation
Well-written docs produce better AI answers. Use clear headings and concise explanations.
Filter Strategically
Use search parameters to focus AI on relevant content without being too restrictive.
Monitor Feedback
Track user feedback to identify documentation gaps or confusing sections.
Test Questions
Try common questions to ensure the AI provides accurate, helpful answers.
Styling Ask AI
Customize the appearance:Next Steps
Styling Guide
Learn how to customize DocSearch appearance including Ask AI components
