/** * @fileoverview Main chatbot hook providing unified access to all chatbot functionality * @module hooks/useChatbot */ import { useContext } from "react"; import { ChatbotContext, type ChatbotContextType, } from "../core/contexts/ChatbotContext"; /** * Re-export the main chatbot hook from the context * This provides a unified interface to all chatbot functionality * * @returns {ChatbotContextType} Chatbot state and methods * * @example * ```typescript * function MyComponent() { * const { * isInitialized, * config, * initialize, * sendMessage, * uploadDocument, * searchSimilarDocuments, * lastError, * clearError * } = useChatbot(); * * useEffect(() => { * if (!isInitialized) { * initialize(); * } * }, [isInitialized, initialize]); * * return ( *
* {lastError &&
{lastError.message}
} * {isInitialized ? : } *
* ); * } * ``` */ export function useChatbot(): ChatbotContextType { const context = useContext(ChatbotContext); if (!context) { throw new Error("useChatbot must be used within a ChatbotProvider"); } return context; }