UNPKG

@xapp/chat-widget

Version:
86 lines (85 loc) 2.72 kB
import 'rollup-plugin-inject-process-env'; import { UserInfo, WidgetConfigurableMessagesConfig, WidgetHooks } from "@xapp/stentor-chat-widget"; import { ActionType } from "../store/ChatAction"; import { ChatMessageRequest, ChatServerMessage } from "./ChatServerMessage"; export interface ChatServer { init(dispatch: (action: ActionType) => void): void; sendOfflineMsg(message: OfflineMessage, cb: (error?: Error) => void): void; sendChatMsg(message: ChatServerMessage, cb: (err?: Error) => void): void; sendChatMsgRequest(message: ChatMessageRequest, cb: (err?: Error) => void): void; /** * Sets if the bot is typing or not. A typing indicator will appear in the UI. * @param isTyping True if typing, false if not. */ sendTyping(isTyping: boolean): void; /** * Sets who the visitor is (userId, accessToken, attributes) * * This data is then used on the requests to the server. * * Developer Note: This same information can be found on the redux state, it is only pulled from there once in the beginning. * * @param visitorInfo * @param cb */ setVisitorInfo(visitorInfo: VisitorInfoMessage, sessionId: string, cb: (error?: Error) => void): void; sendChatRating(rating?: "bad" | "good"): void; sendFile(file: File, cb: (err?: Error) => void): void; markAsRead(): void; flush(): void; dispose(): void; sleep(): void; wakeup(): void; bargeOut(arg0: (err?: Error) => void): unknown; bargeIn(agentName: string, arg1: (err?: Error) => void): unknown; } export interface ChatServerOptions { readonly token?: string; readonly bot?: UserInfo; readonly hooks?: WidgetHooks; readonly configurableMessages?: WidgetConfigurableMessagesConfig; } export interface OfflineMessage { readonly name: string; readonly email: string; readonly message: string; } /** * The visitor is on person on the browser, talking to either the bot or the live agent. */ export interface VisitorInfoMessage { /** * Admin i.e. human agent watching type */ readonly isAdmin?: boolean; /** * Visitors name */ readonly name?: string; /** * Visitor's display name */ readonly displayName?: string; /** * The email of the visitor */ email?: string; /** * Visitors access token */ readonly accessToken?: string; /** * User ID of the visitor */ readonly userId?: string; /** * Visitor's ID, can also be userId * * @deprecated - Use userId */ readonly visitorId?: string; /** * Optional request attributes. */ readonly attributes?: Record<string, any>; }