UNPKG

@developer.notchatbot/webchat

Version:

A beautiful React chatbot widget with single-file bundle

37 lines (36 loc) 1.86 kB
import { ConvexReactClient } from 'convex/react'; import { Message } from '../types'; export interface ConvexConnectionData { client: ConvexReactClient; unsubscribe: (() => void) | null; } /** * Initializes Convex connection for real-time subscriptions * @param realtimeEndpoint Realtime service deployment URL * @param chatbotUid Chatbot UID (API Key) * @param conversationId Conversation ID * @param onMessage Callback for new messages * @param onChatbotToggle Callback for chatbot activation changes * @returns Promise that resolves to Convex connection data */ export declare const initializeConvexConnection: (realtimeEndpoint: string, _chatbotUid: string, conversationId: string, onMessage: (message: Message) => void, onChatbotToggle?: (chatbotActivated: boolean) => void) => Promise<ConvexConnectionData>; /** * Fetches initial conversation data with messages from Convex * @param realtimeEndpoint Realtime service deployment URL * @param conversationId Conversation ID * @returns Promise that resolves to conversation data with messages */ export declare const fetchConversationFromConvex: (realtimeEndpoint: string, conversationId: string) => Promise<any>; /** * Watches webchat activation status for a given API key * @param realtimeEndpoint Realtime service deployment URL * @param apiKey API Key (chatbot UID) * @param onActiveChange Callback when activation status changes * @returns Promise that resolves to connection data with unsubscribe function */ export declare const watchWebchatActive: (realtimeEndpoint: string, apiKey: string, onActiveChange: (isActive: boolean) => void) => Promise<ConvexConnectionData>; /** * Closes Convex connection safely * @param connectionData Convex connection data to close */ export declare const closeConvexConnection: (connectionData: ConvexConnectionData | null) => void;