@deepdesk/deepdesk-sdk 10.0.0-beta.12
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/README.md +60 -0
- package/dist/index.cjs.js +6 -0
- package/dist/index.d.mts +2047 -0
- package/dist/index.d.ts +2047 -0
- package/dist/index.esm.js +6 -0
- package/package.json +123 -0
- package/styles/index.js +2 -0
- package/styles.css +1 -0
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,2047 @@
|
|
|
1
|
+
import React, { FC, HTMLAttributes, ForwardRefExoticComponent, RefAttributes, ReactNode, SyntheticEvent } from 'react';
|
|
2
|
+
import * as redux from 'redux';
|
|
3
|
+
import * as _reduxjs_toolkit_dist_configureStore from '@reduxjs/toolkit/dist/configureStore';
|
|
4
|
+
import * as _reduxjs_toolkit from '@reduxjs/toolkit';
|
|
5
|
+
import { Middleware } from '@reduxjs/toolkit';
|
|
6
|
+
|
|
7
|
+
declare enum Sources {
|
|
8
|
+
SEARCH = "search",
|
|
9
|
+
TEMPLATE = "template",
|
|
10
|
+
ELASTIC_SEARCH = "studio-search",
|
|
11
|
+
GPT = "gpt",
|
|
12
|
+
TRIE = "trie",
|
|
13
|
+
TRIE_WITH_TYPOS = "trie-with-typos",
|
|
14
|
+
SEMANTIC = "semantic",
|
|
15
|
+
TEXT_RECOMMENDATION = "text_recommendation",
|
|
16
|
+
URL_RECOMMENDATION = "url_recommendation",
|
|
17
|
+
LINK_RECOMMENDATION = "link_recommendation",
|
|
18
|
+
PERSONAL_COLLECTION = "personal-collection",
|
|
19
|
+
PERSONAL_COLLECTION_SEARCH = "personal-collection-search"
|
|
20
|
+
}
|
|
21
|
+
declare enum InputType {
|
|
22
|
+
TAB = "tab",
|
|
23
|
+
ARROW = "arrow",
|
|
24
|
+
HOTKEY = "hotkey",
|
|
25
|
+
MOUSE = "mouse"
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* A selection range representation for textarea's and contenteditables only using offsets.
|
|
30
|
+
*/
|
|
31
|
+
type SelectionRange = {
|
|
32
|
+
start: number;
|
|
33
|
+
end: number;
|
|
34
|
+
};
|
|
35
|
+
interface InputEventMap {
|
|
36
|
+
/**
|
|
37
|
+
* User and platform changes (excluding changes by plugin)
|
|
38
|
+
*/
|
|
39
|
+
change: (event: {
|
|
40
|
+
plainText: string;
|
|
41
|
+
rawHtml: string | null;
|
|
42
|
+
}) => void;
|
|
43
|
+
/**
|
|
44
|
+
* Updated value after User, platform and plugin changes
|
|
45
|
+
*/
|
|
46
|
+
updated: (event: {
|
|
47
|
+
plainText: string;
|
|
48
|
+
rawHtml: string | null;
|
|
49
|
+
}) => void;
|
|
50
|
+
/**
|
|
51
|
+
* Changed selection of input
|
|
52
|
+
*/
|
|
53
|
+
selection: (event: SelectionRange | null) => void;
|
|
54
|
+
keydown: (event: KeyboardEvent) => void;
|
|
55
|
+
paste: (event: {
|
|
56
|
+
pastedText: string;
|
|
57
|
+
selectionText: string;
|
|
58
|
+
}) => void;
|
|
59
|
+
cut: (event: {
|
|
60
|
+
selectionText: string;
|
|
61
|
+
}) => void;
|
|
62
|
+
submit: () => void;
|
|
63
|
+
enabled: () => void;
|
|
64
|
+
disabled: () => void;
|
|
65
|
+
unmounted: () => void;
|
|
66
|
+
focus: () => void;
|
|
67
|
+
blur: () => void;
|
|
68
|
+
}
|
|
69
|
+
type InputHandler<K extends keyof InputEventMap> = InputEventMap[K];
|
|
70
|
+
type InputEventListeners<K extends keyof InputEventMap> = Record<K, InputHandler<K>[]>;
|
|
71
|
+
declare abstract class InputMediator<HTMLElementType extends HTMLElement> {
|
|
72
|
+
protected element: HTMLElementType;
|
|
73
|
+
protected eventListeners: Partial<InputEventListeners<keyof InputEventMap>>;
|
|
74
|
+
protected disposeHandlers: (() => void)[];
|
|
75
|
+
protected currentText: string;
|
|
76
|
+
protected currentHTML: string | null;
|
|
77
|
+
protected currentSelection: SelectionRange | null;
|
|
78
|
+
protected isFocused: boolean;
|
|
79
|
+
protected isActive: boolean;
|
|
80
|
+
protected isSettingValue: boolean;
|
|
81
|
+
protected isSubmitting: boolean;
|
|
82
|
+
protected isPossibleClearInputAction: boolean;
|
|
83
|
+
protected isDisposed: boolean;
|
|
84
|
+
constructor(element: HTMLElementType);
|
|
85
|
+
protected addEventListener(eventName: string, listener: EventListenerOrEventListenerObject): void;
|
|
86
|
+
protected removeEventListener(eventName: string, listener: EventListenerOrEventListenerObject): void;
|
|
87
|
+
protected triggerChange(): void;
|
|
88
|
+
abstract getSelectedText(): string;
|
|
89
|
+
protected handleKeyUp(event: KeyboardEvent): void;
|
|
90
|
+
protected handleFocus(): void;
|
|
91
|
+
protected handleBlur(): void;
|
|
92
|
+
protected handleKeyDown(event: KeyboardEvent): void;
|
|
93
|
+
protected handleCut(): void;
|
|
94
|
+
protected handlePaste(event: ClipboardEvent): void;
|
|
95
|
+
protected listen(): void;
|
|
96
|
+
abstract getText(): string;
|
|
97
|
+
abstract getHTML(): string | null;
|
|
98
|
+
abstract getSelection(): SelectionRange | null;
|
|
99
|
+
abstract applyChanges(callback: (element: HTMLElementType) => void): void;
|
|
100
|
+
focus(): void;
|
|
101
|
+
emit<K extends keyof InputEventMap>(type: K, ...args: Parameters<InputHandler<K>>): void;
|
|
102
|
+
on<K extends keyof InputEventMap>(type: K, handler: InputHandler<K>): void;
|
|
103
|
+
activate(): void;
|
|
104
|
+
deactivate(): void;
|
|
105
|
+
dispose(): void;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
type State$f = {
|
|
109
|
+
startTime: Date | null;
|
|
110
|
+
stopTime: Date | null;
|
|
111
|
+
};
|
|
112
|
+
|
|
113
|
+
interface State$e {
|
|
114
|
+
contentType: string | null;
|
|
115
|
+
suggestion: TextSuggestion | null;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
/**
|
|
119
|
+
* CamelCase type manipulation
|
|
120
|
+
* ```
|
|
121
|
+
* type InputType = 'snake_case_key_1'
|
|
122
|
+
* type OutputType = CamelCase<InputType>; // 'snakeCaseKey1'
|
|
123
|
+
* ```
|
|
124
|
+
*/
|
|
125
|
+
type CamelCase<S extends string> = S extends `${infer P1}_${infer P2}${infer P3}` ? `${Lowercase<P1>}${Uppercase<P2>}${CamelCase<P3>}` : Lowercase<S>;
|
|
126
|
+
/**
|
|
127
|
+
* CamelCaseKeys type manipulation
|
|
128
|
+
* Convert object keys and nested objects keys to camel case
|
|
129
|
+
* ```
|
|
130
|
+
* type InputType = {
|
|
131
|
+
* snake_case_key_1: number,
|
|
132
|
+
* snake_case_key_2: string,
|
|
133
|
+
* }
|
|
134
|
+
*
|
|
135
|
+
* type OutputType = CamelCaseKeys<InputType>;
|
|
136
|
+
* > ^ =
|
|
137
|
+
* > type OutputType = {
|
|
138
|
+
* > snakeCaseKey1: number;
|
|
139
|
+
* > snakeCaseKey2: string;
|
|
140
|
+
* > }
|
|
141
|
+
* ```
|
|
142
|
+
*/
|
|
143
|
+
type CamelCaseKeys<T> = T extends Array<any> ? {
|
|
144
|
+
[K in keyof T[number] as CamelCase<K & string>]: CamelCaseKeys<T[number][K]>;
|
|
145
|
+
}[] : T extends object ? {
|
|
146
|
+
[K in keyof T as CamelCase<K & string>]: CamelCaseKeys<T[K]>;
|
|
147
|
+
} : T;
|
|
148
|
+
|
|
149
|
+
type Fetch = typeof window.fetch;
|
|
150
|
+
type HTTPClientOptions = {
|
|
151
|
+
fetch?: typeof window.fetch;
|
|
152
|
+
};
|
|
153
|
+
interface RetryInit {
|
|
154
|
+
abortLatest?: boolean;
|
|
155
|
+
attempts?: number;
|
|
156
|
+
retryDelay?: number;
|
|
157
|
+
retryOnError?(error: Error): boolean;
|
|
158
|
+
retryOnResponse?(response: Response): boolean;
|
|
159
|
+
}
|
|
160
|
+
interface RefreshTokenInit {
|
|
161
|
+
refreshTokenOn401?: boolean;
|
|
162
|
+
}
|
|
163
|
+
interface APIVersionInit {
|
|
164
|
+
version?: 'v1' | 'v2' | null;
|
|
165
|
+
}
|
|
166
|
+
interface ExtendedRequestInit extends RequestInit, RefreshTokenInit, RetryInit, APIVersionInit {
|
|
167
|
+
}
|
|
168
|
+
declare class HTTPClient {
|
|
169
|
+
baseUrl: string;
|
|
170
|
+
options: HTTPClientOptions;
|
|
171
|
+
private latestRequestByUrl;
|
|
172
|
+
csrfToken?: string;
|
|
173
|
+
fetch: ((input: RequestInfo | URL, init?: RequestInit | undefined) => Promise<Response>) & typeof fetch;
|
|
174
|
+
private static refreshingToken;
|
|
175
|
+
constructor(baseUrl?: string, options?: HTTPClientOptions);
|
|
176
|
+
patchFetch(patch: (fetchFn: Fetch) => Fetch): void;
|
|
177
|
+
setCsrfToken(token: string): void;
|
|
178
|
+
request<TResponse>(path: string, init?: ExtendedRequestInit): Promise<TResponse>;
|
|
179
|
+
/**
|
|
180
|
+
* SDK used to talk to backend endpoints only. Backend requires an accessToken for authentication and therefore /auth/validate (backend) is checked.
|
|
181
|
+
* Now SDK will also use admin endpoints. Admin requires a session for authentication.
|
|
182
|
+
* Therefore, both admin and backend authentication is checked
|
|
183
|
+
*/
|
|
184
|
+
validateToken(): Promise<boolean>;
|
|
185
|
+
refreshToken(): Promise<void>;
|
|
186
|
+
get<TResponse>(path: string, init?: ExtendedRequestInit): Promise<TResponse>;
|
|
187
|
+
post<TPayload, TResponse>(path: string, body: TPayload, init?: ExtendedRequestInit): Promise<TResponse>;
|
|
188
|
+
patch<TPayload, TResponse>(path: string, body: TPayload, init?: ExtendedRequestInit): Promise<TResponse>;
|
|
189
|
+
put<TPayload, TResponse>(path: string, body: TPayload, init?: ExtendedRequestInit): Promise<TResponse>;
|
|
190
|
+
delete<TResponse>(path: string, init?: ExtendedRequestInit): Promise<TResponse>;
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
type SSEClientOptions = {
|
|
194
|
+
timeout: number;
|
|
195
|
+
};
|
|
196
|
+
declare class SSEClient<TEventMap extends Record<string, (data?: any) => void>> {
|
|
197
|
+
url: string;
|
|
198
|
+
private eventListeners;
|
|
199
|
+
private options;
|
|
200
|
+
private timeoutTimer;
|
|
201
|
+
eventSource: EventSource | undefined;
|
|
202
|
+
constructor(url: string, options?: Partial<SSEClientOptions>);
|
|
203
|
+
private proxyEvent;
|
|
204
|
+
connect(): void;
|
|
205
|
+
disconnect(): void;
|
|
206
|
+
emit(type: keyof TEventMap, eventPayload: any): void;
|
|
207
|
+
on(type: keyof TEventMap, handler: any): () => void;
|
|
208
|
+
off(type: keyof TEventMap, handler: any): void;
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
declare namespace Server$1 {
|
|
212
|
+
interface CustomMessageReplyOption {
|
|
213
|
+
title: string;
|
|
214
|
+
payload: string;
|
|
215
|
+
}
|
|
216
|
+
interface CustomMessage {
|
|
217
|
+
text: string;
|
|
218
|
+
reply_options?: CustomMessageReplyOption[];
|
|
219
|
+
}
|
|
220
|
+
interface CustomMessagesResponse {
|
|
221
|
+
suggestions: CustomMessage[];
|
|
222
|
+
}
|
|
223
|
+
declare enum AutoflowSessionState {
|
|
224
|
+
Started = "Started",
|
|
225
|
+
Aborted = "Aborted",
|
|
226
|
+
Completed = "Completed"
|
|
227
|
+
}
|
|
228
|
+
interface Autoflow {
|
|
229
|
+
description?: string;
|
|
230
|
+
display_name?: string;
|
|
231
|
+
trigger_payload?: string;
|
|
232
|
+
state: AutoflowSessionState | null;
|
|
233
|
+
}
|
|
234
|
+
interface AutoflowsResponse {
|
|
235
|
+
autoflows: Autoflow[];
|
|
236
|
+
}
|
|
237
|
+
interface AutoflowSessionPayload {
|
|
238
|
+
platform_session_id: string;
|
|
239
|
+
trigger_payload: string;
|
|
240
|
+
}
|
|
241
|
+
interface AutoflowSession {
|
|
242
|
+
id: string;
|
|
243
|
+
platform_session_id: string;
|
|
244
|
+
session_type: string;
|
|
245
|
+
state: AutoflowSessionState;
|
|
246
|
+
data: {
|
|
247
|
+
trigger_payload: string;
|
|
248
|
+
'trigger-payload': string;
|
|
249
|
+
};
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
type EventMap = {
|
|
253
|
+
customMessageSuggestion: (data: CamelCaseKeys<Server$1.CustomMessage>) => void;
|
|
254
|
+
sessionAborted: (data: {
|
|
255
|
+
id: string;
|
|
256
|
+
}) => void;
|
|
257
|
+
sessionCompleted: (data: {
|
|
258
|
+
id: string;
|
|
259
|
+
}) => void;
|
|
260
|
+
};
|
|
261
|
+
declare class DeepdeskBrokerAPI {
|
|
262
|
+
apiUrl: string;
|
|
263
|
+
client: HTTPClient;
|
|
264
|
+
streams: Record<string, SSEClient<EventMap>>;
|
|
265
|
+
logger: Logger;
|
|
266
|
+
constructor(apiUrl: string, options?: HTTPClientOptions);
|
|
267
|
+
getCustomMessages(platformSessionId: string): Promise<CamelCaseKeys<Server$1.CustomMessage[]>>;
|
|
268
|
+
sendCustomMessage(platformSessionId: string, suggestion: CamelCaseKeys<Server$1.CustomMessage>): Promise<CamelCaseKeys<Server$1.CustomMessage>>;
|
|
269
|
+
answerCustomMessage(platformSessionId: string, reply: CamelCaseKeys<Server$1.CustomMessageReplyOption>): Promise<void>;
|
|
270
|
+
getAutoflows(platformSessionId: string): Promise<CamelCaseKeys<Server$1.Autoflow[]>>;
|
|
271
|
+
startAutoflowSession(autoflowSession: CamelCaseKeys<Server$1.AutoflowSessionPayload>): Promise<CamelCaseKeys<Server$1.AutoflowSession>>;
|
|
272
|
+
stopAutoflowSession(platformSessionId: string): Promise<void>;
|
|
273
|
+
openStream(platformSessionId: string): SSEClient<EventMap>;
|
|
274
|
+
closeStream(platformSessionId: string): void;
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
interface StoreConfig {
|
|
278
|
+
deepdeskAPI: DeepdeskAPI;
|
|
279
|
+
deepdeskBrokerAPI?: DeepdeskBrokerAPI;
|
|
280
|
+
dynamicThunkObject?: Record<string, unknown>;
|
|
281
|
+
middleware?: Middleware[];
|
|
282
|
+
preloadedState?: any;
|
|
283
|
+
}
|
|
284
|
+
declare function createStore(config: StoreConfig): _reduxjs_toolkit_dist_configureStore.ToolkitStore<redux.EmptyObject & {
|
|
285
|
+
activeSuggestion: State$e;
|
|
286
|
+
answer: State$6;
|
|
287
|
+
auth: State$d;
|
|
288
|
+
autoflows: State$c;
|
|
289
|
+
conversation: State$b;
|
|
290
|
+
contentTypes: State$a;
|
|
291
|
+
customMessages: State$9;
|
|
292
|
+
exchangeToken: State$8;
|
|
293
|
+
entities: State$7;
|
|
294
|
+
handlingTime: State$f;
|
|
295
|
+
info: {
|
|
296
|
+
agentInfo?: AgentInfo | undefined;
|
|
297
|
+
agentSettings: unknown;
|
|
298
|
+
visitorInfo?: VisitorInfo | undefined;
|
|
299
|
+
fetchState: FetchState;
|
|
300
|
+
};
|
|
301
|
+
input: State$5;
|
|
302
|
+
overlayInput: State$5;
|
|
303
|
+
settings: {
|
|
304
|
+
locale: Locale;
|
|
305
|
+
deanonymize: boolean;
|
|
306
|
+
fallbackImage: string | false;
|
|
307
|
+
isEmbedded: boolean;
|
|
308
|
+
showAutoflows: number | boolean;
|
|
309
|
+
showCustomMessages: number | boolean;
|
|
310
|
+
showImages: boolean;
|
|
311
|
+
showPersonalCollectionLink: boolean;
|
|
312
|
+
showSearch: boolean;
|
|
313
|
+
showImageSearch: boolean;
|
|
314
|
+
showStyleSuggestions: number | boolean;
|
|
315
|
+
showMidSentenceSuggestions: boolean;
|
|
316
|
+
showSuggestionsBeforePattern: string | false;
|
|
317
|
+
showSuggestionsAfterPattern: string | false;
|
|
318
|
+
showTabCompletion: boolean;
|
|
319
|
+
showTextSuggestions: boolean;
|
|
320
|
+
showEntitiesCommand: boolean;
|
|
321
|
+
showSummaryCommand: boolean;
|
|
322
|
+
showKnowledgeSearch: boolean;
|
|
323
|
+
textSuggestionsCount: number;
|
|
324
|
+
recommendTextSuggestions: boolean;
|
|
325
|
+
searchTriggerKey: string;
|
|
326
|
+
visible: boolean;
|
|
327
|
+
insertLink: boolean;
|
|
328
|
+
inlineSuggestions: boolean;
|
|
329
|
+
adminUrl?: string | undefined;
|
|
330
|
+
};
|
|
331
|
+
profile: State$4;
|
|
332
|
+
search: State$3;
|
|
333
|
+
summary: State$2;
|
|
334
|
+
styleSuggestions: State$1;
|
|
335
|
+
ui: {
|
|
336
|
+
showTabHint: boolean;
|
|
337
|
+
inputHasFocus: boolean;
|
|
338
|
+
overlayCollapsed: boolean;
|
|
339
|
+
openOverlayWhenTyping: boolean;
|
|
340
|
+
overlayCollapsedUserOverwrite: boolean;
|
|
341
|
+
};
|
|
342
|
+
textSuggestions: TextSuggestionState;
|
|
343
|
+
}, redux.AnyAction, _reduxjs_toolkit.ThunkMiddleware<redux.CombinedState<{
|
|
344
|
+
activeSuggestion: State$e;
|
|
345
|
+
answer: State$6;
|
|
346
|
+
auth: State$d;
|
|
347
|
+
autoflows: State$c;
|
|
348
|
+
conversation: State$b;
|
|
349
|
+
contentTypes: State$a;
|
|
350
|
+
customMessages: State$9;
|
|
351
|
+
exchangeToken: State$8;
|
|
352
|
+
entities: State$7;
|
|
353
|
+
handlingTime: State$f;
|
|
354
|
+
info: {
|
|
355
|
+
agentInfo?: AgentInfo | undefined;
|
|
356
|
+
agentSettings: unknown;
|
|
357
|
+
visitorInfo?: VisitorInfo | undefined;
|
|
358
|
+
fetchState: FetchState;
|
|
359
|
+
};
|
|
360
|
+
input: State$5;
|
|
361
|
+
overlayInput: State$5;
|
|
362
|
+
settings: {
|
|
363
|
+
locale: Locale;
|
|
364
|
+
deanonymize: boolean;
|
|
365
|
+
fallbackImage: string | false;
|
|
366
|
+
isEmbedded: boolean;
|
|
367
|
+
showAutoflows: number | boolean;
|
|
368
|
+
showCustomMessages: number | boolean;
|
|
369
|
+
showImages: boolean;
|
|
370
|
+
showPersonalCollectionLink: boolean;
|
|
371
|
+
showSearch: boolean;
|
|
372
|
+
showImageSearch: boolean;
|
|
373
|
+
showStyleSuggestions: number | boolean;
|
|
374
|
+
showMidSentenceSuggestions: boolean;
|
|
375
|
+
showSuggestionsBeforePattern: string | false;
|
|
376
|
+
showSuggestionsAfterPattern: string | false;
|
|
377
|
+
showTabCompletion: boolean;
|
|
378
|
+
showTextSuggestions: boolean;
|
|
379
|
+
showEntitiesCommand: boolean;
|
|
380
|
+
showSummaryCommand: boolean;
|
|
381
|
+
showKnowledgeSearch: boolean;
|
|
382
|
+
textSuggestionsCount: number;
|
|
383
|
+
recommendTextSuggestions: boolean;
|
|
384
|
+
searchTriggerKey: string;
|
|
385
|
+
visible: boolean;
|
|
386
|
+
insertLink: boolean;
|
|
387
|
+
inlineSuggestions: boolean;
|
|
388
|
+
adminUrl?: string | undefined;
|
|
389
|
+
};
|
|
390
|
+
profile: State$4;
|
|
391
|
+
search: State$3;
|
|
392
|
+
summary: State$2;
|
|
393
|
+
styleSuggestions: State$1;
|
|
394
|
+
ui: {
|
|
395
|
+
showTabHint: boolean;
|
|
396
|
+
inputHasFocus: boolean;
|
|
397
|
+
overlayCollapsed: boolean;
|
|
398
|
+
openOverlayWhenTyping: boolean;
|
|
399
|
+
overlayCollapsedUserOverwrite: boolean;
|
|
400
|
+
};
|
|
401
|
+
textSuggestions: TextSuggestionState;
|
|
402
|
+
}>, redux.AnyAction, {
|
|
403
|
+
dynamicThunkObject: Record<string, unknown> | undefined;
|
|
404
|
+
deepdeskAPI: DeepdeskAPI;
|
|
405
|
+
deepdeskBrokerAPI: DeepdeskBrokerAPI | undefined;
|
|
406
|
+
}>[]>;
|
|
407
|
+
type Store = ReturnType<typeof createStore>;
|
|
408
|
+
|
|
409
|
+
interface State$d {
|
|
410
|
+
isLoggedIn: boolean | null;
|
|
411
|
+
loginFetchState: FetchState;
|
|
412
|
+
verifyFetchState: FetchState;
|
|
413
|
+
showLoginOverlay: boolean;
|
|
414
|
+
}
|
|
415
|
+
|
|
416
|
+
type Autoflow = CamelCaseKeys<Server$1.Autoflow> & {
|
|
417
|
+
isBusy?: boolean;
|
|
418
|
+
};
|
|
419
|
+
interface State$c {
|
|
420
|
+
list: Autoflow[];
|
|
421
|
+
fetchState: FetchState;
|
|
422
|
+
isInitialRequest: null | boolean;
|
|
423
|
+
}
|
|
424
|
+
|
|
425
|
+
interface State$b {
|
|
426
|
+
current: Conversation | null;
|
|
427
|
+
isSupported: boolean | null;
|
|
428
|
+
}
|
|
429
|
+
|
|
430
|
+
type ContentType = CamelCaseKeys<Server.ContentType>;
|
|
431
|
+
type State$a = {
|
|
432
|
+
data: ContentType[] | null;
|
|
433
|
+
fetchState: FetchState;
|
|
434
|
+
};
|
|
435
|
+
|
|
436
|
+
type CustomMessage = CamelCaseKeys<Server$1.CustomMessage>;
|
|
437
|
+
interface State$9 {
|
|
438
|
+
list: CustomMessage[];
|
|
439
|
+
fetchState: FetchState;
|
|
440
|
+
isInitialRequest: null | boolean;
|
|
441
|
+
sentSuggestions: string[];
|
|
442
|
+
errorSuggestions: string[];
|
|
443
|
+
answeredSuggestions: string[];
|
|
444
|
+
}
|
|
445
|
+
|
|
446
|
+
type State$8 = {
|
|
447
|
+
jwt: string | null;
|
|
448
|
+
accountUrl: string | null;
|
|
449
|
+
interval: NodeJS.Timer | null;
|
|
450
|
+
};
|
|
451
|
+
|
|
452
|
+
type State$7 = {
|
|
453
|
+
data: Entity[] | null;
|
|
454
|
+
fetchState: FetchState;
|
|
455
|
+
};
|
|
456
|
+
|
|
457
|
+
interface ListItemSource {
|
|
458
|
+
url?: string;
|
|
459
|
+
name: string;
|
|
460
|
+
}
|
|
461
|
+
|
|
462
|
+
interface KnowledgeAnswer {
|
|
463
|
+
answer: string;
|
|
464
|
+
timestamp: string;
|
|
465
|
+
sources: ListItemSource[];
|
|
466
|
+
}
|
|
467
|
+
interface KnowledgeRequest {
|
|
468
|
+
question: string;
|
|
469
|
+
answer: KnowledgeAnswer;
|
|
470
|
+
}
|
|
471
|
+
type State$6 = {
|
|
472
|
+
data: KnowledgeRequest[];
|
|
473
|
+
fetchState: FetchState;
|
|
474
|
+
};
|
|
475
|
+
|
|
476
|
+
declare namespace Server {
|
|
477
|
+
/**
|
|
478
|
+
* API create conversation payload
|
|
479
|
+
*/
|
|
480
|
+
type CreateConversationPayload = {
|
|
481
|
+
platform: string;
|
|
482
|
+
session_id: string;
|
|
483
|
+
agent_id: string;
|
|
484
|
+
profile_code?: string;
|
|
485
|
+
tags?: Record<string, string> | null;
|
|
486
|
+
agent_name?: string;
|
|
487
|
+
agent_nickname?: string;
|
|
488
|
+
agent_email?: string;
|
|
489
|
+
};
|
|
490
|
+
/**
|
|
491
|
+
* API message object
|
|
492
|
+
*/
|
|
493
|
+
type ConversationMessage = {
|
|
494
|
+
id: string;
|
|
495
|
+
time: string;
|
|
496
|
+
source: 'agent' | 'visitor' | 'bot' | 'system';
|
|
497
|
+
author_id: string;
|
|
498
|
+
author_name?: string;
|
|
499
|
+
author_email?: string;
|
|
500
|
+
text: string;
|
|
501
|
+
tags: Record<string, string> | null;
|
|
502
|
+
};
|
|
503
|
+
/**
|
|
504
|
+
* API conversation object
|
|
505
|
+
*/
|
|
506
|
+
type Conversation = {
|
|
507
|
+
id: string;
|
|
508
|
+
profile_code: string | null;
|
|
509
|
+
channel: string | null;
|
|
510
|
+
platform: string;
|
|
511
|
+
agent_id: string;
|
|
512
|
+
agent_name: string | null;
|
|
513
|
+
agent_nickname: string | null;
|
|
514
|
+
agent_email: string | null;
|
|
515
|
+
agent_role: string | null;
|
|
516
|
+
engagement_type: string | null;
|
|
517
|
+
engagement_id: string | null;
|
|
518
|
+
engagement_name: string | null;
|
|
519
|
+
engagement_skill: string | null;
|
|
520
|
+
agent_note: string | null;
|
|
521
|
+
survey_email: string | null;
|
|
522
|
+
survey_name: string | null;
|
|
523
|
+
survey_phone: string | null;
|
|
524
|
+
visitor_id: string | null;
|
|
525
|
+
visitor_name: string | null;
|
|
526
|
+
visitor_device: string | null;
|
|
527
|
+
visitor_browser: string | null;
|
|
528
|
+
visitor_os: string | null;
|
|
529
|
+
visitor_country: string | null;
|
|
530
|
+
visitor_state: string | null;
|
|
531
|
+
visitor_city: string | null;
|
|
532
|
+
visitor_isp: string | null;
|
|
533
|
+
visitor_organization: string | null;
|
|
534
|
+
visitor_ip_address: string | null;
|
|
535
|
+
chat_start_time: number | null;
|
|
536
|
+
session_start_time: number | null;
|
|
537
|
+
visit_start_time: string | null;
|
|
538
|
+
session_id: string;
|
|
539
|
+
messages: ConversationMessage[];
|
|
540
|
+
tags: Record<string, string> | null;
|
|
541
|
+
has_active_profile: boolean;
|
|
542
|
+
created: string;
|
|
543
|
+
updated: string;
|
|
544
|
+
};
|
|
545
|
+
/**
|
|
546
|
+
* API object for url suggestion
|
|
547
|
+
*/
|
|
548
|
+
type UrlSuggestion = {
|
|
549
|
+
id?: string;
|
|
550
|
+
score: number;
|
|
551
|
+
url: string;
|
|
552
|
+
context?: string;
|
|
553
|
+
image: string;
|
|
554
|
+
summary?: string;
|
|
555
|
+
title?: string;
|
|
556
|
+
image_sizes?: {
|
|
557
|
+
small: string;
|
|
558
|
+
medium: string;
|
|
559
|
+
large: string;
|
|
560
|
+
};
|
|
561
|
+
};
|
|
562
|
+
/**
|
|
563
|
+
* API object for platform config
|
|
564
|
+
*/
|
|
565
|
+
type PlatformConfig = {
|
|
566
|
+
config: {
|
|
567
|
+
account: {
|
|
568
|
+
code: string;
|
|
569
|
+
name: string;
|
|
570
|
+
url: string;
|
|
571
|
+
is_trial: boolean;
|
|
572
|
+
};
|
|
573
|
+
platform: {
|
|
574
|
+
name: string;
|
|
575
|
+
url: string;
|
|
576
|
+
has_sso: boolean;
|
|
577
|
+
authorization_url: string;
|
|
578
|
+
client_config: unknown;
|
|
579
|
+
};
|
|
580
|
+
};
|
|
581
|
+
};
|
|
582
|
+
/**
|
|
583
|
+
* API object for free suggestion
|
|
584
|
+
*/
|
|
585
|
+
type RecommendFreeSuggestion = {
|
|
586
|
+
score?: number;
|
|
587
|
+
title?: string;
|
|
588
|
+
text: string;
|
|
589
|
+
message?: string;
|
|
590
|
+
url?: string;
|
|
591
|
+
ab_variant?: string;
|
|
592
|
+
ab_test_name?: string;
|
|
593
|
+
training_jobs?: string[];
|
|
594
|
+
source_text: string;
|
|
595
|
+
};
|
|
596
|
+
type ContentType = {
|
|
597
|
+
id: number;
|
|
598
|
+
code: string;
|
|
599
|
+
name: string;
|
|
600
|
+
description: string;
|
|
601
|
+
};
|
|
602
|
+
/**
|
|
603
|
+
* API object for autocomplete suggestion
|
|
604
|
+
*/
|
|
605
|
+
type AutocompleteSuggestion = {
|
|
606
|
+
label: string;
|
|
607
|
+
source: string;
|
|
608
|
+
value: string;
|
|
609
|
+
training_jobs: string[];
|
|
610
|
+
source_text: string;
|
|
611
|
+
search_keywords?: string[];
|
|
612
|
+
};
|
|
613
|
+
/**
|
|
614
|
+
* API object for pinned message
|
|
615
|
+
*/
|
|
616
|
+
type PinnedMessage = {
|
|
617
|
+
message: string;
|
|
618
|
+
title: string;
|
|
619
|
+
image: string;
|
|
620
|
+
image_sizes?: {
|
|
621
|
+
small: string;
|
|
622
|
+
medium: string;
|
|
623
|
+
large: string;
|
|
624
|
+
};
|
|
625
|
+
};
|
|
626
|
+
/**
|
|
627
|
+
* API object for style suggestions
|
|
628
|
+
*/
|
|
629
|
+
type StyleSuggestion = {
|
|
630
|
+
keyword_matches: {
|
|
631
|
+
keyword: string;
|
|
632
|
+
suggestion: string;
|
|
633
|
+
}[];
|
|
634
|
+
};
|
|
635
|
+
declare enum EventType {
|
|
636
|
+
SEND_MESSAGE = "Send Message",
|
|
637
|
+
HANDLING_TIME = "Handling Time",
|
|
638
|
+
START_AUTOFLOW = "Start Autoflow",
|
|
639
|
+
ABORT_AUTOFLOW = "Abort Autoflow",
|
|
640
|
+
ADD_TO_PERSONAL_COLLECTION = "Add to personal collection",
|
|
641
|
+
DELETE_FROM_PERSONAL_COLLECTION = "Delete from personal collection"
|
|
642
|
+
}
|
|
643
|
+
type UsedSuggestion = {
|
|
644
|
+
ab_test_name?: string | null;
|
|
645
|
+
ab_variant?: string | null;
|
|
646
|
+
input_type: string;
|
|
647
|
+
source?: string;
|
|
648
|
+
source_text?: string;
|
|
649
|
+
text: string;
|
|
650
|
+
training_jobs?: string[];
|
|
651
|
+
};
|
|
652
|
+
/**
|
|
653
|
+
* Abstract API object for event data
|
|
654
|
+
* @deprecated in favor of EventDataV2
|
|
655
|
+
* @see EventV2Data
|
|
656
|
+
*/
|
|
657
|
+
type EventData = {
|
|
658
|
+
conversation_id: string;
|
|
659
|
+
client_version: string;
|
|
660
|
+
source: 'agent' | 'visitor';
|
|
661
|
+
pastes: string[];
|
|
662
|
+
cuts: string[];
|
|
663
|
+
deletions: string[];
|
|
664
|
+
len_text_typed: number;
|
|
665
|
+
len_text_total: number;
|
|
666
|
+
len_text_assisted: number;
|
|
667
|
+
len_text_pasted: number;
|
|
668
|
+
len_text_cut: number;
|
|
669
|
+
len_text_deleted: number;
|
|
670
|
+
time_total_seconds: number;
|
|
671
|
+
chars_per_second: number;
|
|
672
|
+
text: string;
|
|
673
|
+
num_pastes: number;
|
|
674
|
+
text_suggestions_v2: UsedSuggestion[];
|
|
675
|
+
url_suggestions_v2: UsedSuggestion[];
|
|
676
|
+
url_link_suggestions_v2: UsedSuggestion[];
|
|
677
|
+
suggestions_counters: {
|
|
678
|
+
source: Sources;
|
|
679
|
+
count_offered: number;
|
|
680
|
+
}[];
|
|
681
|
+
time_start: string;
|
|
682
|
+
time_stop: string;
|
|
683
|
+
agent_id?: string;
|
|
684
|
+
agent_name?: string;
|
|
685
|
+
agent_email?: string;
|
|
686
|
+
platform: string;
|
|
687
|
+
backend_version: string;
|
|
688
|
+
engine_version: string;
|
|
689
|
+
gpt_version: string;
|
|
690
|
+
};
|
|
691
|
+
/**
|
|
692
|
+
* Backend API object for event data v2
|
|
693
|
+
*/
|
|
694
|
+
type EventV2Data = {
|
|
695
|
+
name: string;
|
|
696
|
+
conversation_id?: string;
|
|
697
|
+
agent_id?: string;
|
|
698
|
+
agent_name?: string;
|
|
699
|
+
agent_email?: string;
|
|
700
|
+
data: unknown;
|
|
701
|
+
backend_version?: string;
|
|
702
|
+
engine_version?: string;
|
|
703
|
+
gpt_version?: string;
|
|
704
|
+
};
|
|
705
|
+
interface GetTextSuggestionsParams {
|
|
706
|
+
timezone?: string;
|
|
707
|
+
agent_name?: string;
|
|
708
|
+
visitor_name?: string;
|
|
709
|
+
}
|
|
710
|
+
interface GetAutocompleteSuggestionsParams extends GetTextSuggestionsParams {
|
|
711
|
+
input: string;
|
|
712
|
+
}
|
|
713
|
+
interface GetStyleSuggestionsParams {
|
|
714
|
+
message: string;
|
|
715
|
+
profile_code: string;
|
|
716
|
+
}
|
|
717
|
+
/**
|
|
718
|
+
* Handling time event data
|
|
719
|
+
*/
|
|
720
|
+
type HandlingTimeEventData = Pick<EventData, 'conversation_id' | 'client_version' | 'time_start' | 'time_stop'> & Partial<Pick<EventData, 'agent_id' | 'agent_name' | 'agent_email'>>;
|
|
721
|
+
/**
|
|
722
|
+
* Send message event data
|
|
723
|
+
*/
|
|
724
|
+
type SendMessageEventData = Pick<EventData, 'client_version' | 'conversation_id' | 'source' | 'pastes' | 'cuts' | 'deletions' | 'len_text_typed' | 'len_text_total' | 'len_text_assisted' | 'len_text_pasted' | 'len_text_cut' | 'len_text_deleted' | 'time_total_seconds' | 'chars_per_second' | 'num_pastes' | 'text' | 'text_suggestions_v2' | 'suggestions_counters'> & Partial<Pick<EventData, 'agent_id' | 'agent_name' | 'agent_email'>>;
|
|
725
|
+
/**
|
|
726
|
+
* Autoflow event data
|
|
727
|
+
*/
|
|
728
|
+
type AutoflowEventData = Pick<EventData, 'conversation_id' | 'source'> & {
|
|
729
|
+
text_suggestions_v2: {
|
|
730
|
+
source: string;
|
|
731
|
+
}[];
|
|
732
|
+
};
|
|
733
|
+
/**
|
|
734
|
+
* PersonalCollection event data
|
|
735
|
+
*/
|
|
736
|
+
type PersonalCollectionEventData = Pick<EventData, 'text' | 'platform'>;
|
|
737
|
+
/**
|
|
738
|
+
* Search results data
|
|
739
|
+
*/
|
|
740
|
+
interface SearchResult {
|
|
741
|
+
id: string;
|
|
742
|
+
image: string;
|
|
743
|
+
labels: string;
|
|
744
|
+
status: string;
|
|
745
|
+
text: string;
|
|
746
|
+
title?: string;
|
|
747
|
+
type: SearchResultType;
|
|
748
|
+
}
|
|
749
|
+
type SearchResultsData = {
|
|
750
|
+
results: SearchResult[];
|
|
751
|
+
};
|
|
752
|
+
/**
|
|
753
|
+
* Me
|
|
754
|
+
*/
|
|
755
|
+
type Me = {
|
|
756
|
+
user_email: string;
|
|
757
|
+
user_name: string;
|
|
758
|
+
};
|
|
759
|
+
/**
|
|
760
|
+
* A Deepdesk user
|
|
761
|
+
*/
|
|
762
|
+
type User = {
|
|
763
|
+
username: string;
|
|
764
|
+
external_id: string;
|
|
765
|
+
email?: string;
|
|
766
|
+
nickname?: string;
|
|
767
|
+
first_name?: string;
|
|
768
|
+
last_name?: string;
|
|
769
|
+
};
|
|
770
|
+
/**
|
|
771
|
+
* Profile
|
|
772
|
+
*/
|
|
773
|
+
type Profile = {
|
|
774
|
+
code: string;
|
|
775
|
+
name: string;
|
|
776
|
+
search: boolean;
|
|
777
|
+
image_search: boolean;
|
|
778
|
+
sticky_messages: boolean;
|
|
779
|
+
custom_messages: boolean;
|
|
780
|
+
autoflows: boolean;
|
|
781
|
+
recommend_text_suggestions: boolean;
|
|
782
|
+
assisted_intake: boolean;
|
|
783
|
+
autocomplete_with_text_suggestions: boolean;
|
|
784
|
+
entities_command: boolean;
|
|
785
|
+
summarizer: boolean;
|
|
786
|
+
knowledge_search: boolean;
|
|
787
|
+
ui_config: {
|
|
788
|
+
widget: {
|
|
789
|
+
types: Array<{
|
|
790
|
+
is_active: boolean;
|
|
791
|
+
type: string;
|
|
792
|
+
title: string;
|
|
793
|
+
amount: number;
|
|
794
|
+
lines: 'multiple' | 'single';
|
|
795
|
+
}>;
|
|
796
|
+
};
|
|
797
|
+
};
|
|
798
|
+
};
|
|
799
|
+
type ChatHistory = {
|
|
800
|
+
question: string;
|
|
801
|
+
answer: string;
|
|
802
|
+
timestamp: string;
|
|
803
|
+
};
|
|
804
|
+
}
|
|
805
|
+
type ConversationMessage = CamelCaseKeys<Omit<Server.ConversationMessage, 'tags'>> & {
|
|
806
|
+
tags: Record<string, string> | null;
|
|
807
|
+
};
|
|
808
|
+
type Conversation = CamelCaseKeys<Omit<Server.Conversation, 'tags' | 'messages'>> & {
|
|
809
|
+
tags: Record<string, string> | null;
|
|
810
|
+
} & {
|
|
811
|
+
messages: ConversationMessage[];
|
|
812
|
+
};
|
|
813
|
+
/**
|
|
814
|
+
* Create Conversation Options
|
|
815
|
+
*/
|
|
816
|
+
type CreateConversationOptions = {
|
|
817
|
+
/**
|
|
818
|
+
* The platform's conversation ID.
|
|
819
|
+
*/
|
|
820
|
+
sessionId: string;
|
|
821
|
+
/**
|
|
822
|
+
* The agent ID
|
|
823
|
+
*/
|
|
824
|
+
agentId: string;
|
|
825
|
+
/**
|
|
826
|
+
* The messaging platform, e.g. 'liveengage'
|
|
827
|
+
*/
|
|
828
|
+
platform: string;
|
|
829
|
+
/**
|
|
830
|
+
* The client profile code, e.g. 'b2b' or 'b2c'
|
|
831
|
+
*/
|
|
832
|
+
profileCode?: string;
|
|
833
|
+
tags?: Record<string, string> | null;
|
|
834
|
+
agentName?: string;
|
|
835
|
+
agentNickname?: string;
|
|
836
|
+
agentEmail?: string;
|
|
837
|
+
};
|
|
838
|
+
/**
|
|
839
|
+
* Send message event data
|
|
840
|
+
*/
|
|
841
|
+
type SendMessageEventData$1 = CamelCaseKeys<Server.SendMessageEventData>;
|
|
842
|
+
/**
|
|
843
|
+
* Event v2 payload
|
|
844
|
+
*/
|
|
845
|
+
type EventV2Payload = CamelCaseKeys<Omit<Server.EventV2Data, 'name' | 'backend_version' | 'engine_version' | 'gpt_version'>>;
|
|
846
|
+
/**
|
|
847
|
+
* Handling time event data
|
|
848
|
+
*/
|
|
849
|
+
type HandlingTimeEventData = CamelCaseKeys<Pick<Server.HandlingTimeEventData, 'conversation_id' | 'client_version' | 'time_start' | 'time_stop'>>;
|
|
850
|
+
/**
|
|
851
|
+
* Autoflow event data
|
|
852
|
+
*/
|
|
853
|
+
type AutoflowEventData = CamelCaseKeys<Server.AutoflowEventData>;
|
|
854
|
+
/**
|
|
855
|
+
* Personal collection event data
|
|
856
|
+
*/
|
|
857
|
+
type PersonalCollectionEventData = CamelCaseKeys<Server.PersonalCollectionEventData>;
|
|
858
|
+
/**
|
|
859
|
+
* Send event arguments helper
|
|
860
|
+
*/
|
|
861
|
+
type SendEventArgumentMap = {
|
|
862
|
+
'Send Message': SendMessageEventData$1;
|
|
863
|
+
'Handling Time': HandlingTimeEventData;
|
|
864
|
+
'Start Autoflow': AutoflowEventData;
|
|
865
|
+
'Abort Autoflow': AutoflowEventData;
|
|
866
|
+
'Add to personal collection': PersonalCollectionEventData;
|
|
867
|
+
'Delete from personal collection': PersonalCollectionEventData;
|
|
868
|
+
'entities found': EventV2Payload;
|
|
869
|
+
'conversation summarized': EventV2Payload;
|
|
870
|
+
'style suggested': EventV2Payload;
|
|
871
|
+
'suggestion edited': EventV2Payload;
|
|
872
|
+
'Image attached': EventV2Payload;
|
|
873
|
+
};
|
|
874
|
+
/**
|
|
875
|
+
* Request retry options
|
|
876
|
+
*/
|
|
877
|
+
type RetryOptions = {
|
|
878
|
+
attempts?: number;
|
|
879
|
+
retryDelay?: number;
|
|
880
|
+
};
|
|
881
|
+
interface SearchOptions {
|
|
882
|
+
filters: {
|
|
883
|
+
type?: SearchResultType;
|
|
884
|
+
};
|
|
885
|
+
query: string;
|
|
886
|
+
profile: string;
|
|
887
|
+
tags?: string[];
|
|
888
|
+
params: {
|
|
889
|
+
agentName?: string;
|
|
890
|
+
visitorName?: string;
|
|
891
|
+
timezone?: string;
|
|
892
|
+
};
|
|
893
|
+
}
|
|
894
|
+
interface DeepdeskAPIOptions extends HTTPClientOptions {
|
|
895
|
+
token?: string;
|
|
896
|
+
}
|
|
897
|
+
declare class DeepdeskAPI {
|
|
898
|
+
options: DeepdeskAPIOptions;
|
|
899
|
+
private latestReceivedDeepdeskVersions;
|
|
900
|
+
client: HTTPClient;
|
|
901
|
+
account: string;
|
|
902
|
+
shouldFetchCsrfToken: boolean;
|
|
903
|
+
static exchangeTokenPromise: Promise<void> | null;
|
|
904
|
+
private preflight;
|
|
905
|
+
constructor(apiUrl: string, options?: DeepdeskAPIOptions);
|
|
906
|
+
createConversation(options: CreateConversationOptions): Promise<CamelCaseKeys<Server.Conversation>>;
|
|
907
|
+
getProfile(profileCode: string): Promise<CamelCaseKeys<Server.Profile>>;
|
|
908
|
+
getContentTypes(): Promise<CamelCaseKeys<Server.ContentType[]>>;
|
|
909
|
+
getPlatformConfig(): Promise<CamelCaseKeys<Server.PlatformConfig['config']>>;
|
|
910
|
+
checkUserExists(externalId: string): Promise<boolean>;
|
|
911
|
+
getConversationBySessionId(sessionId: string, options?: RetryOptions): Promise<CamelCaseKeys<Server.Conversation>>;
|
|
912
|
+
isConversationSupported(sessionId: string, options?: RetryOptions): Promise<boolean>;
|
|
913
|
+
/**
|
|
914
|
+
* Update converstation meta data
|
|
915
|
+
*/
|
|
916
|
+
updateConversation(conversationId: string, data: Partial<Conversation>): Promise<Conversation>;
|
|
917
|
+
/**
|
|
918
|
+
* Post converstation messages
|
|
919
|
+
*/
|
|
920
|
+
postMessages(conversationId: string, messages: CamelCaseKeys<Server.ConversationMessage>[]): Promise<({
|
|
921
|
+
text: string;
|
|
922
|
+
id: string;
|
|
923
|
+
time: string;
|
|
924
|
+
source: "agent" | "visitor" | "bot" | "system";
|
|
925
|
+
authorId: string;
|
|
926
|
+
authorName?: string | undefined;
|
|
927
|
+
authorEmail?: string | undefined;
|
|
928
|
+
} & {
|
|
929
|
+
tags: Record<string, string> | null;
|
|
930
|
+
})[]>;
|
|
931
|
+
/**
|
|
932
|
+
* Send event with meta data for analytics
|
|
933
|
+
*/
|
|
934
|
+
sendEvent<T extends keyof SendEventArgumentMap>(event: T, payload: SendEventArgumentMap[T]): Promise<void>;
|
|
935
|
+
/**
|
|
936
|
+
* Send event with meta data for analytics
|
|
937
|
+
* @deprecated
|
|
938
|
+
*/
|
|
939
|
+
sendEventV1<T extends keyof SendEventArgumentMap>(event: T, payload: SendEventArgumentMap[T]): Promise<void>;
|
|
940
|
+
getEntities(messages: Array<{
|
|
941
|
+
text: string;
|
|
942
|
+
}>): Promise<Entity[]>;
|
|
943
|
+
getSummary(messages: Array<{
|
|
944
|
+
source: string;
|
|
945
|
+
text: string;
|
|
946
|
+
}>): Promise<string>;
|
|
947
|
+
/**
|
|
948
|
+
* Get a temporary exchange / login token
|
|
949
|
+
*/
|
|
950
|
+
getTemporaryExchangeToken(): Promise<string>;
|
|
951
|
+
/**
|
|
952
|
+
* Exchange a temporary token for a access token cookie
|
|
953
|
+
*/
|
|
954
|
+
exchangeTokenForAccessCookie(token: string): Promise<void>;
|
|
955
|
+
authenticateWithKey(key: string, user: CamelCaseKeys<Server.User>): Promise<void>;
|
|
956
|
+
/**
|
|
957
|
+
* Request text suggestions based on the current conversation
|
|
958
|
+
*/
|
|
959
|
+
getTextSuggestions(conversationId: string, params: {
|
|
960
|
+
timezone?: string | undefined;
|
|
961
|
+
agentName?: string | undefined;
|
|
962
|
+
visitorName?: string | undefined;
|
|
963
|
+
} | undefined, contentType: string): Promise<TextSuggestion[]>;
|
|
964
|
+
/**
|
|
965
|
+
* Validate authentication
|
|
966
|
+
*/
|
|
967
|
+
isLoggedIn(): Promise<boolean>;
|
|
968
|
+
/**
|
|
969
|
+
* Request autocomplete suggestions based on the agent text input
|
|
970
|
+
*/
|
|
971
|
+
getAutocompleteSuggestions(conversationId: string, params: CamelCaseKeys<Server.GetAutocompleteSuggestionsParams>): Promise<TextSuggestion[]>;
|
|
972
|
+
/**
|
|
973
|
+
* Request pinned messages
|
|
974
|
+
*/
|
|
975
|
+
getPinnedMessages(conversationId: string): Promise<CamelCaseKeys<Server.PinnedMessage[]>>;
|
|
976
|
+
/**
|
|
977
|
+
* Request style suggestions
|
|
978
|
+
*/
|
|
979
|
+
getStyleSuggestions(params: CamelCaseKeys<Server.GetStyleSuggestionsParams>): Promise<CamelCaseKeys<Server.StyleSuggestion>>;
|
|
980
|
+
/**
|
|
981
|
+
* Search
|
|
982
|
+
*/
|
|
983
|
+
search(params: SearchOptions): Promise<CamelCaseKeys<Server.SearchResultsData>>;
|
|
984
|
+
knowledgeSearch(question: string, chatHistory: KnowledgeRequest[], profile?: string): Promise<CamelCaseKeys<KnowledgeAnswer>>;
|
|
985
|
+
requestLoginByEmail(email: string): Promise<{
|
|
986
|
+
code: string;
|
|
987
|
+
message: string;
|
|
988
|
+
}>;
|
|
989
|
+
getCsrfToken(): Promise<string>;
|
|
990
|
+
verifyLoginToken(token: string): Promise<{
|
|
991
|
+
isLoggedIn: boolean;
|
|
992
|
+
}>;
|
|
993
|
+
private handleDeepdeskVersionHeaders;
|
|
994
|
+
}
|
|
995
|
+
|
|
996
|
+
declare const styles$l: {
|
|
997
|
+
readonly "isDisabled": string;
|
|
998
|
+
readonly "buttonStart": string;
|
|
999
|
+
readonly "root": string;
|
|
1000
|
+
readonly "buttonStop": string;
|
|
1001
|
+
readonly "stateBadge": string;
|
|
1002
|
+
readonly "isCompleted": string;
|
|
1003
|
+
readonly "isStarted": string;
|
|
1004
|
+
readonly "isAborted": string;
|
|
1005
|
+
};
|
|
1006
|
+
|
|
1007
|
+
type AutoflowStyles = typeof styles$l;
|
|
1008
|
+
|
|
1009
|
+
declare const styles$k: {
|
|
1010
|
+
readonly "root": string;
|
|
1011
|
+
readonly "imageWrapper": string;
|
|
1012
|
+
readonly "image": string;
|
|
1013
|
+
readonly "content": string;
|
|
1014
|
+
readonly "title": string;
|
|
1015
|
+
readonly "contentIsCropped": string;
|
|
1016
|
+
readonly "lineClamp": string;
|
|
1017
|
+
};
|
|
1018
|
+
|
|
1019
|
+
type ImageProps = {
|
|
1020
|
+
title?: string;
|
|
1021
|
+
src?: string | null;
|
|
1022
|
+
};
|
|
1023
|
+
type ContentProps = {
|
|
1024
|
+
cropText?: boolean;
|
|
1025
|
+
className?: string;
|
|
1026
|
+
lineClamp?: boolean;
|
|
1027
|
+
};
|
|
1028
|
+
type TitleProps = {
|
|
1029
|
+
cropText?: boolean;
|
|
1030
|
+
className?: string;
|
|
1031
|
+
as?: string;
|
|
1032
|
+
};
|
|
1033
|
+
interface CardComposition {
|
|
1034
|
+
Image: FC<ImageProps>;
|
|
1035
|
+
Content: FC<ContentProps>;
|
|
1036
|
+
Title: FC<TitleProps>;
|
|
1037
|
+
}
|
|
1038
|
+
type CardStyles = typeof styles$k;
|
|
1039
|
+
declare const Card: FC & CardComposition;
|
|
1040
|
+
|
|
1041
|
+
declare const styles$j: {
|
|
1042
|
+
readonly "root": string;
|
|
1043
|
+
readonly "list": string;
|
|
1044
|
+
readonly "listWrapper": string;
|
|
1045
|
+
readonly "listHorizontal": string;
|
|
1046
|
+
readonly "page": string;
|
|
1047
|
+
readonly "search": string;
|
|
1048
|
+
readonly "pageNav": string;
|
|
1049
|
+
readonly "pageBackButton": string;
|
|
1050
|
+
readonly "listHeading": string;
|
|
1051
|
+
readonly "listItem": string;
|
|
1052
|
+
readonly "listItemContent": string;
|
|
1053
|
+
readonly "listItemText": string;
|
|
1054
|
+
readonly "listItemDescription": string;
|
|
1055
|
+
readonly "truncate": string;
|
|
1056
|
+
readonly "lineClamp": string;
|
|
1057
|
+
readonly "listItemTitle": string;
|
|
1058
|
+
readonly "listItemAction": string;
|
|
1059
|
+
readonly "listItemPrimaryAction": string;
|
|
1060
|
+
readonly "listItemSelected": string;
|
|
1061
|
+
readonly "sources": string;
|
|
1062
|
+
readonly "sourcesTitle": string;
|
|
1063
|
+
readonly "source": string;
|
|
1064
|
+
readonly "icon": string;
|
|
1065
|
+
readonly "searchIcon": string;
|
|
1066
|
+
readonly "searchInputWrapper": string;
|
|
1067
|
+
readonly "searchInput": string;
|
|
1068
|
+
readonly "select": string;
|
|
1069
|
+
readonly "selectType": string;
|
|
1070
|
+
readonly "selectWrapper": string;
|
|
1071
|
+
readonly "image": string;
|
|
1072
|
+
readonly "imageSrc": string;
|
|
1073
|
+
readonly "imageTitle": string;
|
|
1074
|
+
readonly "actions": string;
|
|
1075
|
+
readonly "actionsWrapper": string;
|
|
1076
|
+
readonly "actionsBar": string;
|
|
1077
|
+
readonly "actionButton": string;
|
|
1078
|
+
readonly "actionShortcut": string;
|
|
1079
|
+
readonly "actionShortcutFixKerning": string;
|
|
1080
|
+
};
|
|
1081
|
+
|
|
1082
|
+
type CommandPaletteStyles = typeof styles$j;
|
|
1083
|
+
|
|
1084
|
+
declare const styles$i: {
|
|
1085
|
+
readonly "root": string;
|
|
1086
|
+
readonly "content": string;
|
|
1087
|
+
};
|
|
1088
|
+
|
|
1089
|
+
type DialogStyles = typeof styles$i;
|
|
1090
|
+
|
|
1091
|
+
declare const styles$h: {
|
|
1092
|
+
readonly "root": string;
|
|
1093
|
+
readonly "title": string;
|
|
1094
|
+
readonly "empty": string;
|
|
1095
|
+
};
|
|
1096
|
+
|
|
1097
|
+
type EntitiesListStyles = typeof styles$h;
|
|
1098
|
+
|
|
1099
|
+
declare const styles$g: {
|
|
1100
|
+
readonly "root": string;
|
|
1101
|
+
readonly "isArrowUp": string;
|
|
1102
|
+
readonly "isArrowDown": string;
|
|
1103
|
+
readonly "isTab": string;
|
|
1104
|
+
readonly "isEsc": string;
|
|
1105
|
+
readonly "isEnter": string;
|
|
1106
|
+
};
|
|
1107
|
+
|
|
1108
|
+
declare enum KeyboardHintKey {
|
|
1109
|
+
ARROW_UP = "arrow-up",
|
|
1110
|
+
ARROW_DOWN = "arrow-down",
|
|
1111
|
+
TAB = "tab",
|
|
1112
|
+
ESC = "esc",
|
|
1113
|
+
ENTER = "enter"
|
|
1114
|
+
}
|
|
1115
|
+
type Props$7 = HTMLAttributes<HTMLSpanElement> & {
|
|
1116
|
+
className?: string;
|
|
1117
|
+
keyCode: KeyboardHintKey;
|
|
1118
|
+
};
|
|
1119
|
+
type KeyboardHintStyles = typeof styles$g;
|
|
1120
|
+
declare const KeyboardHint: React.FC<Props$7>;
|
|
1121
|
+
|
|
1122
|
+
declare const styles$f: {
|
|
1123
|
+
readonly "root": string;
|
|
1124
|
+
};
|
|
1125
|
+
|
|
1126
|
+
type Props$6 = HTMLAttributes<HTMLSpanElement>;
|
|
1127
|
+
type LabelStyles = typeof styles$f;
|
|
1128
|
+
declare const Label: React.FC<Props$6>;
|
|
1129
|
+
|
|
1130
|
+
declare const styles$e: {
|
|
1131
|
+
readonly "root": string;
|
|
1132
|
+
readonly "content": string;
|
|
1133
|
+
};
|
|
1134
|
+
|
|
1135
|
+
type LinkSearchStyles = typeof styles$e;
|
|
1136
|
+
|
|
1137
|
+
declare const styles$d: {
|
|
1138
|
+
readonly "root": string;
|
|
1139
|
+
readonly "anchor": string;
|
|
1140
|
+
readonly "anchorButton": string;
|
|
1141
|
+
};
|
|
1142
|
+
|
|
1143
|
+
type LoginStyles = typeof styles$d;
|
|
1144
|
+
|
|
1145
|
+
declare const styles$c: {
|
|
1146
|
+
readonly "root": string;
|
|
1147
|
+
readonly "anchorButton": string;
|
|
1148
|
+
readonly "errorMessage": string;
|
|
1149
|
+
readonly "title": string;
|
|
1150
|
+
readonly "subtitle": string;
|
|
1151
|
+
readonly "text": string;
|
|
1152
|
+
readonly "input": string;
|
|
1153
|
+
readonly "actions": string;
|
|
1154
|
+
readonly "button": string;
|
|
1155
|
+
readonly "primaryButton": string;
|
|
1156
|
+
};
|
|
1157
|
+
|
|
1158
|
+
type LoginTokenDialogStyles = typeof styles$c;
|
|
1159
|
+
|
|
1160
|
+
declare const styles$b: {
|
|
1161
|
+
readonly "root": string;
|
|
1162
|
+
readonly "text": string;
|
|
1163
|
+
};
|
|
1164
|
+
|
|
1165
|
+
type SearchTriggerStyles = typeof styles$b;
|
|
1166
|
+
|
|
1167
|
+
declare const styles$a: {
|
|
1168
|
+
readonly "root": string;
|
|
1169
|
+
};
|
|
1170
|
+
|
|
1171
|
+
type Props$5 = {
|
|
1172
|
+
className?: string;
|
|
1173
|
+
children?: React.ReactNode;
|
|
1174
|
+
};
|
|
1175
|
+
type SectionListStyles = typeof styles$a;
|
|
1176
|
+
declare const SectionList: React.ForwardRefExoticComponent<Props$5 & React.RefAttributes<HTMLDivElement>>;
|
|
1177
|
+
|
|
1178
|
+
declare const styles$9: {
|
|
1179
|
+
readonly "root": string;
|
|
1180
|
+
readonly "subTitleContainer": string;
|
|
1181
|
+
readonly "subtitle": string;
|
|
1182
|
+
readonly "suggestions": string;
|
|
1183
|
+
};
|
|
1184
|
+
|
|
1185
|
+
type Props$4 = HTMLAttributes<HTMLElement> & {
|
|
1186
|
+
title?: string;
|
|
1187
|
+
};
|
|
1188
|
+
type SectionStyles = typeof styles$9;
|
|
1189
|
+
declare const Section: React.FC<Props$4>;
|
|
1190
|
+
|
|
1191
|
+
declare const styles$8: {
|
|
1192
|
+
readonly "root": string;
|
|
1193
|
+
readonly "isWithDivider": string;
|
|
1194
|
+
};
|
|
1195
|
+
|
|
1196
|
+
type SuggestionListStyles = typeof styles$8;
|
|
1197
|
+
interface Props$3 {
|
|
1198
|
+
withDivider?: boolean;
|
|
1199
|
+
}
|
|
1200
|
+
declare const SuggestionList: React.FC<Props$3>;
|
|
1201
|
+
|
|
1202
|
+
declare const styles$7: {
|
|
1203
|
+
readonly "root": string;
|
|
1204
|
+
readonly "isInline": string;
|
|
1205
|
+
readonly "toggleButton": string;
|
|
1206
|
+
readonly "toggleButtonWrapper": string;
|
|
1207
|
+
readonly "toggleButtonWrapperHidden": string;
|
|
1208
|
+
readonly "isCollapsed": string;
|
|
1209
|
+
readonly "collapsible": string;
|
|
1210
|
+
readonly "hints": string;
|
|
1211
|
+
readonly "hintsHidden": string;
|
|
1212
|
+
readonly "triggers": string;
|
|
1213
|
+
readonly "triggersRight": string;
|
|
1214
|
+
};
|
|
1215
|
+
|
|
1216
|
+
type SuggestionsOverlayStyles = typeof styles$7;
|
|
1217
|
+
|
|
1218
|
+
declare const styles$6: {
|
|
1219
|
+
readonly "root": string;
|
|
1220
|
+
readonly "fadein": string;
|
|
1221
|
+
readonly "isClickable": string;
|
|
1222
|
+
readonly "isSelected": string;
|
|
1223
|
+
readonly "actions": string;
|
|
1224
|
+
readonly "actionsIsFixed": string;
|
|
1225
|
+
readonly "actionButton": string;
|
|
1226
|
+
readonly "dropdownList": string;
|
|
1227
|
+
readonly "dropdownButton": string;
|
|
1228
|
+
readonly "dropdownItem": string;
|
|
1229
|
+
readonly "dropdownItemButton": string;
|
|
1230
|
+
readonly "actionButtonIsPrimary": string;
|
|
1231
|
+
readonly "actionButtonIsDisabled": string;
|
|
1232
|
+
readonly "labels": string;
|
|
1233
|
+
readonly "label": string;
|
|
1234
|
+
};
|
|
1235
|
+
|
|
1236
|
+
interface ActionsProps extends HTMLAttributes<HTMLElement> {
|
|
1237
|
+
fixed?: boolean;
|
|
1238
|
+
}
|
|
1239
|
+
interface ActionButtonProps extends HTMLAttributes<HTMLElement> {
|
|
1240
|
+
primary?: boolean;
|
|
1241
|
+
disabled?: boolean;
|
|
1242
|
+
label: ReactNode;
|
|
1243
|
+
}
|
|
1244
|
+
interface DropdownItemProps extends HTMLAttributes<HTMLElement> {
|
|
1245
|
+
index: number;
|
|
1246
|
+
label: ReactNode;
|
|
1247
|
+
onClick?(event: SyntheticEvent<any>): void;
|
|
1248
|
+
}
|
|
1249
|
+
interface LabelProps {
|
|
1250
|
+
labels: string[];
|
|
1251
|
+
}
|
|
1252
|
+
type Props$2 = HTMLAttributes<HTMLElement> & {
|
|
1253
|
+
selected?: boolean;
|
|
1254
|
+
as?: 'div' | 'button';
|
|
1255
|
+
};
|
|
1256
|
+
interface SuggestionComposition {
|
|
1257
|
+
Actions: FC<ActionsProps>;
|
|
1258
|
+
ActionButton: FC<ActionButtonProps>;
|
|
1259
|
+
DropdownButton: FC<ActionButtonProps>;
|
|
1260
|
+
DropdownItem: FC<DropdownItemProps>;
|
|
1261
|
+
Labels: FC<LabelProps>;
|
|
1262
|
+
}
|
|
1263
|
+
type SuggestionStyles = typeof styles$6;
|
|
1264
|
+
declare const Suggestion: ForwardRefExoticComponent<Props$2 & RefAttributes<any>> & SuggestionComposition;
|
|
1265
|
+
|
|
1266
|
+
declare const styles$5: {
|
|
1267
|
+
readonly "root": string;
|
|
1268
|
+
readonly "agentText": string;
|
|
1269
|
+
readonly "tabText": string;
|
|
1270
|
+
readonly "hint": string;
|
|
1271
|
+
readonly "matchSelection": string;
|
|
1272
|
+
readonly "focus": string;
|
|
1273
|
+
readonly "resetIndent": string;
|
|
1274
|
+
readonly "matchKeyword": string;
|
|
1275
|
+
readonly "matchPlaceholder": string;
|
|
1276
|
+
readonly "hover": string;
|
|
1277
|
+
readonly "hintText": string;
|
|
1278
|
+
readonly "popover": string;
|
|
1279
|
+
readonly "popoverRoot": string;
|
|
1280
|
+
readonly "popoverContentContainer": string;
|
|
1281
|
+
readonly "popoverContent": string;
|
|
1282
|
+
readonly "selectionOptions": string;
|
|
1283
|
+
readonly "selectionOptionsIsHidden": string;
|
|
1284
|
+
readonly "selectionOptionsButton": string;
|
|
1285
|
+
readonly "caret": string;
|
|
1286
|
+
readonly "popoverSuggestionsRoot": string;
|
|
1287
|
+
readonly "suggestionsOverlayInputStyles": string;
|
|
1288
|
+
};
|
|
1289
|
+
|
|
1290
|
+
type TabCompletionStyles = typeof styles$5;
|
|
1291
|
+
|
|
1292
|
+
declare const styles$4: {
|
|
1293
|
+
readonly "root": string;
|
|
1294
|
+
readonly "content": string;
|
|
1295
|
+
readonly "title": string;
|
|
1296
|
+
readonly "actions": string;
|
|
1297
|
+
readonly "pagination": string;
|
|
1298
|
+
readonly "primaryButton": string;
|
|
1299
|
+
readonly "primaryButtons": string;
|
|
1300
|
+
};
|
|
1301
|
+
|
|
1302
|
+
type EditSuggestionFormStyles = typeof styles$4;
|
|
1303
|
+
|
|
1304
|
+
declare const styles$3: {
|
|
1305
|
+
readonly "badge": string;
|
|
1306
|
+
readonly "formattedText": string;
|
|
1307
|
+
};
|
|
1308
|
+
|
|
1309
|
+
type TextSuggestionStyles = typeof styles$3;
|
|
1310
|
+
|
|
1311
|
+
declare const styles$2: {
|
|
1312
|
+
readonly "root": string;
|
|
1313
|
+
readonly "isCollapsed": string;
|
|
1314
|
+
};
|
|
1315
|
+
|
|
1316
|
+
type Props$1 = HTMLAttributes<HTMLButtonElement> & {
|
|
1317
|
+
isCollapsed: boolean;
|
|
1318
|
+
title: string;
|
|
1319
|
+
};
|
|
1320
|
+
type ToggleButtonStyles = typeof styles$2;
|
|
1321
|
+
declare const ToggleButton: React.FC<Props$1>;
|
|
1322
|
+
|
|
1323
|
+
declare const styles$1: {
|
|
1324
|
+
readonly "root": string;
|
|
1325
|
+
readonly "loginText": string;
|
|
1326
|
+
readonly "stateText": string;
|
|
1327
|
+
readonly "sectionList": string;
|
|
1328
|
+
readonly "links": string;
|
|
1329
|
+
readonly "link": string;
|
|
1330
|
+
};
|
|
1331
|
+
|
|
1332
|
+
type WidgetStyles = typeof styles$1;
|
|
1333
|
+
|
|
1334
|
+
declare const styles: {
|
|
1335
|
+
readonly "root": string;
|
|
1336
|
+
};
|
|
1337
|
+
|
|
1338
|
+
interface Props {
|
|
1339
|
+
children: React.ReactNode;
|
|
1340
|
+
}
|
|
1341
|
+
type ChipStyles = typeof styles;
|
|
1342
|
+
declare const Chip: React.FC<Props>;
|
|
1343
|
+
|
|
1344
|
+
type WidgetCustomStyles = {
|
|
1345
|
+
Autoflow?: Partial<AutoflowStyles>;
|
|
1346
|
+
Card?: Partial<CardStyles>;
|
|
1347
|
+
Dialog?: Partial<DialogStyles>;
|
|
1348
|
+
KeyboardHint?: Partial<KeyboardHintStyles>;
|
|
1349
|
+
Label?: Partial<LabelStyles>;
|
|
1350
|
+
LinkSearch?: Partial<LinkSearchStyles>;
|
|
1351
|
+
Login?: Partial<LoginStyles>;
|
|
1352
|
+
Section?: Partial<SectionStyles>;
|
|
1353
|
+
SectionList?: Partial<SectionListStyles>;
|
|
1354
|
+
Suggestion?: Partial<SuggestionStyles>;
|
|
1355
|
+
SuggestionList?: Partial<SuggestionListStyles>;
|
|
1356
|
+
EditSuggestionForm?: Partial<EditSuggestionFormStyles>;
|
|
1357
|
+
Widget?: Partial<WidgetStyles>;
|
|
1358
|
+
};
|
|
1359
|
+
type InputOverlayCustomStyles = {
|
|
1360
|
+
CommandPalette?: Partial<CommandPaletteStyles>;
|
|
1361
|
+
Chip?: Partial<ChipStyles>;
|
|
1362
|
+
EntitiesList?: Partial<EntitiesListStyles>;
|
|
1363
|
+
Label?: Partial<LabelStyles>;
|
|
1364
|
+
Login?: Partial<LoginStyles>;
|
|
1365
|
+
LoginTokenDialog?: Partial<LoginTokenDialogStyles>;
|
|
1366
|
+
SearchTrigger?: Partial<SearchTriggerStyles>;
|
|
1367
|
+
Suggestion?: Partial<SuggestionStyles>;
|
|
1368
|
+
SuggestionList?: Partial<SuggestionListStyles>;
|
|
1369
|
+
SuggestionsOverlay?: Partial<SuggestionsOverlayStyles>;
|
|
1370
|
+
TextSuggestion?: Partial<TextSuggestionStyles>;
|
|
1371
|
+
ToggleButton?: Partial<ToggleButtonStyles>;
|
|
1372
|
+
KeyboardHint?: Partial<KeyboardHintStyles>;
|
|
1373
|
+
TabCompletion?: Partial<TabCompletionStyles>;
|
|
1374
|
+
};
|
|
1375
|
+
declare enum Locale {
|
|
1376
|
+
NL_NL = "nl-NL",
|
|
1377
|
+
EN_US = "en-US"
|
|
1378
|
+
}
|
|
1379
|
+
interface SuggestionApiMetrics {
|
|
1380
|
+
source?: string;
|
|
1381
|
+
score?: number;
|
|
1382
|
+
abVariant?: string;
|
|
1383
|
+
abTestName?: string;
|
|
1384
|
+
sourceText?: string;
|
|
1385
|
+
trainingJobs?: string[];
|
|
1386
|
+
}
|
|
1387
|
+
interface TextSuggestion extends SuggestionApiMetrics {
|
|
1388
|
+
id?: string;
|
|
1389
|
+
text: string;
|
|
1390
|
+
url?: string;
|
|
1391
|
+
title?: string;
|
|
1392
|
+
sourceLabel?: string;
|
|
1393
|
+
type?: string;
|
|
1394
|
+
searchKeywords?: string[];
|
|
1395
|
+
image?: string;
|
|
1396
|
+
message?: string;
|
|
1397
|
+
imageSizes?: {
|
|
1398
|
+
small: string;
|
|
1399
|
+
medium: string;
|
|
1400
|
+
large: string;
|
|
1401
|
+
};
|
|
1402
|
+
}
|
|
1403
|
+
interface PinnedMessage extends SuggestionApiMetrics {
|
|
1404
|
+
title: string;
|
|
1405
|
+
message: string;
|
|
1406
|
+
image: string;
|
|
1407
|
+
imageSizes?: {
|
|
1408
|
+
small: string;
|
|
1409
|
+
medium: string;
|
|
1410
|
+
large: string;
|
|
1411
|
+
};
|
|
1412
|
+
}
|
|
1413
|
+
interface UrlSuggestion extends SuggestionApiMetrics {
|
|
1414
|
+
id?: string;
|
|
1415
|
+
url: string;
|
|
1416
|
+
context?: string;
|
|
1417
|
+
image: string;
|
|
1418
|
+
summary?: string;
|
|
1419
|
+
title?: string;
|
|
1420
|
+
imageSizes?: {
|
|
1421
|
+
small: string;
|
|
1422
|
+
medium: string;
|
|
1423
|
+
large: string;
|
|
1424
|
+
};
|
|
1425
|
+
}
|
|
1426
|
+
interface SearchSuggestion extends SuggestionApiMetrics {
|
|
1427
|
+
id?: string;
|
|
1428
|
+
text: string;
|
|
1429
|
+
title?: string;
|
|
1430
|
+
context?: string;
|
|
1431
|
+
image?: string;
|
|
1432
|
+
type?: SearchResultType;
|
|
1433
|
+
}
|
|
1434
|
+
interface SuggestionEventMetrics {
|
|
1435
|
+
inputType: InputType;
|
|
1436
|
+
}
|
|
1437
|
+
interface SuggestionMetrics extends SuggestionApiMetrics, SuggestionEventMetrics {
|
|
1438
|
+
text: string;
|
|
1439
|
+
searchTerm?: string | null;
|
|
1440
|
+
}
|
|
1441
|
+
type VisitorInfo = {
|
|
1442
|
+
visitorId?: string;
|
|
1443
|
+
visitorName?: string;
|
|
1444
|
+
visitorTimeZone?: string;
|
|
1445
|
+
psid?: string;
|
|
1446
|
+
};
|
|
1447
|
+
type AgentInfo = {
|
|
1448
|
+
agentId: string;
|
|
1449
|
+
agentNickname: string;
|
|
1450
|
+
agentName?: string;
|
|
1451
|
+
agentEmail?: string;
|
|
1452
|
+
agentTimeZone?: string;
|
|
1453
|
+
};
|
|
1454
|
+
type User = CamelCaseKeys<Server.User>;
|
|
1455
|
+
type SendMessageEventData = CamelCaseKeys<Server.SendMessageEventData>;
|
|
1456
|
+
type Profile = CamelCaseKeys<Server.Profile>;
|
|
1457
|
+
|
|
1458
|
+
type CreateConversation = {
|
|
1459
|
+
platform: string;
|
|
1460
|
+
sessionId: string;
|
|
1461
|
+
profileCode?: string;
|
|
1462
|
+
agentId: string;
|
|
1463
|
+
agentName?: string;
|
|
1464
|
+
agentNickname?: string;
|
|
1465
|
+
agentEmail?: string;
|
|
1466
|
+
tags?: Record<string, string> | null;
|
|
1467
|
+
};
|
|
1468
|
+
interface Entity {
|
|
1469
|
+
text: string;
|
|
1470
|
+
label: string;
|
|
1471
|
+
}
|
|
1472
|
+
/**
|
|
1473
|
+
* Utils
|
|
1474
|
+
*/
|
|
1475
|
+
type Logger = {
|
|
1476
|
+
info(...args: any[]): void;
|
|
1477
|
+
warn(...args: any[]): void;
|
|
1478
|
+
error(...args: any[]): void;
|
|
1479
|
+
};
|
|
1480
|
+
declare enum FetchState {
|
|
1481
|
+
IDLE = "idle",
|
|
1482
|
+
LOADING = "loading",
|
|
1483
|
+
DONE = "done",
|
|
1484
|
+
ERROR = "error"
|
|
1485
|
+
}
|
|
1486
|
+
|
|
1487
|
+
type KeyboardMetric = Pick<KeyboardEvent, 'key' | 'shiftKey' | 'ctrlKey' | 'altKey' | 'metaKey'>;
|
|
1488
|
+
type StageSuggestion = {
|
|
1489
|
+
text: string;
|
|
1490
|
+
suggestion: TextSuggestion;
|
|
1491
|
+
eventMetrics: SuggestionEventMetrics;
|
|
1492
|
+
replace: 'selection' | 'until-selection-end';
|
|
1493
|
+
};
|
|
1494
|
+
type EditTextSuggestionPayload = {
|
|
1495
|
+
contentType: string;
|
|
1496
|
+
index: number | null;
|
|
1497
|
+
suggestions: TextSuggestion[];
|
|
1498
|
+
};
|
|
1499
|
+
type MetricState = {
|
|
1500
|
+
numCharsTyped: number;
|
|
1501
|
+
numCharsPasted: number;
|
|
1502
|
+
numCharsCut: number;
|
|
1503
|
+
numCharsDeleted: number;
|
|
1504
|
+
numPaste: number;
|
|
1505
|
+
agentStartedTypingTimestamp: number | null;
|
|
1506
|
+
pastes: any[];
|
|
1507
|
+
deletions: any[];
|
|
1508
|
+
offeredTextSuggestions: TextSuggestion[];
|
|
1509
|
+
textSuggestions: SuggestionMetrics[];
|
|
1510
|
+
cuts: any[];
|
|
1511
|
+
};
|
|
1512
|
+
type State$5 = {
|
|
1513
|
+
text: string;
|
|
1514
|
+
html: string | null;
|
|
1515
|
+
selection: SelectionRange;
|
|
1516
|
+
stagedSuggestion: StageSuggestion | null;
|
|
1517
|
+
userCommitted: {
|
|
1518
|
+
text: string;
|
|
1519
|
+
selection: SelectionRange;
|
|
1520
|
+
};
|
|
1521
|
+
tabCompletionSuggestion?: TextSuggestion;
|
|
1522
|
+
metrics: MetricState;
|
|
1523
|
+
previousKeyDownEvent: KeyboardMetric | null;
|
|
1524
|
+
textSuggestions: TextSuggestion[];
|
|
1525
|
+
selectedSuggestionIndex: number;
|
|
1526
|
+
};
|
|
1527
|
+
|
|
1528
|
+
type State$4 = {
|
|
1529
|
+
data: Profile | null;
|
|
1530
|
+
fetchState: FetchState;
|
|
1531
|
+
};
|
|
1532
|
+
|
|
1533
|
+
type SearchResultType = string | SearchResultDefaultType;
|
|
1534
|
+
declare enum SearchResultDefaultType {
|
|
1535
|
+
url = "URL",
|
|
1536
|
+
personal = "PERSONAL",
|
|
1537
|
+
pinned = "STICKYMESSAGE",
|
|
1538
|
+
image = "IMAGE"
|
|
1539
|
+
}
|
|
1540
|
+
type SearchResult = SearchSuggestion;
|
|
1541
|
+
interface State$3 {
|
|
1542
|
+
list: Array<SearchResult>;
|
|
1543
|
+
fetchState: FetchState;
|
|
1544
|
+
isOpen: boolean;
|
|
1545
|
+
}
|
|
1546
|
+
|
|
1547
|
+
type State$2 = {
|
|
1548
|
+
data: string | null;
|
|
1549
|
+
fetchState: FetchState;
|
|
1550
|
+
};
|
|
1551
|
+
|
|
1552
|
+
type StyleSuggestion = CamelCaseKeys<Server.StyleSuggestion>;
|
|
1553
|
+
interface State$1 {
|
|
1554
|
+
list: StyleSuggestion;
|
|
1555
|
+
fetchState: FetchState;
|
|
1556
|
+
isInitialRequest: null | boolean;
|
|
1557
|
+
}
|
|
1558
|
+
|
|
1559
|
+
type SuggestionState = {
|
|
1560
|
+
suggestions: TextSuggestion[];
|
|
1561
|
+
fetchState: FetchState;
|
|
1562
|
+
isInitialRequest: null | boolean;
|
|
1563
|
+
};
|
|
1564
|
+
interface TextSuggestionState {
|
|
1565
|
+
[type: string]: SuggestionState;
|
|
1566
|
+
}
|
|
1567
|
+
|
|
1568
|
+
type State = {
|
|
1569
|
+
locale: Locale;
|
|
1570
|
+
deanonymize: boolean;
|
|
1571
|
+
fallbackImage: string | false;
|
|
1572
|
+
isEmbedded: boolean;
|
|
1573
|
+
showAutoflows: boolean | number;
|
|
1574
|
+
showCustomMessages: boolean | number;
|
|
1575
|
+
showImages: boolean;
|
|
1576
|
+
showPersonalCollectionLink: boolean;
|
|
1577
|
+
showSearch: boolean;
|
|
1578
|
+
showImageSearch: boolean;
|
|
1579
|
+
showStyleSuggestions: boolean | number;
|
|
1580
|
+
showMidSentenceSuggestions: boolean;
|
|
1581
|
+
showSuggestionsBeforePattern: string | false;
|
|
1582
|
+
showSuggestionsAfterPattern: string | false;
|
|
1583
|
+
showTabCompletion: boolean;
|
|
1584
|
+
showTextSuggestions: boolean;
|
|
1585
|
+
showEntitiesCommand: boolean;
|
|
1586
|
+
showSummaryCommand: boolean;
|
|
1587
|
+
showKnowledgeSearch: boolean;
|
|
1588
|
+
textSuggestionsCount: number;
|
|
1589
|
+
recommendTextSuggestions: boolean;
|
|
1590
|
+
searchTriggerKey: string;
|
|
1591
|
+
visible: boolean;
|
|
1592
|
+
insertLink: boolean;
|
|
1593
|
+
inlineSuggestions: boolean;
|
|
1594
|
+
adminUrl?: string;
|
|
1595
|
+
};
|
|
1596
|
+
declare const set: _reduxjs_toolkit.ActionCreatorWithPayload<Partial<State>, "settings/set">;
|
|
1597
|
+
|
|
1598
|
+
declare global {
|
|
1599
|
+
interface Window {
|
|
1600
|
+
clipboardData: any;
|
|
1601
|
+
__REDUX_DEVTOOLS_EXTENSION_COMPOSE__: any;
|
|
1602
|
+
}
|
|
1603
|
+
}
|
|
1604
|
+
interface SDKOptions {
|
|
1605
|
+
deepdeskUrl: string;
|
|
1606
|
+
brokerUrl?: string;
|
|
1607
|
+
version?: string;
|
|
1608
|
+
locale?: Locale;
|
|
1609
|
+
token?: string;
|
|
1610
|
+
fetch?: typeof window.fetch;
|
|
1611
|
+
}
|
|
1612
|
+
interface SDKEventMap {
|
|
1613
|
+
'select-suggestion': {
|
|
1614
|
+
text: string;
|
|
1615
|
+
type: string;
|
|
1616
|
+
replace: SelectionRange;
|
|
1617
|
+
suggestion: TextSuggestion;
|
|
1618
|
+
};
|
|
1619
|
+
'reset': {
|
|
1620
|
+
text: string;
|
|
1621
|
+
selectionAfter: SelectionRange;
|
|
1622
|
+
};
|
|
1623
|
+
'replace': {
|
|
1624
|
+
text: string;
|
|
1625
|
+
replace: SelectionRange;
|
|
1626
|
+
};
|
|
1627
|
+
'select-image': {
|
|
1628
|
+
suggestion: TextSuggestion;
|
|
1629
|
+
};
|
|
1630
|
+
'edit-suggestion': EditTextSuggestionPayload;
|
|
1631
|
+
'send-message': string;
|
|
1632
|
+
'send-message-event': SendMessageEventData;
|
|
1633
|
+
ready: undefined;
|
|
1634
|
+
showSearchOverlay: boolean;
|
|
1635
|
+
}
|
|
1636
|
+
type SDKHandler<K extends keyof SDKEventMap> = (eventPayload: SDKEventMap[K]) => void;
|
|
1637
|
+
interface MountOptions {
|
|
1638
|
+
customStyles?: InputOverlayCustomStyles & {
|
|
1639
|
+
rootNode?: string;
|
|
1640
|
+
};
|
|
1641
|
+
closestScrollSelector?: string;
|
|
1642
|
+
automaticHandlingTime?: boolean;
|
|
1643
|
+
showStyleSuggestions?: boolean;
|
|
1644
|
+
showTabCompletion?: boolean;
|
|
1645
|
+
showTextSuggestions?: boolean;
|
|
1646
|
+
showMidSentenceSuggestions?: boolean;
|
|
1647
|
+
showSuggestionsBeforePattern?: string | false;
|
|
1648
|
+
showSuggestionsAfterPattern?: string | false;
|
|
1649
|
+
textSuggestionsCount?: number;
|
|
1650
|
+
detectSubmit?: boolean;
|
|
1651
|
+
insertLink?: boolean;
|
|
1652
|
+
isEmbedded?: boolean;
|
|
1653
|
+
/**
|
|
1654
|
+
* By default append overlay to target.parentElement
|
|
1655
|
+
* Optionally append to different HTMLElement, for example `document.body`
|
|
1656
|
+
*/
|
|
1657
|
+
appendOverlayTo?: HTMLElement;
|
|
1658
|
+
inputMediator?: InputMediator<HTMLElement>;
|
|
1659
|
+
inlineSuggestions?: boolean;
|
|
1660
|
+
}
|
|
1661
|
+
interface WidgetOptions {
|
|
1662
|
+
customStyles?: WidgetCustomStyles;
|
|
1663
|
+
showImages?: boolean;
|
|
1664
|
+
isEmbedded?: boolean;
|
|
1665
|
+
showPersonalCollectionLink?: boolean;
|
|
1666
|
+
}
|
|
1667
|
+
declare class DeepdeskSDK {
|
|
1668
|
+
static version: string;
|
|
1669
|
+
static count: number;
|
|
1670
|
+
private deepdeskApi;
|
|
1671
|
+
private inputMediator;
|
|
1672
|
+
private version;
|
|
1673
|
+
private broadcastEvents;
|
|
1674
|
+
private eventListeners;
|
|
1675
|
+
private unmountHandlers;
|
|
1676
|
+
private widgetRoot;
|
|
1677
|
+
private dynamicThunkObject;
|
|
1678
|
+
isMounted: boolean;
|
|
1679
|
+
instanceId: number;
|
|
1680
|
+
private shouldRender;
|
|
1681
|
+
store: Store;
|
|
1682
|
+
constructor({ deepdeskUrl, brokerUrl, version, locale, token, fetch, }: SDKOptions);
|
|
1683
|
+
get state(): redux.EmptyObject & {
|
|
1684
|
+
activeSuggestion: State$e;
|
|
1685
|
+
answer: State$6;
|
|
1686
|
+
auth: State$d;
|
|
1687
|
+
autoflows: State$c;
|
|
1688
|
+
conversation: State$b;
|
|
1689
|
+
contentTypes: State$a;
|
|
1690
|
+
customMessages: State$9;
|
|
1691
|
+
exchangeToken: State$8;
|
|
1692
|
+
entities: State$7;
|
|
1693
|
+
handlingTime: State$f;
|
|
1694
|
+
info: {
|
|
1695
|
+
agentInfo?: AgentInfo | undefined;
|
|
1696
|
+
agentSettings: unknown;
|
|
1697
|
+
visitorInfo?: VisitorInfo | undefined;
|
|
1698
|
+
fetchState: FetchState;
|
|
1699
|
+
};
|
|
1700
|
+
input: State$5;
|
|
1701
|
+
overlayInput: State$5;
|
|
1702
|
+
settings: {
|
|
1703
|
+
locale: Locale;
|
|
1704
|
+
deanonymize: boolean;
|
|
1705
|
+
fallbackImage: string | false;
|
|
1706
|
+
isEmbedded: boolean;
|
|
1707
|
+
showAutoflows: number | boolean;
|
|
1708
|
+
showCustomMessages: number | boolean;
|
|
1709
|
+
showImages: boolean;
|
|
1710
|
+
showPersonalCollectionLink: boolean;
|
|
1711
|
+
showSearch: boolean;
|
|
1712
|
+
showImageSearch: boolean;
|
|
1713
|
+
showStyleSuggestions: number | boolean;
|
|
1714
|
+
showMidSentenceSuggestions: boolean;
|
|
1715
|
+
showSuggestionsBeforePattern: string | false;
|
|
1716
|
+
showSuggestionsAfterPattern: string | false;
|
|
1717
|
+
showTabCompletion: boolean;
|
|
1718
|
+
showTextSuggestions: boolean;
|
|
1719
|
+
showEntitiesCommand: boolean;
|
|
1720
|
+
showSummaryCommand: boolean;
|
|
1721
|
+
showKnowledgeSearch: boolean;
|
|
1722
|
+
textSuggestionsCount: number;
|
|
1723
|
+
recommendTextSuggestions: boolean;
|
|
1724
|
+
searchTriggerKey: string;
|
|
1725
|
+
visible: boolean;
|
|
1726
|
+
insertLink: boolean;
|
|
1727
|
+
inlineSuggestions: boolean;
|
|
1728
|
+
adminUrl?: string | undefined;
|
|
1729
|
+
};
|
|
1730
|
+
profile: State$4;
|
|
1731
|
+
search: State$3;
|
|
1732
|
+
summary: State$2;
|
|
1733
|
+
styleSuggestions: State$1;
|
|
1734
|
+
ui: {
|
|
1735
|
+
showTabHint: boolean;
|
|
1736
|
+
inputHasFocus: boolean;
|
|
1737
|
+
overlayCollapsed: boolean;
|
|
1738
|
+
openOverlayWhenTyping: boolean;
|
|
1739
|
+
overlayCollapsedUserOverwrite: boolean;
|
|
1740
|
+
};
|
|
1741
|
+
textSuggestions: TextSuggestionState;
|
|
1742
|
+
};
|
|
1743
|
+
get settings(): {
|
|
1744
|
+
locale: Locale;
|
|
1745
|
+
deanonymize: boolean;
|
|
1746
|
+
fallbackImage: string | false;
|
|
1747
|
+
isEmbedded: boolean;
|
|
1748
|
+
showAutoflows: number | boolean;
|
|
1749
|
+
showCustomMessages: number | boolean;
|
|
1750
|
+
showImages: boolean;
|
|
1751
|
+
showPersonalCollectionLink: boolean;
|
|
1752
|
+
showSearch: boolean;
|
|
1753
|
+
showImageSearch: boolean;
|
|
1754
|
+
showStyleSuggestions: number | boolean;
|
|
1755
|
+
showMidSentenceSuggestions: boolean;
|
|
1756
|
+
showSuggestionsBeforePattern: string | false;
|
|
1757
|
+
showSuggestionsAfterPattern: string | false;
|
|
1758
|
+
showTabCompletion: boolean;
|
|
1759
|
+
showTextSuggestions: boolean;
|
|
1760
|
+
showEntitiesCommand: boolean;
|
|
1761
|
+
showSummaryCommand: boolean;
|
|
1762
|
+
showKnowledgeSearch: boolean;
|
|
1763
|
+
textSuggestionsCount: number;
|
|
1764
|
+
recommendTextSuggestions: boolean;
|
|
1765
|
+
searchTriggerKey: string;
|
|
1766
|
+
visible: boolean;
|
|
1767
|
+
insertLink: boolean;
|
|
1768
|
+
inlineSuggestions: boolean;
|
|
1769
|
+
adminUrl?: string | undefined;
|
|
1770
|
+
};
|
|
1771
|
+
get selectedTextSuggestion(): TextSuggestion;
|
|
1772
|
+
hasConversation(): boolean;
|
|
1773
|
+
conversationId(): string;
|
|
1774
|
+
private sessionId;
|
|
1775
|
+
private shouldAbort;
|
|
1776
|
+
login(): Promise<void>;
|
|
1777
|
+
isLoggedIn(): Promise<boolean>;
|
|
1778
|
+
/**
|
|
1779
|
+
* Set platform id for current user
|
|
1780
|
+
* @param agentId - The platform id of the current user
|
|
1781
|
+
* @deprecated Since 7.14.6 in favor of setAgentInfo
|
|
1782
|
+
*/
|
|
1783
|
+
setPlatformAgentId(agentId: string): Promise<void>;
|
|
1784
|
+
/**
|
|
1785
|
+
* Check if conversation is supported by Deepdesk
|
|
1786
|
+
* @param sessionId - A string with the conversation session ID.
|
|
1787
|
+
* A session ID is local to the customer service platform, and identifies a
|
|
1788
|
+
* conversation that takes place within a certain time frame.
|
|
1789
|
+
*/
|
|
1790
|
+
isConversationSupported(sessionId: string, options?: Parameters<typeof DeepdeskAPI.prototype.isConversationSupported>[1]): Promise<boolean>;
|
|
1791
|
+
/**
|
|
1792
|
+
* Create a conversation
|
|
1793
|
+
* This should only be used when backend ingestion (via webhooks) is not possible.
|
|
1794
|
+
* @param data - The create conversation options
|
|
1795
|
+
*/
|
|
1796
|
+
createConversation(data: CreateConversation): Promise<Conversation>;
|
|
1797
|
+
/**
|
|
1798
|
+
* Get a conversation by session ID
|
|
1799
|
+
* @param sessionId - A string with the conversation session ID.
|
|
1800
|
+
* A session ID is local to the customer service platform, and identifies a
|
|
1801
|
+
* conversation that takes place within a certain time frame.
|
|
1802
|
+
*/
|
|
1803
|
+
getConversationBySessionId(sessionId: string, options?: Parameters<typeof DeepdeskAPI.prototype.getConversationBySessionId>[1]): Promise<Conversation>;
|
|
1804
|
+
/**
|
|
1805
|
+
* Upsert a conversation: Get and update conversation or create it if it does not exist yet.
|
|
1806
|
+
*/
|
|
1807
|
+
upsertConversation(data: CreateConversation): Promise<Conversation>;
|
|
1808
|
+
/**
|
|
1809
|
+
* Method to call when the conversation is updated, either by an incoming message
|
|
1810
|
+
* from the visitor, or a message sent by the agent.
|
|
1811
|
+
*/
|
|
1812
|
+
postMessages(messages: ConversationMessage[]): Promise<any>;
|
|
1813
|
+
/**
|
|
1814
|
+
* Update converstation meta data
|
|
1815
|
+
*/
|
|
1816
|
+
updateConversation(conversation: Partial<Conversation>): Promise<Conversation>;
|
|
1817
|
+
/**
|
|
1818
|
+
* Reset conversation
|
|
1819
|
+
*/
|
|
1820
|
+
resetConversation(): void;
|
|
1821
|
+
/**
|
|
1822
|
+
* Get summary from conversation
|
|
1823
|
+
*/
|
|
1824
|
+
getSummary(): Promise<string>;
|
|
1825
|
+
/**
|
|
1826
|
+
* Change settings value
|
|
1827
|
+
*/
|
|
1828
|
+
configure(settings: Parameters<typeof set>[0]): void;
|
|
1829
|
+
/**
|
|
1830
|
+
* Store the visitor information in memory
|
|
1831
|
+
*/
|
|
1832
|
+
setVisitorInfo(visitorInfo: VisitorInfo): void;
|
|
1833
|
+
/**
|
|
1834
|
+
* Store the agent information in memory
|
|
1835
|
+
*/
|
|
1836
|
+
setAgentInfo(agentInfo: AgentInfo): Promise<void>;
|
|
1837
|
+
/**
|
|
1838
|
+
* Store the agent settings
|
|
1839
|
+
*/
|
|
1840
|
+
setAgentSettings<T = unknown>(patch: Partial<T>): Promise<void>;
|
|
1841
|
+
/**
|
|
1842
|
+
* Get the agent settings
|
|
1843
|
+
*/
|
|
1844
|
+
getAgentSettings<T = unknown>(): Promise<T>;
|
|
1845
|
+
/**
|
|
1846
|
+
* Refresh suggestions based on the current conversation.
|
|
1847
|
+
* Only refresh text suggestions when the agent is not typing.
|
|
1848
|
+
*/
|
|
1849
|
+
refresh(): Promise<void>;
|
|
1850
|
+
/**
|
|
1851
|
+
* Method to call when the agent input has changed
|
|
1852
|
+
*/
|
|
1853
|
+
private notifyInputChanged;
|
|
1854
|
+
private syncInputHtml;
|
|
1855
|
+
/**
|
|
1856
|
+
* Method to call for the agent input keydown event
|
|
1857
|
+
*/
|
|
1858
|
+
private notifyKeyDown;
|
|
1859
|
+
private notifyPaste;
|
|
1860
|
+
private notifyCut;
|
|
1861
|
+
notifyExternalSuggestion(suggestion: StageSuggestion): void;
|
|
1862
|
+
notifyEditSuggestion(data: {
|
|
1863
|
+
contentType: string;
|
|
1864
|
+
suggestions: TextSuggestion[];
|
|
1865
|
+
index: number | null;
|
|
1866
|
+
}): void;
|
|
1867
|
+
private handleInputChanged;
|
|
1868
|
+
private handleKeyDown;
|
|
1869
|
+
private handleAfterSendMessage;
|
|
1870
|
+
handlingTimeStart(): void;
|
|
1871
|
+
handlingTimeStop(): void;
|
|
1872
|
+
private logSendMessage;
|
|
1873
|
+
private logSendEditMessage;
|
|
1874
|
+
private logHandlingTime;
|
|
1875
|
+
/**
|
|
1876
|
+
* Method to call when the agent has sent a message to the visitor
|
|
1877
|
+
* Optionally pass the sent text
|
|
1878
|
+
*/
|
|
1879
|
+
notifySubmit(options?: {
|
|
1880
|
+
text?: string;
|
|
1881
|
+
}): void;
|
|
1882
|
+
stageSelectedSuggestion(eventMetrics: SuggestionEventMetrics): void;
|
|
1883
|
+
emit<K extends keyof SDKEventMap>(type: K, eventPayload: SDKEventMap[K], options?: {
|
|
1884
|
+
mayApplyChanges?: boolean;
|
|
1885
|
+
}): void;
|
|
1886
|
+
/**
|
|
1887
|
+
* Attach listener to SDK event
|
|
1888
|
+
* Returns removeListener
|
|
1889
|
+
*/
|
|
1890
|
+
on<K extends keyof SDKEventMap>(type: K, handler: SDKHandler<K>): () => void;
|
|
1891
|
+
/**
|
|
1892
|
+
* Remove listener from SDK
|
|
1893
|
+
* Similar to HTMLElement.removeListener
|
|
1894
|
+
*/
|
|
1895
|
+
off<K extends keyof SDKEventMap>(type: K, handler: SDKHandler<K>): void;
|
|
1896
|
+
off(): void;
|
|
1897
|
+
/**
|
|
1898
|
+
* Set the fetch function to retrieve conversation data to be used for NER endpoints
|
|
1899
|
+
* This way the NER service can remain a separate system and ensure anonomity
|
|
1900
|
+
* @param fetchFn function that returns the conversation data as a string
|
|
1901
|
+
*/
|
|
1902
|
+
setConversationQuery(fetchFn: () => Promise<Array<{
|
|
1903
|
+
source: string;
|
|
1904
|
+
text: string;
|
|
1905
|
+
}>>): void;
|
|
1906
|
+
whenConversationLoaded(callback: () => void): void;
|
|
1907
|
+
private overlayContainerFactory;
|
|
1908
|
+
private createContainer;
|
|
1909
|
+
/**
|
|
1910
|
+
* Renders the tab completion and suggestions overlay and 2-way binds events
|
|
1911
|
+
* @param inputElement - the agent input element to enhance
|
|
1912
|
+
* @param options - optional mount options
|
|
1913
|
+
*/
|
|
1914
|
+
mount(inputElement: HTMLElement, options?: MountOptions): void;
|
|
1915
|
+
unmount(): void;
|
|
1916
|
+
/**
|
|
1917
|
+
* Injects the Deepdesk Widget element into the provided DOM element.
|
|
1918
|
+
* @param containerElement - the element to inject the deepdesk element in
|
|
1919
|
+
* @param options - optional widget options
|
|
1920
|
+
*/
|
|
1921
|
+
renderWidget(containerElement: HTMLElement, options?: WidgetOptions): void;
|
|
1922
|
+
unmountWidget(): void;
|
|
1923
|
+
private setupHandlingTime;
|
|
1924
|
+
private handleError;
|
|
1925
|
+
private loadProfileConfigPromise;
|
|
1926
|
+
private loadProfileConfig;
|
|
1927
|
+
checkForTrialMode(agentId: string): Promise<void>;
|
|
1928
|
+
private refreshWidgetSuggestions;
|
|
1929
|
+
}
|
|
1930
|
+
|
|
1931
|
+
declare class ContentEditableInput extends InputMediator<HTMLDivElement> {
|
|
1932
|
+
protected observer?: MutationObserver;
|
|
1933
|
+
getText(): string;
|
|
1934
|
+
getHTML(): string;
|
|
1935
|
+
getSelection(): SelectionRange | null;
|
|
1936
|
+
getSelectedText(): string;
|
|
1937
|
+
applyChanges(callback: (element: HTMLDivElement) => void | Promise<void>): void;
|
|
1938
|
+
listen(): void;
|
|
1939
|
+
dispose(): void;
|
|
1940
|
+
}
|
|
1941
|
+
|
|
1942
|
+
declare class TextAreaInput extends InputMediator<HTMLTextAreaElement> {
|
|
1943
|
+
getText(): string;
|
|
1944
|
+
getHTML(): string | null;
|
|
1945
|
+
getSelection(): SelectionRange;
|
|
1946
|
+
getSelectedText(): string;
|
|
1947
|
+
applyChanges(callback: (element: HTMLTextAreaElement) => void | Promise<void>): void;
|
|
1948
|
+
listen(): void;
|
|
1949
|
+
}
|
|
1950
|
+
|
|
1951
|
+
type OverlayOptions = {
|
|
1952
|
+
appendTo?: HTMLElement;
|
|
1953
|
+
mirrorOverflow?: boolean;
|
|
1954
|
+
closestScrollElement?: HTMLElement;
|
|
1955
|
+
overlayContainer?: HTMLElement;
|
|
1956
|
+
onHide?(): void;
|
|
1957
|
+
onShow?(): void;
|
|
1958
|
+
onRemove?(): void;
|
|
1959
|
+
};
|
|
1960
|
+
/**
|
|
1961
|
+
* border-box: width including scroll width
|
|
1962
|
+
* content-box: width excluding scroll width
|
|
1963
|
+
*/
|
|
1964
|
+
declare function createOverlayContainer(target: HTMLElement, options?: OverlayOptions): [HTMLElement, () => void];
|
|
1965
|
+
|
|
1966
|
+
declare function isSupportedInputElement(element?: HTMLElement): boolean;
|
|
1967
|
+
|
|
1968
|
+
type TextAreaOptions = {
|
|
1969
|
+
replace?: SelectionRange;
|
|
1970
|
+
selectionAfter?: SelectionRange;
|
|
1971
|
+
setValue?: (newValue: string) => void | Promise<void>;
|
|
1972
|
+
};
|
|
1973
|
+
declare function updateTextArea(element: HTMLTextAreaElement, insertText: string, options?: TextAreaOptions): Promise<void>;
|
|
1974
|
+
type ContentEditableOptions = {
|
|
1975
|
+
replace?: SelectionRange;
|
|
1976
|
+
selectionAfter?: SelectionRange | false;
|
|
1977
|
+
setRange?: (range: Range) => void | Promise<void>;
|
|
1978
|
+
};
|
|
1979
|
+
declare function updateContentEditable(element: HTMLElement, insertText: string, options?: ContentEditableOptions): Promise<void>;
|
|
1980
|
+
|
|
1981
|
+
/**
|
|
1982
|
+
* Format (markdown) patterns to html.
|
|
1983
|
+
*/
|
|
1984
|
+
declare function formatTextMarkup(message: string): string;
|
|
1985
|
+
|
|
1986
|
+
declare function authenticateWithKey(accountOrigin: string, key: string, user: User): Promise<void>;
|
|
1987
|
+
|
|
1988
|
+
type PlatformConfig = {
|
|
1989
|
+
config: {
|
|
1990
|
+
account: {
|
|
1991
|
+
name: string;
|
|
1992
|
+
};
|
|
1993
|
+
platform: {
|
|
1994
|
+
name: string;
|
|
1995
|
+
hasSso: boolean;
|
|
1996
|
+
authorizationUrl: string;
|
|
1997
|
+
};
|
|
1998
|
+
};
|
|
1999
|
+
};
|
|
2000
|
+
declare function fetchPlatformConfig(accountOrigin: string): Promise<PlatformConfig>;
|
|
2001
|
+
|
|
2002
|
+
declare function escapeHTML(text: string): string;
|
|
2003
|
+
|
|
2004
|
+
interface TargetFileOptions {
|
|
2005
|
+
/**
|
|
2006
|
+
* path to file
|
|
2007
|
+
* eg: https://example.com/test.jpeg
|
|
2008
|
+
*/
|
|
2009
|
+
url: string;
|
|
2010
|
+
/**
|
|
2011
|
+
* name of file
|
|
2012
|
+
* eg: test.jpeg
|
|
2013
|
+
*/
|
|
2014
|
+
name: string;
|
|
2015
|
+
/**
|
|
2016
|
+
* mime type of file
|
|
2017
|
+
* default: image/jpeg
|
|
2018
|
+
*/
|
|
2019
|
+
mimeType?: string;
|
|
2020
|
+
/**
|
|
2021
|
+
* optionally override default window.fetch
|
|
2022
|
+
*/
|
|
2023
|
+
fetch?: typeof window.fetch;
|
|
2024
|
+
}
|
|
2025
|
+
declare function attachFile(fileInput: HTMLInputElement, target: TargetFileOptions): Promise<void>;
|
|
2026
|
+
|
|
2027
|
+
declare function createRangeFromOffsets(rootElement: HTMLElement, startOffset: number, endOffset: number): Range;
|
|
2028
|
+
declare function getRangeOffsets(rootElement: HTMLElement, range: Range): {
|
|
2029
|
+
start: number;
|
|
2030
|
+
end: number;
|
|
2031
|
+
};
|
|
2032
|
+
declare function getRangeText(rootElement: Node, range: Range): string;
|
|
2033
|
+
|
|
2034
|
+
interface Cancelable {
|
|
2035
|
+
(): void;
|
|
2036
|
+
}
|
|
2037
|
+
/**
|
|
2038
|
+
* Get notified when a specific element changes from visible or invisible in the DOM
|
|
2039
|
+
*/
|
|
2040
|
+
declare function waitForElementVisibilityChange(element: HTMLElement, callback: (change: {
|
|
2041
|
+
isVisible: boolean;
|
|
2042
|
+
}) => void, interval?: number): Cancelable;
|
|
2043
|
+
|
|
2044
|
+
type CSSModule = Record<string, string>;
|
|
2045
|
+
declare function useStyles<TStyles extends CSSModule>(componentName: string, defaultStyles: TStyles): TStyles;
|
|
2046
|
+
|
|
2047
|
+
export { AgentInfo, Card, Chip, ContentEditableInput, Conversation, ConversationMessage, DeepdeskAPI, DeepdeskSDK, InputMediator, InputOverlayCustomStyles, InputType, KeyboardHint, Label, Locale, Logger, MountOptions, PinnedMessage, PlatformConfig, Section, SectionList, SelectionRange, Sources, Suggestion, SuggestionEventMetrics, SuggestionList, SuggestionMetrics, TextAreaInput, TextSuggestion, ToggleButton, UrlSuggestion, VisitorInfo, WidgetCustomStyles, WidgetOptions, attachFile, authenticateWithKey, createOverlayContainer, createRangeFromOffsets, escapeHTML, fetchPlatformConfig, formatTextMarkup, getRangeOffsets, getRangeText, isSupportedInputElement, updateContentEditable, updateTextArea, useStyles, waitForElementVisibilityChange };
|