supporttor
Version:
A generic React chat widget component that supports any app with a knowledge base
96 lines (95 loc) • 2.37 kB
TypeScript
export interface Message {
id: string;
text: string;
sender: 'user' | 'assistant' | 'support-team';
timestamp: string;
status: 'sending' | 'sent' | 'failed';
conversationId?: string;
error?: string;
}
export interface StaticData {
apiUrl: string;
app_name: string;
conversationHistoryUrl: string;
}
export type Language = 'en' | 'tr' | 'de' | 'es' | 'pt';
export interface ChatWidgetProps {
domain_name: string;
userEmail?: string | null;
position?: 'bottom-right' | 'bottom-left' | 'top-right' | 'top-left';
language?: Language;
theme?: {
primaryColor?: string;
backgroundColor?: string;
textColor?: string;
loadingColor?: string;
errorColor?: string;
};
loadingIndicator?: {
type?: 'dots' | 'spinner';
color?: string;
size?: number;
};
}
export interface ChatIconProps {
position: string;
color: string;
onClick: () => void;
}
export interface ChatInterfaceProps {
isOpen: boolean;
onClose: () => void;
messages: Message[];
onSendMessage: (message: string) => Promise<void>;
onRetryMessage: (messageId: string) => Promise<void>;
onNewChat: () => void;
onRefresh: () => Promise<void>;
isLoading: boolean;
isRefreshing: boolean;
appName: string;
faqUrl: string;
}
export interface MessageBubbleProps {
message: Message;
onRetry?: (messageId: string) => void;
}
export interface ApiResponse {
conversation_id: string;
will_replied_with_email: boolean;
content: string;
}
export interface ConversationMessage {
id: string;
content: string;
sender_type: string;
created_at: string;
conversation_id: string;
}
export interface ConversationData {
id: string;
messages: ConversationMessage[];
created_at: string;
updated_at: string;
}
export interface ConversationHistoryResponse {
messages: ConversationMessage[];
}
export interface MessageInputProps {
value: string;
onChange: (value: string) => void;
onSend: () => void;
onRefresh: () => void;
isLoading: boolean;
isRefreshing: boolean;
}
export interface FAQItem {
question: string;
answer: string;
}
export interface FAQCategory {
name: string;
items: FAQItem[];
}
export interface FAQData {
categories: FAQCategory[];
}