@developer.notchatbot/webchat
Version:
A beautiful React chatbot widget with single-file bundle
51 lines (50 loc) • 1.64 kB
TypeScript
import { Message } from '../types';
export interface SendMessagePayload {
conversationId: string;
conversation: {
id: string;
senderId: string;
createdAt: string;
chatbotActivated: boolean;
updatedAt: string;
source: string;
website: string;
language?: string;
region?: string;
messages: any[];
};
chatbotUid: string;
newMessages: any[];
note?: string;
currentUrl?: string;
}
/**
* Creates a fallback bot message for error scenarios
* @returns Fallback bot message
*/
export declare const createFallbackMessage: () => Message;
/**
* Builds the payload for sending messages to the API
* @param conversationId Conversation ID
* @param messages Array of all messages
* @param newMessages Array of only new messages to be processed
* @param config Chat configuration
* @param sessionId User's session identifier
* @returns API payload
*/
export declare const buildMessagePayload: (conversationId: string, messages: Message[], newMessages: Message[], config: {
apiKey: string;
note?: string;
}, sessionId: string, currentUrl?: string) => SendMessagePayload;
/**
* Sends messages to the chat API
* @param payload Message payload
* @returns Promise that resolves to API response or null if failed
*/
export declare const sendMessageToAPI: (payload: SendMessagePayload) => Promise<any>;
/**
* Creates a bot message from API response
* @param responseData API response data
* @returns Bot message or null if no content
*/
export declare const createBotMessageFromResponse: (responseData: any) => Message | null;