@iai-lib/any-chat-widget 0.1.0-alpha.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.md +1 -0
- package/README.md +7 -0
- package/dist/any-chat-widget.es.js +6040 -0
- package/dist/any-chat-widget.umd.js +352 -0
- package/dist/types/main.d.ts +1 -0
- package/dist/types/modules/five9/five9.ws.d.ts +21 -0
- package/dist/types/modules/five9/five9Manager.d.ts +38 -0
- package/dist/types/modules/five9/ngrok.d.ts +1 -0
- package/dist/types/modules/iaiChatWidget/functionCallHandlers/tourScheduler.d.ts +2 -0
- package/dist/types/modules/iaiChatWidget/functionCallHandlers/transferToLiveAgent.d.ts +6 -0
- package/dist/types/modules/iaiChatWidget/iaiChatWidget.d.ts +10 -0
- package/dist/types/types/five9Types.d.ts +229 -0
- package/dist/types/types/sdk.d.ts +17 -0
- package/dist/types/types/vite-env.d.ts +3 -0
- package/package.json +41 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { AnyChatWidget } from "./modules/iaiChatWidget/iaiChatWidget";
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export declare class Five9WebSocket {
|
|
2
|
+
private chatWsUrl;
|
|
3
|
+
private readonly _emitter;
|
|
4
|
+
readonly on: {
|
|
5
|
+
<Key extends string | number | symbol>(type: Key, handler: import("mitt").Handler<any>): void;
|
|
6
|
+
(type: "*", handler: import("mitt").WildcardHandler<any>): void;
|
|
7
|
+
};
|
|
8
|
+
readonly off: {
|
|
9
|
+
<Key extends string | number | symbol>(type: Key, handler?: import("mitt").Handler<any> | undefined): void;
|
|
10
|
+
(type: "*", handler: import("mitt").WildcardHandler<any>): void;
|
|
11
|
+
};
|
|
12
|
+
private reconnectCodes;
|
|
13
|
+
private reconnectAttempts;
|
|
14
|
+
private maxReconnectAttempts;
|
|
15
|
+
private ws?;
|
|
16
|
+
constructor(chatWsUrl: string);
|
|
17
|
+
connect(): void;
|
|
18
|
+
reconnect(): void;
|
|
19
|
+
disconnect(): void;
|
|
20
|
+
destroy(): void;
|
|
21
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { Five9Types } from "../../types/five9Types";
|
|
2
|
+
export declare class Five9Manager {
|
|
3
|
+
#private;
|
|
4
|
+
private readonly _emitter;
|
|
5
|
+
readonly on: {
|
|
6
|
+
<Key extends string | number | symbol>(type: Key, handler: import("mitt").Handler<any>): void;
|
|
7
|
+
(type: "*", handler: import("mitt").WildcardHandler<any>): void;
|
|
8
|
+
};
|
|
9
|
+
readonly off: {
|
|
10
|
+
<Key extends string | number | symbol>(type: Key, handler?: import("mitt").Handler<any> | undefined): void;
|
|
11
|
+
(type: "*", handler: import("mitt").WildcardHandler<any>): void;
|
|
12
|
+
};
|
|
13
|
+
conversationStarted: boolean;
|
|
14
|
+
private five9WebSocket?;
|
|
15
|
+
serialize(): string;
|
|
16
|
+
static deserialize(rawData: string): Five9Manager;
|
|
17
|
+
static generateBaseUrl(host: string): string;
|
|
18
|
+
createSession(): Promise<Five9Types.SessionToken>;
|
|
19
|
+
setSession(sessionToken: Five9Types.SessionToken): void;
|
|
20
|
+
setConversationId(conversationId: string): void;
|
|
21
|
+
connect(): void;
|
|
22
|
+
connectToWebSocket(): void;
|
|
23
|
+
authenticatedFetch(path: string, options?: RequestInit): Promise<any>;
|
|
24
|
+
getMetadata(): Promise<Five9Types.SessionToken>;
|
|
25
|
+
createConversation(conversation: Partial<Five9Types.Conversation>): Promise<Five9Types.ConversationInfo>;
|
|
26
|
+
sendMessage(content: string): Promise<void>;
|
|
27
|
+
sendTyping(): Promise<void>;
|
|
28
|
+
acknowledgeMessage(messages: Five9Types.AcknowledgeMessages): Promise<void>;
|
|
29
|
+
terminateConversation(): Promise<void>;
|
|
30
|
+
destroy(): void;
|
|
31
|
+
get sessionToken(): Five9Types.SessionToken | null;
|
|
32
|
+
get conversationId(): string | null;
|
|
33
|
+
get dataCenter(): Five9Types.DataCenter | undefined;
|
|
34
|
+
get apiUrl(): string | undefined;
|
|
35
|
+
get tenantId(): string | undefined;
|
|
36
|
+
get tokenId(): string | undefined;
|
|
37
|
+
get farmId(): string | undefined;
|
|
38
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function getNgrokUrl(): Promise<string>;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { Five9Manager } from "../../five9/five9Manager";
|
|
2
|
+
import { ChatWindowApi } from "@iai-lib/chat-widget/dist/types/types/widget";
|
|
3
|
+
import { FunctionCallParams } from "@iai-lib/chat-widget/dist/types/schema/WidgetOptions";
|
|
4
|
+
export declare function getChatSessionKey(historyKey: string | null): string;
|
|
5
|
+
export declare function transferToLiveAgent({ params, chatWindow }: FunctionCallParams): Promise<void>;
|
|
6
|
+
export declare function hijackChatForLiveAgent(chatWindow: ChatWindowApi, five9Manager: Five9Manager): void;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { WidgetOptions } from "@iai-lib/chat-widget/dist/types/schema/WidgetOptions";
|
|
2
|
+
import { IAIChatWidget } from "@iai-lib/chat-widget";
|
|
3
|
+
export declare class AnyChatWidget {
|
|
4
|
+
chatWidget: IAIChatWidget;
|
|
5
|
+
constructor(widgetOptions: Partial<WidgetOptions>, anyOptions: AnyOptions);
|
|
6
|
+
destroy(): void;
|
|
7
|
+
}
|
|
8
|
+
export interface AnyOptions {
|
|
9
|
+
schedulerUrl: string;
|
|
10
|
+
}
|
|
@@ -0,0 +1,229 @@
|
|
|
1
|
+
export declare namespace Five9Types {
|
|
2
|
+
enum MessageType {
|
|
3
|
+
TEXT = "TEXT"
|
|
4
|
+
}
|
|
5
|
+
enum AcknowledgeType {
|
|
6
|
+
DELIVERED = "DELIVERED",
|
|
7
|
+
READ = "READ",
|
|
8
|
+
FAILED = "FAILED"
|
|
9
|
+
}
|
|
10
|
+
enum ContentType {
|
|
11
|
+
GENERIC = "GENERIC",
|
|
12
|
+
SMS = "SMS",
|
|
13
|
+
RCS = "RCS",
|
|
14
|
+
FACEBOOK = "FACEBOOK",
|
|
15
|
+
TWITTER = "TWITTER",
|
|
16
|
+
WHATSAPP = "WHATSAPP",
|
|
17
|
+
WECHAT = "WECHAT",
|
|
18
|
+
QQMOBILE = "QQMOBILE",
|
|
19
|
+
APPLE_BUSINESS_CHAT = "APPLE_BUSINESS_CHAT",
|
|
20
|
+
SKYPE = "SKYPE",
|
|
21
|
+
SNAPCHAT = "SNAPCHAT",
|
|
22
|
+
VIBER = "VIBER",
|
|
23
|
+
LINE = "LINE",
|
|
24
|
+
TELEGRAM = "TELEGRAM",
|
|
25
|
+
KAKAO = "KAKAO"
|
|
26
|
+
}
|
|
27
|
+
enum ConversationEventOrigin {
|
|
28
|
+
SYSTEM = "SYSTEM",
|
|
29
|
+
USER = "USER"
|
|
30
|
+
}
|
|
31
|
+
enum ConversationStatus {
|
|
32
|
+
PENDING = "PENDING",
|
|
33
|
+
ACTIVE = "ACTIVE",
|
|
34
|
+
TERMINATED = "TERMINATED"
|
|
35
|
+
}
|
|
36
|
+
type AcknowledgeMessage = {
|
|
37
|
+
type: AcknowledgeType;
|
|
38
|
+
messageId: string;
|
|
39
|
+
};
|
|
40
|
+
type AcknowledgeMessages = {
|
|
41
|
+
messages: AcknowledgeMessage[];
|
|
42
|
+
};
|
|
43
|
+
type AnonymousUser = {
|
|
44
|
+
tenantName: string;
|
|
45
|
+
};
|
|
46
|
+
type Contact = {
|
|
47
|
+
email?: string;
|
|
48
|
+
firstName?: string;
|
|
49
|
+
lastName?: string;
|
|
50
|
+
company?: string;
|
|
51
|
+
street?: string;
|
|
52
|
+
city?: string;
|
|
53
|
+
state?: string;
|
|
54
|
+
zip?: string;
|
|
55
|
+
gender?: string;
|
|
56
|
+
number1?: string;
|
|
57
|
+
number2?: string;
|
|
58
|
+
number3?: string;
|
|
59
|
+
socialAccountHandle?: string;
|
|
60
|
+
socialAccountName?: string;
|
|
61
|
+
socialAccountImageUrl?: string;
|
|
62
|
+
socialAccountProfileUrl?: string;
|
|
63
|
+
};
|
|
64
|
+
type Conversation = {
|
|
65
|
+
type: ContentType;
|
|
66
|
+
tenantId: number;
|
|
67
|
+
callbackUrl: string;
|
|
68
|
+
campaignName?: string;
|
|
69
|
+
campaignId?: number;
|
|
70
|
+
contact: Contact;
|
|
71
|
+
attributes?: Record<string, string>;
|
|
72
|
+
disableAutoClose?: boolean;
|
|
73
|
+
disableComfortMessage?: boolean;
|
|
74
|
+
useBusinessHours?: boolean;
|
|
75
|
+
externalId?: string;
|
|
76
|
+
priority?: number;
|
|
77
|
+
};
|
|
78
|
+
type ConversationAcceptEvent = {
|
|
79
|
+
correlationId: string;
|
|
80
|
+
displayName: string;
|
|
81
|
+
externalId?: string;
|
|
82
|
+
eventSerialNumber: number;
|
|
83
|
+
from: ConversationBind;
|
|
84
|
+
timestamp: string;
|
|
85
|
+
userId: number;
|
|
86
|
+
};
|
|
87
|
+
type ConversationBind = any;
|
|
88
|
+
type ConversationErrorEvent = {
|
|
89
|
+
correlationId: string;
|
|
90
|
+
contentType: ContentType;
|
|
91
|
+
displayName: string;
|
|
92
|
+
externalId?: string;
|
|
93
|
+
eventSerialNumber: number;
|
|
94
|
+
from: ConversationBind[];
|
|
95
|
+
messageId: string;
|
|
96
|
+
messageSerialNumber: number;
|
|
97
|
+
messageType: number;
|
|
98
|
+
text: string;
|
|
99
|
+
timestamp: string;
|
|
100
|
+
userId: number;
|
|
101
|
+
};
|
|
102
|
+
type ConversationEvent = {
|
|
103
|
+
correlationId: string;
|
|
104
|
+
externalId?: string;
|
|
105
|
+
timestamp: string;
|
|
106
|
+
eventSerialNumber: number;
|
|
107
|
+
};
|
|
108
|
+
type ConversationInfo = {
|
|
109
|
+
id: string;
|
|
110
|
+
status: ConversationTypingEvent;
|
|
111
|
+
disposition: number;
|
|
112
|
+
};
|
|
113
|
+
type ConversationMessageEvent = {
|
|
114
|
+
contentType: ContentType;
|
|
115
|
+
correlationId: string;
|
|
116
|
+
displayName: string;
|
|
117
|
+
eventSerialNumber: number;
|
|
118
|
+
externalId?: string;
|
|
119
|
+
from: string;
|
|
120
|
+
messageId: string;
|
|
121
|
+
text: string;
|
|
122
|
+
timestamp: string;
|
|
123
|
+
userId: number;
|
|
124
|
+
attachments: string[];
|
|
125
|
+
};
|
|
126
|
+
type ConversationParticipantEvent = {
|
|
127
|
+
correlationId: string;
|
|
128
|
+
displayName: string;
|
|
129
|
+
eventSerialNumber: number;
|
|
130
|
+
externalId?: string;
|
|
131
|
+
participants: Metadata[];
|
|
132
|
+
timestamp: string;
|
|
133
|
+
userId: number;
|
|
134
|
+
};
|
|
135
|
+
type ConversationTerminateEvent = {
|
|
136
|
+
correlationId: string;
|
|
137
|
+
displayName: string;
|
|
138
|
+
externalId?: string;
|
|
139
|
+
eventSerialNumber: number;
|
|
140
|
+
from: ConversationBind;
|
|
141
|
+
timestamp: string;
|
|
142
|
+
userId: number;
|
|
143
|
+
};
|
|
144
|
+
type ConversationTransferEvent = {
|
|
145
|
+
correlationId: string;
|
|
146
|
+
externalId?: string;
|
|
147
|
+
eventSerialNumber: number;
|
|
148
|
+
fromDisplayName: string;
|
|
149
|
+
fromUserId: number;
|
|
150
|
+
timestamp: string;
|
|
151
|
+
};
|
|
152
|
+
type ConversationTransferToAgentEvent = {
|
|
153
|
+
correlationId: string;
|
|
154
|
+
externalId?: string;
|
|
155
|
+
eventSerialNumber: number;
|
|
156
|
+
fromDisplayName: string;
|
|
157
|
+
fromUserId: number;
|
|
158
|
+
toDisplayName: string;
|
|
159
|
+
toUserId: number;
|
|
160
|
+
participants: Metadata[];
|
|
161
|
+
timestamp: string;
|
|
162
|
+
};
|
|
163
|
+
type ConversationTransferToGroupEvent = {
|
|
164
|
+
correlationId: string;
|
|
165
|
+
externalId?: string;
|
|
166
|
+
eventSerialNumber: number;
|
|
167
|
+
fromDisplayName: string;
|
|
168
|
+
fromUserId: number;
|
|
169
|
+
groupId: number;
|
|
170
|
+
groupName: string;
|
|
171
|
+
timestamp: string;
|
|
172
|
+
};
|
|
173
|
+
type ConversationTypingEvent = {
|
|
174
|
+
correlationId: string;
|
|
175
|
+
displayName: string;
|
|
176
|
+
externalId?: string;
|
|
177
|
+
eventSerialNumber: number;
|
|
178
|
+
timestamp: string;
|
|
179
|
+
userId: number;
|
|
180
|
+
};
|
|
181
|
+
type Generic500ErrorResponse = {
|
|
182
|
+
description: string;
|
|
183
|
+
};
|
|
184
|
+
type Group = {
|
|
185
|
+
groupId: number;
|
|
186
|
+
groupName: string;
|
|
187
|
+
};
|
|
188
|
+
type Message = {
|
|
189
|
+
messageType: MessageType;
|
|
190
|
+
message: string;
|
|
191
|
+
externalId?: string;
|
|
192
|
+
attachments?: string[];
|
|
193
|
+
};
|
|
194
|
+
type Participant = {
|
|
195
|
+
userId: number;
|
|
196
|
+
displayName: string;
|
|
197
|
+
};
|
|
198
|
+
type Five9Config = {
|
|
199
|
+
tenantName: string;
|
|
200
|
+
campaignName: string;
|
|
201
|
+
callbackUrl: string;
|
|
202
|
+
};
|
|
203
|
+
type ApiUrl = {
|
|
204
|
+
host: string;
|
|
205
|
+
port: string;
|
|
206
|
+
routeKey: string;
|
|
207
|
+
version: string;
|
|
208
|
+
};
|
|
209
|
+
type DataCenter = {
|
|
210
|
+
name: string;
|
|
211
|
+
uiUrls: ApiUrl[];
|
|
212
|
+
apiUrls: ApiUrl[];
|
|
213
|
+
loginUrls: ApiUrl[];
|
|
214
|
+
active: boolean;
|
|
215
|
+
};
|
|
216
|
+
type Metadata = {
|
|
217
|
+
freedomUrl: string;
|
|
218
|
+
dataCenters: DataCenter[];
|
|
219
|
+
};
|
|
220
|
+
type SessionToken = {
|
|
221
|
+
context: Map<string, string> & {
|
|
222
|
+
farmId: string;
|
|
223
|
+
};
|
|
224
|
+
metadata: Metadata;
|
|
225
|
+
orgId: string;
|
|
226
|
+
tokenId: string;
|
|
227
|
+
userId: string;
|
|
228
|
+
};
|
|
229
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
|
|
2
|
+
type ChatMessage = UserMessage | AgentMessage | SystemMessage;
|
|
3
|
+
|
|
4
|
+
type Five9Events = {
|
|
5
|
+
previousMessagesLoaded: ChatMessage[],
|
|
6
|
+
message: ChatMessage,
|
|
7
|
+
'message.user': UserMessage,
|
|
8
|
+
'message.agent': AgentMessage,
|
|
9
|
+
'message.system': SystemMessage,
|
|
10
|
+
agentJoined: AgentJoined,
|
|
11
|
+
agentTyping: {
|
|
12
|
+
userId: number,
|
|
13
|
+
displayName: string
|
|
14
|
+
typing: boolean;
|
|
15
|
+
},
|
|
16
|
+
event: Five9Event
|
|
17
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@iai-lib/any-chat-widget",
|
|
3
|
+
"license": "SEE LICENSE IN LICENSE.md",
|
|
4
|
+
"version": "0.1.0-alpha.10",
|
|
5
|
+
"publishConfig": {
|
|
6
|
+
"access": "public"
|
|
7
|
+
},
|
|
8
|
+
"type": "module",
|
|
9
|
+
"scripts": {
|
|
10
|
+
"dev": "vite",
|
|
11
|
+
"dev:build": "vite build --watch",
|
|
12
|
+
"dev:build:delayed": "delay 10 && yarn dev:build",
|
|
13
|
+
"build": "vite build",
|
|
14
|
+
"lint": "eslint \"src/**/*.{js}\"",
|
|
15
|
+
"lint:fix": "npm run lint -- --fix"
|
|
16
|
+
},
|
|
17
|
+
"main": "./dist/any-chat-widget.umd.js",
|
|
18
|
+
"module": "./dist/any-chat-widget.es.js",
|
|
19
|
+
"exports": {
|
|
20
|
+
".": {
|
|
21
|
+
"import": "./dist/any-chat-widget.es.js",
|
|
22
|
+
"require": "./dist/any-chat-widget.umd.js"
|
|
23
|
+
}
|
|
24
|
+
},
|
|
25
|
+
"types": "./dist/types/main.d.ts",
|
|
26
|
+
"files": [
|
|
27
|
+
"dist"
|
|
28
|
+
],
|
|
29
|
+
"devDependencies": {
|
|
30
|
+
"delay-cli": "^2.0.0",
|
|
31
|
+
"typescript": "^5.3.3",
|
|
32
|
+
"vite": "^5.1.0",
|
|
33
|
+
"vite-plugin-dts": "^3.7.2",
|
|
34
|
+
"vite-plugin-static-copy": "^1.0.1"
|
|
35
|
+
},
|
|
36
|
+
"dependencies": {
|
|
37
|
+
"@iai-lib/chat-widget": "^1.0.0-alpha.18",
|
|
38
|
+
"mitt": "^3.0.1"
|
|
39
|
+
},
|
|
40
|
+
"gitHead": "ee3fe187d3c334fe02a8b9931350aa9d46d2d46a"
|
|
41
|
+
}
|