ui-embed
Embed the chatbot UI inside Docusaurus and connect it to the FastAPI RAG backend. Use when building chat components, handling streaming responses, or integrating chat widgets into MDX pages.
When & Why to Use This Skill
This Claude skill streamlines the integration of AI-powered chatbot interfaces within Docusaurus documentation sites. It provides a comprehensive framework for building React-based chat components, managing streaming responses from FastAPI RAG backends, and embedding interactive chat widgets directly into MDX pages to enhance user engagement and documentation accessibility.
Use Cases
- AI-Powered Documentation: Transform static technical docs into an interactive experience by embedding a RAG-connected chatbot that answers user queries based on the site content.
- Contextual Learning: Use MDX shortcodes to insert specialized chat widgets into specific tutorial chapters, providing students with real-time, context-aware coding assistance.
- Enhanced UX with Text Selection: Implement a 'chat-with-selected-text' feature that allows users to highlight complex documentation snippets and receive instant AI explanations or summaries.
- Seamless API Integration: Rapidly connect Docusaurus front-ends to FastAPI backends with pre-configured fetch helpers designed for streaming data and metadata logging.
| name | ui-embed |
|---|---|
| description | Embed the chatbot UI inside Docusaurus and connect it to the FastAPI RAG backend. Use when building chat components, handling streaming responses, or integrating chat widgets into MDX pages. |
UI Embed Skill
Instructions
Build component
- Create React chat panel (
ChatbotPanel.tsx) with:- Message list
- Input field
- Mode toggle (RAG vs Selected Text)
- Source list display
- Handle streaming responses (EventSource/fetch reader)
- Include loading and error UI states
- Create React chat panel (
API client
- Create fetch helpers for
/queryand/query/selected - Include page metadata (module/week/title) for logging
- Debounce/trim inputs; enforce max length
- Create fetch helpers for
Integration
- Add to
src/theme/Layoutor dedicatedChatpage - Optionally show floating button
- Provide MDX shortcode to drop chat in specific chapters
- Add to
UX and accessibility
- Basic console logging for failures
- Friendly fallback messages
- Focus management, keyboard submit
- Readable contrast
Examples
// ChatbotPanel.tsx
import React, { useState } from 'react';
export function ChatbotPanel({ apiUrl }: { apiUrl: string }) {
const [messages, setMessages] = useState([]);
const [input, setInput] = useState('');
const [mode, setMode] = useState<'rag' | 'selected'>('rag');
// ... implementation
}
{/* In any MDX page */}
import { ChatbotPanel } from '@site/src/components/ChatbotPanel';
<ChatbotPanel apiUrl={process.env.API_URL} />
Definition of Done
- Widget renders in Docusaurus dev build; can query backend
- Selected-text path sends provided text and returns grounded answer
- Error/loading states visible; minimal styling but responsive
- Integration steps documented for future pages