@iotauz/ai-chat
Version:
A customizable React chatbot component for IOTA SDK
131 lines (121 loc) • 4.08 kB
text/typescript
import * as React from 'react';
import React__default from 'react';
type ChatMessage = {
id: string;
content: string;
sender: 'user' | 'bot';
timestamp: Date;
};
interface FAQItem {
id: string;
question: string;
}
interface ChatbotInterfaceProps {
locale?: string;
apiEndpoint: string;
faqItems?: FAQItem[];
title?: string;
subtitle?: string;
chatIcon?: React.ReactNode;
customButton?: (props: {
onClick: () => void;
isMobile: boolean;
messageCount: number;
chatIcon?: React.ReactNode;
}) => React.ReactNode;
soundOptions?: {
enabled?: boolean;
volume?: number;
submitSoundPath?: string;
operatorSoundPath?: string;
};
onMessageSubmit?: (message: string) => void;
}
declare function ChatbotInterface({ locale, apiEndpoint, // Direct API endpoint (required)
faqItems, title, subtitle, chatIcon, customButton, soundOptions, onMessageSubmit, }: ChatbotInterfaceProps): React.JSX.Element;
interface SoundOptions {
volume?: number;
enabled?: boolean;
submitSoundPath?: string;
operatorSoundPath?: string;
}
declare function useSoundEffects(options?: SoundOptions): {
playSubmitSound: () => void;
playOperatorSound: () => void;
};
interface CreateThreadRequest {
message: string;
phone: string;
}
interface ThreadResponse {
thread_id: string;
}
interface Message {
role: 'user' | 'assistant';
message: string;
timestamp: string;
}
interface MessagesResponse {
messages: Message[];
}
interface AddMessageRequest {
message: string;
}
declare class ChatApiService {
private apiEndpoint;
setApiEndpoint(endpoint: string): void;
createThread(data: CreateThreadRequest): Promise<ThreadResponse>;
getMessages(threadId: string): Promise<MessagesResponse>;
addMessage(threadId: string, data: AddMessageRequest): Promise<ThreadResponse>;
}
declare const chatApi: ChatApiService;
interface Translations {
chatbotTitle: string;
chatbotSubtitle: string;
welcomeGreeting: string;
welcomeMessage: string;
phoneRequestMessage: string;
phoneInputPlaceholder: string;
phoneInputLabel: string;
messageInputPlaceholder: string;
sendButton: string;
callbackRequestButton: string;
extendPolicyQuestion: string;
findContractNumberQuestion: string;
submitClaimQuestion: string;
callbackModalTitle: string;
callbackModalSubtitle: string;
callbackPhoneInputLabel: string;
dataPrivacyMessage: string;
dataProcessingConsent: string;
backButton: string;
requestCallButton: string;
callbackConfirmation: string;
errorLoadingMessages: string;
errorCreatingChat: string;
errorSendingMessage: string;
threadNotFoundMessage: string;
months: string[];
}
declare function getTranslations(locale: string): Translations;
declare function formatDate(date: Date, translations: Translations): string;
interface CallbackModalProps {
isOpen: boolean;
onClose: () => void;
onSubmit: (_phoneNumber: string) => void;
translations: Translations;
}
declare function CallbackModal({ isOpen, onClose, onSubmit, translations }: CallbackModalProps): React__default.JSX.Element | null;
interface QuickReplyButtonsProps {
translations: Translations;
isTyping: boolean;
onQuickReply: (_question: string) => void;
faqItems?: FAQItem[];
}
declare function QuickReplyButtons({ translations, isTyping, onQuickReply, faqItems }: QuickReplyButtonsProps): React__default.JSX.Element;
interface TypingIndicatorProps {
translations: Translations;
botTitle?: string;
}
declare function TypingIndicator({ translations, botTitle }: TypingIndicatorProps): React__default.JSX.Element;
export { type AddMessageRequest, CallbackModal, type ChatMessage, ChatbotInterface, type CreateThreadRequest, type FAQItem, type Message, type MessagesResponse, QuickReplyButtons, type SoundOptions, type ThreadResponse, type Translations, TypingIndicator, chatApi, formatDate, getTranslations, useSoundEffects };