@developer.notchatbot/webchat
Version:
A beautiful React chatbot widget with single-file bundle
29 lines (28 loc) • 1.25 kB
TypeScript
import { default as Ably } from 'ably';
import { Message } from '../types';
export interface AblyConnectionData {
client: Ably.Realtime;
channel: Ably.Types.RealtimeChannelBase;
}
/**
* Initializes Ably connection with provided token details
* @param tokenDetails Token details from API
* @param chatbotUid Chatbot UID
* @param conversationId Conversation ID
* @param onMessage Callback for new messages
* @param onConnectionChange Callback for connection status changes
* @returns Promise that resolves to Ably connection data
*/
export declare const initializeAblyConnection: (tokenDetails: any, chatbotUid: string, conversationId: string, onMessage: (message: Message) => void, onConnectionChange?: (status: string) => void) => Promise<AblyConnectionData>;
/**
* Fetches Ably token from conversation endpoint
* @param conversationId Conversation ID
* @param apiKey API key for authentication
* @returns Promise that resolves to conversation data with token details
*/
export declare const fetchAblyToken: (conversationId: string, apiKey: string) => Promise<any>;
/**
* Closes Ably connection safely
* @param client Ably client to close
*/
export declare const closeAblyConnection: (client: Ably.Realtime | null) => void;