@infomatebot/chatbot-widget
Version:
Build intelligent chatbots using pre-designed conversation flows with quick reply options. Upload documents for AI-powered, context-aware responses and reduce support costs by 80% with guided conversations
228 lines • 6.02 kB
TypeScript
export interface MessageRequest {
message: string;
replyChoiceId: string;
actionData?: Record<string, any>;
}
export interface QuickReply {
id: string;
label: string;
}
export interface InputValidation {
required: boolean;
minLength?: number;
maxLength?: number;
pattern?: string;
errorMessage?: string;
min?: string;
max?: string;
}
export interface Message {
id: string;
content: string;
sender: 'bot' | 'user';
timestamp: string;
type?: 'text' | 'error';
}
export type MessageSource = 'knowledge_base' | 'conversation_flow';
export interface MessageMetadata {
source: MessageSource;
nodeId?: string;
confidence?: number;
documents?: string[];
[key: string]: any;
}
export interface ChatResponse {
message: string;
quickReplies?: QuickReply[];
inputCollector?: InputCollectorConfig;
}
export interface MessageResponse {
success: boolean;
message?: string;
quickReplies?: QuickReply[];
inputCollector?: InputCollectorConfig;
metadata?: MessageMetadata;
error?: string;
}
export interface InputCollectorConfig {
inputs: InputFormField[];
actionPayload: Record<string, any>;
successFlowId: string;
failureFlowId: string;
cancelFlowId?: string;
buttonLabels?: {
submit?: string;
cancel?: string;
};
}
export interface InputFormField {
inputKey: string;
label: string;
inputType: 'text' | 'email' | 'number' | 'tel' | 'textarea' | 'select' | 'date' | 'datetime-local' | 'time';
placeholder?: string;
validation?: InputValidation;
options?: string[];
}
export interface ActionRequest {
id: string;
payload: Record<string, any>;
timestamp: number;
messageId?: string;
}
export interface ActionResponse {
success: boolean;
message?: string;
data?: Record<string, any>;
error?: string;
}
export interface ActionHandler {
(payload: Record<string, any>, callback?: (response: ActionResponse) => void): Promise<ActionResponse> | ActionResponse | void;
}
export interface ActionExecutionOptions {
timeout: number;
showLoader: boolean;
timeoutBehavior: 'silent' | 'generic' | 'error';
fallbackMessage?: string;
}
export interface InputCollectorOptions {
inputType: string;
placeholder?: string;
validation?: InputValidation;
onSubmit: (value: string) => void;
onCancel: () => void;
}
export interface ChatInitResult {
success: boolean;
config?: InternalChatbotConfig;
error?: string;
}
export interface BackendConfig {
botName?: string;
welcomeMessage?: string;
inputPlaceholder?: string;
primaryColor?: string;
secondaryColor?: string;
size?: 'small' | 'medium' | 'large' | 'xl';
position?: 'bottom-right' | 'bottom-left';
autoOpen?: boolean;
enableTyping?: boolean;
theme?: 'light' | 'dark';
showPoweredBy?: boolean;
welcomeFlow?: {
flowId: string;
title: string;
message: string;
userOptions: Array<{
id: string;
text: string;
targetFlow: string;
}>;
};
fallbackFlow?: {
flowId: string;
title: string;
message: string;
userOptions: Array<{
id: string;
text: string;
targetFlow: string;
}>;
};
}
export interface ConversationHistory {
success: boolean;
messages?: Array<{
content: string;
sender: 'bot' | 'user';
timestamp: string;
}>;
error?: string;
}
export interface FeedbackResult {
success: boolean;
error?: string;
}
export interface ChatbotState {
isInitialized: boolean;
isOpen: boolean;
isTyping: boolean;
messageHistory: Message[];
}
export type ChatbotError = 'INITIALIZATION_FAILED' | 'API_REQUEST_FAILED' | 'MESSAGE_SEND_FAILED' | 'SESSION_EXPIRED' | 'INVALID_CONFIGURATION' | 'SERVICE_UNAVAILABLE' | 'RATE_LIMIT_EXCEEDED' | 'DOMAIN_NOT_ALLOWED';
export interface ThemeConfig {
primary: string;
secondary: string;
background: string;
text: string;
border: string;
}
export interface ChatbotElements {
trigger?: HTMLButtonElement;
window?: HTMLDivElement;
messages?: HTMLDivElement;
input?: HTMLTextAreaElement;
sendBtn?: HTMLButtonElement;
closeBtn?: HTMLButtonElement;
botName?: HTMLHeadingElement;
botStatus?: HTMLParagraphElement;
maximizeBtn?: HTMLButtonElement;
}
export interface InternalChatbotConfig {
apiBaseUrl: string;
apiKey: string;
botName: string;
welcomeMessage: string;
inputPlaceholder: string;
primaryColor: string;
secondaryColor: string;
theme: 'light' | 'dark';
size: 'small' | 'medium' | 'large' | 'xl';
position: 'bottom-right' | 'bottom-left';
autoOpen: boolean;
enableTyping: boolean;
showPoweredBy: boolean;
welcomeFlow?: {
flowId: string;
title: string;
message: string;
userOptions: Array<{
id: string;
text: string;
targetFlow: string;
}>;
};
fallbackFlow?: {
flowId: string;
title: string;
message: string;
userOptions: Array<{
id: string;
text: string;
targetFlow: string;
}>;
};
}
export type ChatbotEventHandler<T = any> = (event: CustomEvent<T>) => void;
export type RequiredChatbotConfig = Required<Omit<InternalChatbotConfig, 'welcomeFlow' | 'fallbackFlow'>> & {
welcomeFlow?: {
flowId: string;
title: string;
message: string;
userOptions: Array<{
id: string;
text: string;
targetFlow: string;
}>;
};
fallbackFlow?: {
flowId: string;
title: string;
message: string;
userOptions: Array<{
id: string;
text: string;
targetFlow: string;
}>;
};
};
//# sourceMappingURL=internal.types.d.ts.map