UNPKG

@xapp/chat-widget

Version:
97 lines (96 loc) 3.07 kB
import 'rollup-plugin-inject-process-env'; /** * This mirrors the declaration in Chat-Server */ import { ChatUserInfo } from "@xapp/stentor-chat-widget"; import { Display } from "stentor-models"; /** * It's the same request in both (visitor <-> agent) direction! */ export interface ChatMessageRequest { /** * Type of message */ type: "rating" | "ratingRequest" | "comment" | "msg" | "failureMsg" | "custom" | "startTyping" | "stopTyping" | "userJoined" | "userLeft" | "handOff" | "handBack" | "permissionRequest" | "permissionGrant"; timestamp: number; msg?: ChatServerMessage; /** * Information related to the user sending the request */ readonly user: ChatUserInfo; agent?: boolean; /** * The user has requested to end the session. */ endSession?: boolean; handoffMessage?: string; handoffTarget?: string; /** * Optional, open ended, attributes to append to each request. */ attributes?: Record<string, unknown>; } export type PermissionRequestType = "EMAIL" | "PHONE_NUMBER" | "LOCATION_PRECISE"; export interface PermissionRequest { readonly time: number; readonly type: PermissionRequestType; readonly approve?: ChatServerMessage; readonly deny?: ChatServerMessage; } export interface ChatMessageRequestCustom extends ChatMessageRequest { readonly type: "custom"; readonly payload: string; } export interface ChatServerMessage { readonly text?: string; readonly html?: string; readonly permissionRequest?: PermissionRequest; options?: (string | ChatServerActionLink)[]; card?: ChatServerCard; list?: ChatServerList; token?: string; location?: ChatServerLocation; displays?: readonly Display[]; context?: readonly string[]; /** * Optional, open ended, attributes to append to each request. */ attributes?: Record<string, unknown>; } export interface ChatServerLocation { readonly latitude: number; readonly longitude: number; } export interface ChatServerCard { title?: string; imageUrl?: string; imageActionUrl?: string; content?: string; buttons?: ChatServerButton[]; } export type ChatServerListType = "LIST" | "CAROUSEL"; export interface ChatServerList { readonly type: ChatServerListType; readonly title?: string; readonly items: readonly ChatServerListItem[]; } export interface ChatServerButton { actionUrl: string | null; label: string; } export interface ChatServerActionLink { actionUrl: string; label: string; } export declare function isChatServerActionLink(arg: string | ChatServerActionLink): arg is ChatServerActionLink; export declare function getChatServerActionLinkLabel(arg: string | ChatServerActionLink): string; export declare function getItemUrl(item: ChatServerListItem): string | null; export interface ChatServerListItem { title: string; url?: string; imageUrl?: string; imageActionUrl?: string; subTitle?: string; token?: string; buttons?: readonly ChatServerButton[]; }