crisp-api 9.12.1 → 10.0.2
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/CHANGELOG.md +14 -0
- package/README.md +6 -2
- package/dist/crisp.d.ts +167 -0
- package/dist/crisp.js +764 -0
- package/dist/resources/BaseResource.d.ts +15 -0
- package/dist/resources/BaseResource.js +20 -0
- package/dist/resources/BucketURL.d.ts +28 -0
- package/dist/resources/BucketURL.js +29 -0
- package/dist/resources/MediaAnimation.d.ts +14 -0
- package/dist/resources/MediaAnimation.js +32 -0
- package/dist/resources/PluginConnect.d.ts +50 -0
- package/dist/resources/PluginConnect.js +73 -0
- package/dist/resources/PluginSubscription.d.ts +103 -0
- package/dist/resources/PluginSubscription.js +122 -0
- package/dist/resources/WebsiteAnalytics.d.ts +14 -0
- package/dist/resources/WebsiteAnalytics.js +29 -0
- package/dist/resources/WebsiteAvailability.d.ts +31 -0
- package/dist/resources/WebsiteAvailability.js +36 -0
- package/dist/resources/WebsiteBase.d.ts +60 -0
- package/dist/resources/WebsiteBase.js +71 -0
- package/dist/resources/WebsiteBatch.d.ts +52 -0
- package/dist/resources/WebsiteBatch.js +70 -0
- package/dist/resources/WebsiteCampaign.d.ts +199 -0
- package/dist/resources/WebsiteCampaign.js +194 -0
- package/dist/resources/WebsiteConversation.d.ts +701 -0
- package/dist/resources/WebsiteConversation.js +595 -0
- package/dist/resources/WebsiteHelpdesk.d.ts +347 -0
- package/dist/resources/WebsiteHelpdesk.js +587 -0
- package/dist/resources/WebsiteOperator.d.ts +79 -0
- package/dist/resources/WebsiteOperator.js +93 -0
- package/dist/resources/WebsitePeople.d.ts +248 -0
- package/dist/resources/WebsitePeople.js +276 -0
- package/dist/resources/WebsiteSettings.d.ts +159 -0
- package/dist/resources/WebsiteSettings.js +36 -0
- package/dist/resources/WebsiteVerify.d.ts +38 -0
- package/dist/resources/WebsiteVerify.js +50 -0
- package/dist/resources/WebsiteVisitors.d.ts +113 -0
- package/dist/resources/WebsiteVisitors.js +88 -0
- package/dist/resources/index.d.ts +17 -0
- package/dist/resources/index.js +40 -0
- package/dist/services/bucket.d.ts +13 -0
- package/dist/services/bucket.js +28 -0
- package/dist/services/media.d.ts +13 -0
- package/dist/services/media.js +28 -0
- package/dist/services/plugin.d.ts +14 -0
- package/dist/services/plugin.js +30 -0
- package/dist/services/website.d.ts +24 -0
- package/dist/services/website.js +50 -0
- package/eslint.config.mjs +208 -0
- package/lib/crisp.ts +957 -0
- package/lib/resources/BaseResource.ts +29 -0
- package/lib/resources/BucketURL.ts +49 -0
- package/lib/resources/MediaAnimation.ts +34 -0
- package/lib/resources/PluginConnect.ts +128 -0
- package/lib/resources/PluginSubscription.ts +208 -0
- package/lib/resources/WebsiteAnalytics.ts +31 -0
- package/lib/resources/WebsiteAvailability.ts +54 -0
- package/lib/resources/WebsiteBase.ts +108 -0
- package/lib/resources/WebsiteBatch.ts +96 -0
- package/lib/resources/WebsiteCampaign.ts +399 -0
- package/lib/resources/WebsiteConversation.ts +1416 -0
- package/lib/resources/WebsiteHelpdesk.ts +982 -0
- package/lib/resources/WebsiteOperator.ts +161 -0
- package/lib/resources/WebsitePeople.ts +527 -0
- package/lib/resources/WebsiteSettings.ts +192 -0
- package/lib/resources/WebsiteVerify.ts +76 -0
- package/lib/resources/WebsiteVisitors.ts +196 -0
- package/lib/resources/index.ts +25 -0
- package/lib/services/bucket.ts +28 -0
- package/lib/services/media.ts +28 -0
- package/lib/services/plugin.ts +32 -0
- package/lib/services/website.ts +62 -0
- package/package.json +16 -11
- package/tsconfig.json +12 -5
- package/lib/crisp.js +0 -1168
- package/lib/resources/BucketURL.js +0 -34
- package/lib/resources/MediaAnimation.js +0 -41
- package/lib/resources/PluginConnect.js +0 -119
- package/lib/resources/PluginSubscription.js +0 -234
- package/lib/resources/WebsiteAnalytics.js +0 -37
- package/lib/resources/WebsiteAvailability.js +0 -48
- package/lib/resources/WebsiteBase.js +0 -100
- package/lib/resources/WebsiteBatch.js +0 -92
- package/lib/resources/WebsiteCampaign.js +0 -396
- package/lib/resources/WebsiteConversation.js +0 -1261
- package/lib/resources/WebsiteHelpdesk.js +0 -1198
- package/lib/resources/WebsiteOperator.js +0 -167
- package/lib/resources/WebsitePeople.js +0 -516
- package/lib/resources/WebsiteSettings.js +0 -50
- package/lib/resources/WebsiteVerify.js +0 -79
- package/lib/resources/WebsiteVisitors.js +0 -148
- package/lib/services/Bucket.js +0 -28
- package/lib/services/Media.js +0 -28
- package/lib/services/Plugin.js +0 -29
- package/lib/services/Website.js +0 -39
- package/types/crisp.d.ts +0 -151
- package/types/resources/BucketURL.d.ts +0 -15
- package/types/resources/MediaAnimation.d.ts +0 -15
- package/types/resources/PluginConnect.d.ts +0 -15
- package/types/resources/PluginSubscription.d.ts +0 -15
- package/types/resources/WebsiteAnalytics.d.ts +0 -15
- package/types/resources/WebsiteAvailability.d.ts +0 -15
- package/types/resources/WebsiteBase.d.ts +0 -15
- package/types/resources/WebsiteBatch.d.ts +0 -15
- package/types/resources/WebsiteCampaign.d.ts +0 -15
- package/types/resources/WebsiteConversation.d.ts +0 -15
- package/types/resources/WebsiteHelpdesk.d.ts +0 -15
- package/types/resources/WebsiteOperator.d.ts +0 -15
- package/types/resources/WebsitePeople.d.ts +0 -15
- package/types/resources/WebsiteSettings.d.ts +0 -15
- package/types/resources/WebsiteVerify.d.ts +0 -15
- package/types/resources/WebsiteVisitors.d.ts +0 -15
- package/types/services/Bucket.d.ts +0 -14
- package/types/services/Media.d.ts +0 -14
- package/types/services/Plugin.d.ts +0 -14
- package/types/services/Website.d.ts +0 -14
|
@@ -0,0 +1,1416 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* node-crisp-api
|
|
3
|
+
*
|
|
4
|
+
* Copyright 2022, Crisp IM SAS
|
|
5
|
+
* Author: Baptiste Jamin <baptiste@crisp.chat>
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
/**************************************************************************
|
|
9
|
+
* IMPORTS
|
|
10
|
+
***************************************************************************/
|
|
11
|
+
|
|
12
|
+
// PROJECT: RESOURCES
|
|
13
|
+
import BaseResource from "./BaseResource";
|
|
14
|
+
|
|
15
|
+
export interface Conversation {
|
|
16
|
+
session_id: string;
|
|
17
|
+
website_id: string;
|
|
18
|
+
inbox_id?: string;
|
|
19
|
+
people_id?: string;
|
|
20
|
+
state?: ConversationState;
|
|
21
|
+
status?: number;
|
|
22
|
+
is_verified?: boolean;
|
|
23
|
+
is_blocked?: boolean;
|
|
24
|
+
availability?: string;
|
|
25
|
+
active?: ConversationActive;
|
|
26
|
+
last_message?: string;
|
|
27
|
+
preview_message?: ConversationPreviewMessage;
|
|
28
|
+
topic?: string;
|
|
29
|
+
verifications?: ConversationVerification[];
|
|
30
|
+
participants?: ConversationParticipant[];
|
|
31
|
+
mentions?: string[];
|
|
32
|
+
compose?: ConversationCompose;
|
|
33
|
+
unread?: ConversationUnread;
|
|
34
|
+
assigned?: ConversationAssigned;
|
|
35
|
+
meta?: ConversationMeta;
|
|
36
|
+
created_at?: number;
|
|
37
|
+
updated_at?: number;
|
|
38
|
+
waiting_since?: number;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
type ConversationNew = {
|
|
42
|
+
session_id?: string;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export interface ConversationActive {
|
|
46
|
+
now?: boolean;
|
|
47
|
+
last?: number;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export interface ConversationPreviewMessage {
|
|
51
|
+
type?: string;
|
|
52
|
+
from?: string;
|
|
53
|
+
excerpt?: string;
|
|
54
|
+
fingerprint?: number;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
export interface ConversationCompose {
|
|
58
|
+
operator?: ConversationComposeAtom;
|
|
59
|
+
visitor?: ConversationComposeAtom;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export interface ConversationComposeAtom {
|
|
63
|
+
type?: string;
|
|
64
|
+
excerpt?: string;
|
|
65
|
+
timestamp?: number;
|
|
66
|
+
user?: ConversationComposeAtomUser;
|
|
67
|
+
automated?: boolean;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
export interface ConversationComposeAtomUser {
|
|
71
|
+
user_id?: string;
|
|
72
|
+
nickname?: string;
|
|
73
|
+
avatar?: string;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
export interface ConversationUnread {
|
|
77
|
+
operator?: number;
|
|
78
|
+
visitor?: number;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
export interface ConversationAssigned {
|
|
82
|
+
user_id?: string;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
export interface ConversationVerification {
|
|
86
|
+
identity?: string;
|
|
87
|
+
method?: string;
|
|
88
|
+
annotation?: string;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
export interface ConversationParticipant {
|
|
92
|
+
type?: string;
|
|
93
|
+
target?: string;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
export interface ConversationParticipants {
|
|
97
|
+
participants?: ConversationParticipant[];
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
export interface ConversationParticipantsSave {
|
|
101
|
+
participants?: ConversationParticipant[];
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
export interface ConversationMeta {
|
|
105
|
+
nickname: string;
|
|
106
|
+
email?: string;
|
|
107
|
+
phone?: string;
|
|
108
|
+
ip?: string;
|
|
109
|
+
avatar?: string;
|
|
110
|
+
data?: Record<string, unknown>;
|
|
111
|
+
connection?: ConnectionInfo;
|
|
112
|
+
device?: DeviceInfo;
|
|
113
|
+
segments?: string[];
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
export interface ConnectionInfo {
|
|
117
|
+
isp?: string;
|
|
118
|
+
asn?: string;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
export interface DeviceInfo {
|
|
122
|
+
capabilities?: string[];
|
|
123
|
+
geolocation?: GeolocationInfo;
|
|
124
|
+
system?: SystemInfo;
|
|
125
|
+
timezone?: number;
|
|
126
|
+
locales?: string[];
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
export interface GeolocationInfo {
|
|
130
|
+
country?: string;
|
|
131
|
+
region?: string;
|
|
132
|
+
city?: string;
|
|
133
|
+
coordinates?: Coordinates;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
export interface Coordinates {
|
|
137
|
+
latitude?: number;
|
|
138
|
+
longitude?: number;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
export interface SystemInfo {
|
|
142
|
+
os?: OSInfo;
|
|
143
|
+
engine?: EngineInfo;
|
|
144
|
+
browser?: BrowserInfo;
|
|
145
|
+
useragent?: string;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
export interface OSInfo {
|
|
149
|
+
version?: string;
|
|
150
|
+
name?: string;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
export interface EngineInfo {
|
|
154
|
+
name?: string;
|
|
155
|
+
version?: string;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
export interface BrowserInfo {
|
|
159
|
+
major?: string;
|
|
160
|
+
version?: string;
|
|
161
|
+
name?: string;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
export type ConversationMessageType =
|
|
165
|
+
| "text"
|
|
166
|
+
| "file"
|
|
167
|
+
| "animation"
|
|
168
|
+
| "audio"
|
|
169
|
+
| "carousel"
|
|
170
|
+
| "note"
|
|
171
|
+
| "picker"
|
|
172
|
+
| "field";
|
|
173
|
+
|
|
174
|
+
export type ConversationState = "pending" | "unresolved" | "resolved";
|
|
175
|
+
|
|
176
|
+
export type ConversationContent = (
|
|
177
|
+
string |
|
|
178
|
+
ConversationFileMessageContent |
|
|
179
|
+
ConversationAnimationMessageContent |
|
|
180
|
+
ConversationAudioMessageContent |
|
|
181
|
+
ConversationPickerMessageContent |
|
|
182
|
+
ConversationFieldMessageContent |
|
|
183
|
+
ConversationCarouselMessageContent |
|
|
184
|
+
ConversationEventMessageContent
|
|
185
|
+
)
|
|
186
|
+
|
|
187
|
+
export interface ConversationMessage {
|
|
188
|
+
session_id?: string;
|
|
189
|
+
website_id?: string;
|
|
190
|
+
type?: ConversationMessageType;
|
|
191
|
+
from?: string;
|
|
192
|
+
origin?: string;
|
|
193
|
+
content?: ConversationContent;
|
|
194
|
+
preview?: ConversationMessagePreview[];
|
|
195
|
+
mentions?: string[];
|
|
196
|
+
read?: string;
|
|
197
|
+
delivered?: string;
|
|
198
|
+
ignored?: Record<string, ConversationMessageIgnored>;
|
|
199
|
+
edited?: boolean;
|
|
200
|
+
translated?: boolean;
|
|
201
|
+
automated?: boolean;
|
|
202
|
+
fingerprint?: number;
|
|
203
|
+
timestamp?: number;
|
|
204
|
+
user?: ConversationMessageUser;
|
|
205
|
+
references?: ConversationMessageReference[];
|
|
206
|
+
original?: ConversationMessageOriginal;
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
export interface ConversationFileMessageContent {
|
|
210
|
+
name?: string;
|
|
211
|
+
url?: string;
|
|
212
|
+
type?: string;
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
export interface ConversationAnimationMessageContent {
|
|
216
|
+
url?: string;
|
|
217
|
+
type?: string;
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
export interface ConversationAudioMessageContent {
|
|
221
|
+
url?: string;
|
|
222
|
+
type?: string;
|
|
223
|
+
duration?: number;
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
export interface ConversationPickerMessageContent {
|
|
227
|
+
id?: string;
|
|
228
|
+
text?: string;
|
|
229
|
+
choices?: ConversationPickerMessageContentChoice[];
|
|
230
|
+
required?: boolean;
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
export interface ConversationPickerMessageContentChoice {
|
|
234
|
+
value?: string;
|
|
235
|
+
icon?: string;
|
|
236
|
+
label?: string;
|
|
237
|
+
selected?: boolean;
|
|
238
|
+
action?: ConversationPickerMessageContentChoiceAction;
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
export interface ConversationPickerMessageContentChoiceAction {
|
|
242
|
+
type?: string;
|
|
243
|
+
target?: string;
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
export interface ConversationFieldMessageContent {
|
|
247
|
+
id?: string;
|
|
248
|
+
text?: string;
|
|
249
|
+
explain?: string;
|
|
250
|
+
value?: string;
|
|
251
|
+
required?: boolean;
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
export interface ConversationCarouselMessageContent {
|
|
255
|
+
text?: string;
|
|
256
|
+
targets?: ConversationCarouselMessageContentTarget[];
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
export interface ConversationCarouselMessageContentTarget {
|
|
260
|
+
title?: string;
|
|
261
|
+
description?: string;
|
|
262
|
+
image?: string;
|
|
263
|
+
actions?: ConversationCarouselMessageContentTargetAction[];
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
export interface ConversationCarouselMessageContentTargetAction {
|
|
267
|
+
label?: string;
|
|
268
|
+
url?: string;
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
export interface ConversationEventMessageContent {
|
|
272
|
+
namespace?: string;
|
|
273
|
+
text?: string;
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
export interface ConversationMessagePreview {
|
|
277
|
+
url?: string;
|
|
278
|
+
website?: string;
|
|
279
|
+
title?: string;
|
|
280
|
+
preview?: ConversationMessagePreviewInformation;
|
|
281
|
+
stamped?: boolean;
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
export interface ConversationMessagePreviewInformation {
|
|
285
|
+
excerpt?: string;
|
|
286
|
+
image?: string;
|
|
287
|
+
embed?: string;
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
export interface ConversationMessageIgnored {
|
|
291
|
+
type?: string;
|
|
292
|
+
reason?: string;
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
export interface ConversationMessageUser {
|
|
296
|
+
type?: string;
|
|
297
|
+
user_id?: string;
|
|
298
|
+
nickname?: string;
|
|
299
|
+
avatar?: string;
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
export interface ConversationMessageReference {
|
|
303
|
+
type?: string;
|
|
304
|
+
name?: string;
|
|
305
|
+
target?: string;
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
export interface ConversationMessageOriginal {
|
|
309
|
+
original_id?: string;
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
export type ConversationMessageNew = (
|
|
313
|
+
ConversationTextMessageNew |
|
|
314
|
+
ConversationFileMessageNew |
|
|
315
|
+
ConversationAnimationMessageNew |
|
|
316
|
+
ConversationAudioMessageNew |
|
|
317
|
+
ConversationPickerMessageNew |
|
|
318
|
+
ConversationFieldMessageNew |
|
|
319
|
+
ConversationCarouselMessageNew |
|
|
320
|
+
ConversationNoteMessageNew |
|
|
321
|
+
ConversationEventMessageNew
|
|
322
|
+
)
|
|
323
|
+
|
|
324
|
+
export interface ConversationTextMessageNew {
|
|
325
|
+
type: "text" | "note";
|
|
326
|
+
from: string;
|
|
327
|
+
origin: string;
|
|
328
|
+
content: unknown;
|
|
329
|
+
mentions?: string[];
|
|
330
|
+
fingerprint?: number;
|
|
331
|
+
user?: ConversationMessageUser;
|
|
332
|
+
references?: ConversationMessageReference[];
|
|
333
|
+
original?: ConversationMessageOriginal;
|
|
334
|
+
timestamp?: number;
|
|
335
|
+
stealth?: boolean;
|
|
336
|
+
translated?: boolean;
|
|
337
|
+
automated?: boolean;
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
export interface ConversationFileMessageNew {
|
|
341
|
+
type: "file";
|
|
342
|
+
from?: string;
|
|
343
|
+
origin?: string;
|
|
344
|
+
content?: ConversationFileMessageContent;
|
|
345
|
+
mentions?: string[];
|
|
346
|
+
fingerprint?: number;
|
|
347
|
+
user?: ConversationMessageUser;
|
|
348
|
+
references?: ConversationMessageReference[];
|
|
349
|
+
original?: ConversationMessageOriginal;
|
|
350
|
+
timestamp?: number;
|
|
351
|
+
stealth?: boolean;
|
|
352
|
+
translated?: boolean;
|
|
353
|
+
automated?: boolean;
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
export interface ConversationAnimationMessageNew {
|
|
357
|
+
type: "animation";
|
|
358
|
+
from?: string;
|
|
359
|
+
origin?: string;
|
|
360
|
+
content?: ConversationAnimationMessageContent;
|
|
361
|
+
mentions?: string[];
|
|
362
|
+
fingerprint?: number;
|
|
363
|
+
user?: ConversationMessageUser;
|
|
364
|
+
references?: ConversationMessageReference[];
|
|
365
|
+
original?: ConversationMessageOriginal;
|
|
366
|
+
timestamp?: number;
|
|
367
|
+
stealth?: boolean;
|
|
368
|
+
translated?: boolean;
|
|
369
|
+
automated?: boolean;
|
|
370
|
+
}
|
|
371
|
+
|
|
372
|
+
export interface ConversationAudioMessageNew {
|
|
373
|
+
type: "audio";
|
|
374
|
+
from?: string;
|
|
375
|
+
origin?: string;
|
|
376
|
+
content?: ConversationAudioMessageContent;
|
|
377
|
+
mentions?: string[];
|
|
378
|
+
fingerprint?: number;
|
|
379
|
+
user?: ConversationMessageUser;
|
|
380
|
+
references?: ConversationMessageReference[];
|
|
381
|
+
original?: ConversationMessageOriginal;
|
|
382
|
+
timestamp?: number;
|
|
383
|
+
stealth?: boolean;
|
|
384
|
+
translated?: boolean;
|
|
385
|
+
automated?: boolean;
|
|
386
|
+
}
|
|
387
|
+
|
|
388
|
+
export interface ConversationPickerMessageNew {
|
|
389
|
+
type: "picker";
|
|
390
|
+
from?: string;
|
|
391
|
+
origin?: string;
|
|
392
|
+
content?: ConversationPickerMessageContent;
|
|
393
|
+
mentions?: string[];
|
|
394
|
+
fingerprint?: number;
|
|
395
|
+
user?: ConversationMessageUser;
|
|
396
|
+
references?: ConversationMessageReference[];
|
|
397
|
+
original?: ConversationMessageOriginal;
|
|
398
|
+
timestamp?: number;
|
|
399
|
+
stealth?: boolean;
|
|
400
|
+
translated?: boolean;
|
|
401
|
+
automated?: boolean;
|
|
402
|
+
}
|
|
403
|
+
|
|
404
|
+
export interface ConversationFieldMessageNew {
|
|
405
|
+
type: "field";
|
|
406
|
+
from?: string;
|
|
407
|
+
origin?: string;
|
|
408
|
+
content?: ConversationFieldMessageContent;
|
|
409
|
+
mentions?: string[];
|
|
410
|
+
fingerprint?: number;
|
|
411
|
+
user?: ConversationMessageUser;
|
|
412
|
+
references?: ConversationMessageReference[];
|
|
413
|
+
original?: ConversationMessageOriginal;
|
|
414
|
+
timestamp?: number;
|
|
415
|
+
stealth?: boolean;
|
|
416
|
+
translated?: boolean;
|
|
417
|
+
automated?: boolean;
|
|
418
|
+
}
|
|
419
|
+
|
|
420
|
+
export interface ConversationCarouselMessageNew {
|
|
421
|
+
type: "carousel";
|
|
422
|
+
from?: string;
|
|
423
|
+
origin?: string;
|
|
424
|
+
content?: ConversationCarouselMessageContent;
|
|
425
|
+
mentions?: string[];
|
|
426
|
+
fingerprint?: number;
|
|
427
|
+
user?: ConversationMessageUser;
|
|
428
|
+
references?: ConversationMessageReference[];
|
|
429
|
+
original?: ConversationMessageOriginal;
|
|
430
|
+
timestamp?: number;
|
|
431
|
+
stealth?: boolean;
|
|
432
|
+
translated?: boolean;
|
|
433
|
+
automated?: boolean;
|
|
434
|
+
}
|
|
435
|
+
|
|
436
|
+
export interface ConversationNoteMessageNew extends ConversationTextMessageNew {
|
|
437
|
+
type: "note";
|
|
438
|
+
}
|
|
439
|
+
|
|
440
|
+
export interface ConversationEventMessageNew {
|
|
441
|
+
type: "event";
|
|
442
|
+
from?: string;
|
|
443
|
+
origin?: string;
|
|
444
|
+
content?: ConversationEventMessageContent;
|
|
445
|
+
mentions?: string[];
|
|
446
|
+
fingerprint?: number;
|
|
447
|
+
user?: ConversationMessageUser;
|
|
448
|
+
references?: ConversationMessageReference[];
|
|
449
|
+
original?: ConversationMessageOriginal;
|
|
450
|
+
timestamp?: number;
|
|
451
|
+
stealth?: boolean;
|
|
452
|
+
translated?: boolean;
|
|
453
|
+
automated?: boolean;
|
|
454
|
+
}
|
|
455
|
+
|
|
456
|
+
export interface ConversationComposeMessageNew {
|
|
457
|
+
type: string;
|
|
458
|
+
from: string;
|
|
459
|
+
excerpt?: string;
|
|
460
|
+
stealth?: boolean;
|
|
461
|
+
automated?: boolean;
|
|
462
|
+
}
|
|
463
|
+
|
|
464
|
+
export interface ConversationSuggestedSegment {
|
|
465
|
+
segment?: string;
|
|
466
|
+
count?: number;
|
|
467
|
+
}
|
|
468
|
+
|
|
469
|
+
export interface ConversationSuggestedData {
|
|
470
|
+
key?: string;
|
|
471
|
+
count?: number;
|
|
472
|
+
}
|
|
473
|
+
|
|
474
|
+
export interface ConversationSpam {
|
|
475
|
+
spam_id?: string;
|
|
476
|
+
type?: string;
|
|
477
|
+
reason?: string;
|
|
478
|
+
metadata?: Record<string, unknown>;
|
|
479
|
+
headers?: Record<string, unknown>;
|
|
480
|
+
timestamp?: number;
|
|
481
|
+
}
|
|
482
|
+
|
|
483
|
+
export interface ConversationSpamContent extends ConversationSpam {
|
|
484
|
+
content?: Record<string, unknown>;
|
|
485
|
+
}
|
|
486
|
+
|
|
487
|
+
export interface ConversationReadMessageMark {
|
|
488
|
+
from?: string;
|
|
489
|
+
origin?: string;
|
|
490
|
+
fingerprints?: number[];
|
|
491
|
+
}
|
|
492
|
+
|
|
493
|
+
export interface ConversationUnreadMessageMark {
|
|
494
|
+
from?: string;
|
|
495
|
+
}
|
|
496
|
+
|
|
497
|
+
export interface ConversationRoutingAssignUpdate {
|
|
498
|
+
assigned?: ConversationRoutingAssignUpdateAssigned;
|
|
499
|
+
silent?: boolean;
|
|
500
|
+
}
|
|
501
|
+
|
|
502
|
+
export interface ConversationRoutingAssignUpdateAssigned {
|
|
503
|
+
user_id?: string;
|
|
504
|
+
}
|
|
505
|
+
|
|
506
|
+
export interface ConversationOriginal {
|
|
507
|
+
website_id?: string;
|
|
508
|
+
session_id?: string;
|
|
509
|
+
original_id?: string;
|
|
510
|
+
type?: string;
|
|
511
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
512
|
+
headers?: Record<string, any>;
|
|
513
|
+
content?: string;
|
|
514
|
+
timestamp?: number;
|
|
515
|
+
}
|
|
516
|
+
|
|
517
|
+
export interface ConversationPage {
|
|
518
|
+
page_title?: string;
|
|
519
|
+
page_url?: string;
|
|
520
|
+
page_referrer?: string;
|
|
521
|
+
timestamp?: number;
|
|
522
|
+
}
|
|
523
|
+
|
|
524
|
+
export interface ConversationEvent {
|
|
525
|
+
text?: string;
|
|
526
|
+
data?: Record<string, any>;
|
|
527
|
+
color?: string;
|
|
528
|
+
timestamp?: number;
|
|
529
|
+
}
|
|
530
|
+
|
|
531
|
+
export interface ConversationFile {
|
|
532
|
+
name?: string;
|
|
533
|
+
type?: string;
|
|
534
|
+
url?: string;
|
|
535
|
+
fingerprint?: number;
|
|
536
|
+
timestamp?: number;
|
|
537
|
+
}
|
|
538
|
+
|
|
539
|
+
export interface ConversationStateData {
|
|
540
|
+
state?: ConversationState;
|
|
541
|
+
}
|
|
542
|
+
|
|
543
|
+
export interface ConversationBlock {
|
|
544
|
+
blocked?: boolean;
|
|
545
|
+
}
|
|
546
|
+
|
|
547
|
+
export interface ConversationVerify {
|
|
548
|
+
verified?: boolean;
|
|
549
|
+
verifications?: ConversationVerification[];
|
|
550
|
+
}
|
|
551
|
+
|
|
552
|
+
export interface ConversationVerifyIdentityRequest {
|
|
553
|
+
identity?: string;
|
|
554
|
+
method?: string;
|
|
555
|
+
recipient?: string;
|
|
556
|
+
}
|
|
557
|
+
|
|
558
|
+
export interface ConversationVerifyIdentityRedeem {
|
|
559
|
+
identity?: string;
|
|
560
|
+
token?: string;
|
|
561
|
+
recipient?: string;
|
|
562
|
+
}
|
|
563
|
+
|
|
564
|
+
export interface ConversationBrowsing {
|
|
565
|
+
browsing_id?: string;
|
|
566
|
+
browsing_token?: string;
|
|
567
|
+
useragent?: string;
|
|
568
|
+
}
|
|
569
|
+
|
|
570
|
+
export interface ConversationCall {
|
|
571
|
+
call_id?: string;
|
|
572
|
+
}
|
|
573
|
+
|
|
574
|
+
/**
|
|
575
|
+
* Crisp WebsiteConversation Resource
|
|
576
|
+
* @class
|
|
577
|
+
*/
|
|
578
|
+
class WebsiteConversation extends BaseResource {
|
|
579
|
+
/**
|
|
580
|
+
* List Conversations
|
|
581
|
+
*/
|
|
582
|
+
listConversations(websiteID: string, pageNumber: number = 1) : Promise<Conversation[]> {
|
|
583
|
+
return this.crisp.get(
|
|
584
|
+
this.crisp.prepareRestUrl(["website", websiteID, "conversations", String(pageNumber)])
|
|
585
|
+
);
|
|
586
|
+
};
|
|
587
|
+
|
|
588
|
+
/**
|
|
589
|
+
* List Suggested Conversation Segments
|
|
590
|
+
*/
|
|
591
|
+
listSuggestedConversationSegments(websiteID: string, pageNumber: number = 1) : Promise<ConversationSuggestedSegment[]> {
|
|
592
|
+
return this.crisp.get(
|
|
593
|
+
this.crisp.prepareRestUrl([
|
|
594
|
+
"website", websiteID, "conversations", "suggest", "segments", String(pageNumber)
|
|
595
|
+
])
|
|
596
|
+
);
|
|
597
|
+
};
|
|
598
|
+
|
|
599
|
+
/**
|
|
600
|
+
* Delete Suggested Conversation Segment
|
|
601
|
+
*/
|
|
602
|
+
deleteSuggestedConversationSegment(websiteID: string, segment: string) {
|
|
603
|
+
return this.crisp.delete(
|
|
604
|
+
this.crisp.prepareRestUrl([
|
|
605
|
+
"website", websiteID, "conversations", "suggest", "segment"
|
|
606
|
+
]),
|
|
607
|
+
|
|
608
|
+
null,
|
|
609
|
+
|
|
610
|
+
{
|
|
611
|
+
segment: segment
|
|
612
|
+
}
|
|
613
|
+
);
|
|
614
|
+
};
|
|
615
|
+
|
|
616
|
+
/**
|
|
617
|
+
* List Suggested Conversation Data Keys
|
|
618
|
+
*/
|
|
619
|
+
listSuggestedConversationDataKeys(websiteID: string, pageNumber: number = 1) : Promise<ConversationSuggestedData[]> {
|
|
620
|
+
return this.crisp.get(
|
|
621
|
+
this.crisp.prepareRestUrl([
|
|
622
|
+
"website", websiteID, "conversations", "suggest", "data", String(pageNumber)
|
|
623
|
+
])
|
|
624
|
+
);
|
|
625
|
+
};
|
|
626
|
+
|
|
627
|
+
/**
|
|
628
|
+
* Delete Suggested Conversation Data Key
|
|
629
|
+
*/
|
|
630
|
+
deleteSuggestedConversationDataKey(websiteID: string, key: string) {
|
|
631
|
+
return this.crisp.delete(
|
|
632
|
+
this.crisp.prepareRestUrl([
|
|
633
|
+
"website", websiteID, "conversations", "suggest", "data"
|
|
634
|
+
]),
|
|
635
|
+
|
|
636
|
+
null,
|
|
637
|
+
|
|
638
|
+
{
|
|
639
|
+
key: key
|
|
640
|
+
}
|
|
641
|
+
);
|
|
642
|
+
};
|
|
643
|
+
|
|
644
|
+
/**
|
|
645
|
+
* List Spam Conversations
|
|
646
|
+
*/
|
|
647
|
+
listSpamConversations(websiteID: string, pageNumber: number = 1) : Promise<ConversationSpam[]> {
|
|
648
|
+
return this.crisp.get(
|
|
649
|
+
this.crisp.prepareRestUrl([
|
|
650
|
+
"website", websiteID, "conversations", "spams", String(pageNumber)
|
|
651
|
+
])
|
|
652
|
+
);
|
|
653
|
+
};
|
|
654
|
+
|
|
655
|
+
/**
|
|
656
|
+
* Resolve Spam Conversation Content
|
|
657
|
+
*/
|
|
658
|
+
resolveSpamConversationContent(websiteID: string, spamID: string) : Promise<ConversationSpamContent> {
|
|
659
|
+
return this.crisp.get(
|
|
660
|
+
this.crisp.prepareRestUrl([
|
|
661
|
+
"website", websiteID, "conversations", "spam", spamID, "content"
|
|
662
|
+
])
|
|
663
|
+
);
|
|
664
|
+
};
|
|
665
|
+
|
|
666
|
+
/**
|
|
667
|
+
* Submit Spam Conversation Decision
|
|
668
|
+
*/
|
|
669
|
+
submitSpamConversationDecision(websiteID: string, spamID: string, action: string) {
|
|
670
|
+
return this.crisp.post(
|
|
671
|
+
this.crisp.prepareRestUrl([
|
|
672
|
+
"website", websiteID, "conversations", "spam", spamID, "decision"
|
|
673
|
+
]),
|
|
674
|
+
|
|
675
|
+
null,
|
|
676
|
+
|
|
677
|
+
{
|
|
678
|
+
action: action
|
|
679
|
+
}
|
|
680
|
+
);
|
|
681
|
+
};
|
|
682
|
+
|
|
683
|
+
/**
|
|
684
|
+
* Create A New Conversation
|
|
685
|
+
*/
|
|
686
|
+
createNewConversation(websiteID: string) : Promise<ConversationNew> {
|
|
687
|
+
return this.crisp.post(
|
|
688
|
+
this.crisp.prepareRestUrl(["website", websiteID, "conversation"]),
|
|
689
|
+
|
|
690
|
+
null,
|
|
691
|
+
|
|
692
|
+
null
|
|
693
|
+
);
|
|
694
|
+
};
|
|
695
|
+
|
|
696
|
+
/**
|
|
697
|
+
* Check If Conversation Exists
|
|
698
|
+
*/
|
|
699
|
+
checkConversationExists(websiteID: string, sessionID: string) {
|
|
700
|
+
return this.crisp.head(
|
|
701
|
+
this.crisp.prepareRestUrl(["website", websiteID, "conversation", sessionID])
|
|
702
|
+
);
|
|
703
|
+
};
|
|
704
|
+
|
|
705
|
+
/**
|
|
706
|
+
* Get A Conversation
|
|
707
|
+
*/
|
|
708
|
+
getConversation(websiteID: string, sessionID: string) : Promise<Conversation> {
|
|
709
|
+
return this.crisp.get(
|
|
710
|
+
this.crisp.prepareRestUrl(["website", websiteID, "conversation", sessionID])
|
|
711
|
+
);
|
|
712
|
+
};
|
|
713
|
+
|
|
714
|
+
/**
|
|
715
|
+
* Remove A Conversation
|
|
716
|
+
*/
|
|
717
|
+
removeConversation(websiteID: string, sessionID: string) {
|
|
718
|
+
return this.crisp.delete(
|
|
719
|
+
this.crisp.prepareRestUrl(["website", websiteID, "conversation", sessionID])
|
|
720
|
+
);
|
|
721
|
+
};
|
|
722
|
+
|
|
723
|
+
/**
|
|
724
|
+
* Initiate A Conversation With Existing Session
|
|
725
|
+
*/
|
|
726
|
+
initiateConversationWithExistingSession(websiteID: string, sessionID: string) {
|
|
727
|
+
return this.crisp.post(
|
|
728
|
+
this.crisp.prepareRestUrl([
|
|
729
|
+
"website", websiteID, "conversation", sessionID, "initiate"
|
|
730
|
+
]),
|
|
731
|
+
|
|
732
|
+
null,
|
|
733
|
+
|
|
734
|
+
null
|
|
735
|
+
);
|
|
736
|
+
};
|
|
737
|
+
|
|
738
|
+
/**
|
|
739
|
+
* Get Messages In Conversation
|
|
740
|
+
*/
|
|
741
|
+
getMessagesInConversation(websiteID: string, sessionID: string, timestampBefore?: string|number) : Promise<ConversationMessage[]> {
|
|
742
|
+
// Generate query
|
|
743
|
+
let query = {};
|
|
744
|
+
|
|
745
|
+
if (timestampBefore) {
|
|
746
|
+
// @ts-ignore
|
|
747
|
+
query.timestamp_before = String(timestampBefore);
|
|
748
|
+
}
|
|
749
|
+
|
|
750
|
+
return this.crisp.get(
|
|
751
|
+
this.crisp.prepareRestUrl([
|
|
752
|
+
"website", websiteID, "conversation", sessionID, "messages"
|
|
753
|
+
]),
|
|
754
|
+
|
|
755
|
+
query
|
|
756
|
+
);
|
|
757
|
+
};
|
|
758
|
+
|
|
759
|
+
/**
|
|
760
|
+
* Send A Message In Conversation
|
|
761
|
+
*/
|
|
762
|
+
sendMessageInConversation(websiteID: string, sessionID: string, message: ConversationMessageNew) {
|
|
763
|
+
return this.crisp.post(
|
|
764
|
+
this.crisp.prepareRestUrl([
|
|
765
|
+
"website", websiteID, "conversation", sessionID, "message"
|
|
766
|
+
]),
|
|
767
|
+
|
|
768
|
+
null, message
|
|
769
|
+
);
|
|
770
|
+
};
|
|
771
|
+
|
|
772
|
+
/**
|
|
773
|
+
* Get A Message In Conversation
|
|
774
|
+
*/
|
|
775
|
+
getMessageInConversation(websiteID: string, sessionID: string, fingerprint: number) : Promise<ConversationMessage> {
|
|
776
|
+
return this.crisp.get(
|
|
777
|
+
this.crisp.prepareRestUrl([
|
|
778
|
+
"website", websiteID, "conversation", sessionID, "message", String(fingerprint)
|
|
779
|
+
])
|
|
780
|
+
);
|
|
781
|
+
};
|
|
782
|
+
|
|
783
|
+
/**
|
|
784
|
+
* Update A Message In Conversation
|
|
785
|
+
*/
|
|
786
|
+
updateMessageInConversation(websiteID: string, sessionID: string, fingerprint: number, content: ConversationContent) {
|
|
787
|
+
return this.crisp.patch(
|
|
788
|
+
this.crisp.prepareRestUrl([
|
|
789
|
+
"website", websiteID, "conversation", sessionID, "message", String(fingerprint)
|
|
790
|
+
]),
|
|
791
|
+
|
|
792
|
+
null,
|
|
793
|
+
|
|
794
|
+
{
|
|
795
|
+
content: content
|
|
796
|
+
}
|
|
797
|
+
);
|
|
798
|
+
};
|
|
799
|
+
|
|
800
|
+
/**
|
|
801
|
+
* Remove A Message In Conversation
|
|
802
|
+
*/
|
|
803
|
+
removeMessageInConversation(websiteID: string, sessionID: string, fingerprint: number) {
|
|
804
|
+
return this.crisp.delete(
|
|
805
|
+
this.crisp.prepareRestUrl([
|
|
806
|
+
"website", websiteID, "conversation", sessionID, "message", String(fingerprint)
|
|
807
|
+
])
|
|
808
|
+
);
|
|
809
|
+
};
|
|
810
|
+
|
|
811
|
+
/**
|
|
812
|
+
* Compose A Message In Conversation
|
|
813
|
+
*/
|
|
814
|
+
composeMessageInConversation(websiteID: string, sessionID: string, compose: ConversationComposeMessageNew) {
|
|
815
|
+
return this.crisp.patch(
|
|
816
|
+
this.crisp.prepareRestUrl([
|
|
817
|
+
"website", websiteID, "conversation", sessionID, "compose"
|
|
818
|
+
]),
|
|
819
|
+
|
|
820
|
+
null, compose
|
|
821
|
+
);
|
|
822
|
+
};
|
|
823
|
+
|
|
824
|
+
/**
|
|
825
|
+
* Mark Messages As Read In Conversation
|
|
826
|
+
*/
|
|
827
|
+
markMessagesReadInConversation(websiteID: string, sessionID: string, read: ConversationReadMessageMark) {
|
|
828
|
+
return this.crisp.patch(
|
|
829
|
+
this.crisp.prepareRestUrl([
|
|
830
|
+
"website", websiteID, "conversation", sessionID, "read"
|
|
831
|
+
]),
|
|
832
|
+
|
|
833
|
+
null, read
|
|
834
|
+
);
|
|
835
|
+
};
|
|
836
|
+
|
|
837
|
+
/**
|
|
838
|
+
* Mark Conversation As Unread
|
|
839
|
+
*/
|
|
840
|
+
markConversationAsUnread(websiteID: string, sessionID: string, unread: ConversationUnreadMessageMark) {
|
|
841
|
+
return this.crisp.patch(
|
|
842
|
+
this.crisp.prepareRestUrl([
|
|
843
|
+
"website", websiteID, "conversation", sessionID, "unread"
|
|
844
|
+
]),
|
|
845
|
+
|
|
846
|
+
null, unread
|
|
847
|
+
);
|
|
848
|
+
};
|
|
849
|
+
|
|
850
|
+
/**
|
|
851
|
+
* Mark Messages As Delivered In Conversation
|
|
852
|
+
*/
|
|
853
|
+
markMessagesDeliveredInConversation(websiteID: string, sessionID: string, delivered: ConversationReadMessageMark) {
|
|
854
|
+
return this.crisp.patch(
|
|
855
|
+
this.crisp.prepareRestUrl([
|
|
856
|
+
"website", websiteID, "conversation", sessionID, "delivered"
|
|
857
|
+
]),
|
|
858
|
+
|
|
859
|
+
null, delivered
|
|
860
|
+
);
|
|
861
|
+
};
|
|
862
|
+
|
|
863
|
+
/**
|
|
864
|
+
* Update Conversation Open State
|
|
865
|
+
*/
|
|
866
|
+
updateConversationOpenState(websiteID: string, sessionID: string, opened: boolean) {
|
|
867
|
+
return this.crisp.patch(
|
|
868
|
+
this.crisp.prepareRestUrl([
|
|
869
|
+
"website", websiteID, "conversation", sessionID, "open"
|
|
870
|
+
]),
|
|
871
|
+
|
|
872
|
+
null,
|
|
873
|
+
|
|
874
|
+
{
|
|
875
|
+
opened: (opened || false)
|
|
876
|
+
}
|
|
877
|
+
);
|
|
878
|
+
};
|
|
879
|
+
|
|
880
|
+
/**
|
|
881
|
+
* Get Conversation Routing Assign
|
|
882
|
+
*/
|
|
883
|
+
getConversationRoutingAssign(websiteID: string, sessionID: string) {
|
|
884
|
+
return this.crisp.get(
|
|
885
|
+
this.crisp.prepareRestUrl([
|
|
886
|
+
"website", websiteID, "conversation", sessionID, "routing"
|
|
887
|
+
])
|
|
888
|
+
);
|
|
889
|
+
};
|
|
890
|
+
|
|
891
|
+
/**
|
|
892
|
+
* Assign Conversation Routing
|
|
893
|
+
*/
|
|
894
|
+
assignConversationRouting(websiteID: string, sessionID: string, assign: ConversationRoutingAssignUpdate) {
|
|
895
|
+
return this.crisp.patch(
|
|
896
|
+
this.crisp.prepareRestUrl([
|
|
897
|
+
"website", websiteID, "conversation", sessionID, "routing"
|
|
898
|
+
]),
|
|
899
|
+
|
|
900
|
+
null, assign
|
|
901
|
+
);
|
|
902
|
+
};
|
|
903
|
+
|
|
904
|
+
/**
|
|
905
|
+
* Update Conversation Inbox
|
|
906
|
+
*/
|
|
907
|
+
updateConversationInbox(websiteID: string, sessionID: string, inboxID: string) {
|
|
908
|
+
return this.crisp.patch(
|
|
909
|
+
this.crisp.prepareRestUrl([
|
|
910
|
+
"website", websiteID, "conversation", sessionID, "inbox"
|
|
911
|
+
]),
|
|
912
|
+
|
|
913
|
+
null,
|
|
914
|
+
|
|
915
|
+
{
|
|
916
|
+
inbox_id: inboxID
|
|
917
|
+
}
|
|
918
|
+
);
|
|
919
|
+
}
|
|
920
|
+
|
|
921
|
+
/**
|
|
922
|
+
* Get Conversation Metas
|
|
923
|
+
*/
|
|
924
|
+
getConversationMetas(websiteID: string, sessionID: string) : Promise<ConversationMeta> {
|
|
925
|
+
return this.crisp.get(
|
|
926
|
+
this.crisp.prepareRestUrl([
|
|
927
|
+
"website", websiteID, "conversation", sessionID, "meta"
|
|
928
|
+
])
|
|
929
|
+
);
|
|
930
|
+
}
|
|
931
|
+
|
|
932
|
+
/**
|
|
933
|
+
* Update Conversation Metas
|
|
934
|
+
*/
|
|
935
|
+
updateConversationMetas(websiteID: string, sessionID: string, metas: ConversationMeta) {
|
|
936
|
+
return this.crisp.patch(
|
|
937
|
+
this.crisp.prepareRestUrl([
|
|
938
|
+
"website", websiteID, "conversation", sessionID, "meta"
|
|
939
|
+
]),
|
|
940
|
+
|
|
941
|
+
null, metas
|
|
942
|
+
);
|
|
943
|
+
}
|
|
944
|
+
|
|
945
|
+
/**
|
|
946
|
+
* Get An Original Message In Conversation
|
|
947
|
+
*/
|
|
948
|
+
getOriginalMessageInConversation(websiteID: string, sessionID: string, originalID: string) : Promise<ConversationOriginal> {
|
|
949
|
+
return this.crisp.get(
|
|
950
|
+
this.crisp.prepareRestUrl([
|
|
951
|
+
"website", websiteID, "conversation", sessionID, "original", originalID
|
|
952
|
+
])
|
|
953
|
+
);
|
|
954
|
+
}
|
|
955
|
+
|
|
956
|
+
/**
|
|
957
|
+
* List Conversation Pages
|
|
958
|
+
*/
|
|
959
|
+
listConversationPages(websiteID: string, sessionID: string, pageNumber: number = 1) : Promise<ConversationPage[]> {
|
|
960
|
+
return this.crisp.get(
|
|
961
|
+
this.crisp.prepareRestUrl([
|
|
962
|
+
"website", websiteID, "conversation", sessionID, "pages", String(pageNumber)
|
|
963
|
+
])
|
|
964
|
+
);
|
|
965
|
+
};
|
|
966
|
+
|
|
967
|
+
/**
|
|
968
|
+
* List Conversation Events
|
|
969
|
+
*/
|
|
970
|
+
listConversationEvents(websiteID: string, sessionID: string, pageNumber: number = 1) : Promise<ConversationEvent[]> {
|
|
971
|
+
return this.crisp.get(
|
|
972
|
+
this.crisp.prepareRestUrl([
|
|
973
|
+
"website", websiteID, "conversation", sessionID, "events", String(pageNumber)
|
|
974
|
+
])
|
|
975
|
+
);
|
|
976
|
+
};
|
|
977
|
+
|
|
978
|
+
/**
|
|
979
|
+
* List Conversation Files
|
|
980
|
+
*/
|
|
981
|
+
listConversationFiles(websiteID: string, sessionID: string, pageNumber: number = 1) : Promise<ConversationFile[]> {
|
|
982
|
+
return this.crisp.get(
|
|
983
|
+
this.crisp.prepareRestUrl([
|
|
984
|
+
"website", websiteID, "conversation", sessionID, "files", String(pageNumber)
|
|
985
|
+
])
|
|
986
|
+
);
|
|
987
|
+
};
|
|
988
|
+
|
|
989
|
+
/**
|
|
990
|
+
* Get Conversation State
|
|
991
|
+
*/
|
|
992
|
+
getConversationState(websiteID: string, sessionID: string) : Promise<ConversationStateData> {
|
|
993
|
+
return this.crisp.get(
|
|
994
|
+
this.crisp.prepareRestUrl([
|
|
995
|
+
"website", websiteID, "conversation", sessionID, "state"
|
|
996
|
+
])
|
|
997
|
+
);
|
|
998
|
+
};
|
|
999
|
+
|
|
1000
|
+
/**
|
|
1001
|
+
* Change Conversation State
|
|
1002
|
+
*/
|
|
1003
|
+
changeConversationState(websiteID: string, sessionID: string, state: ConversationState) {
|
|
1004
|
+
return this.crisp.patch(
|
|
1005
|
+
this.crisp.prepareRestUrl([
|
|
1006
|
+
"website", websiteID, "conversation", sessionID, "state"
|
|
1007
|
+
]),
|
|
1008
|
+
|
|
1009
|
+
null,
|
|
1010
|
+
|
|
1011
|
+
{
|
|
1012
|
+
state: state
|
|
1013
|
+
}
|
|
1014
|
+
);
|
|
1015
|
+
};
|
|
1016
|
+
|
|
1017
|
+
/**
|
|
1018
|
+
* Get Conversation Participants
|
|
1019
|
+
*/
|
|
1020
|
+
getConversationParticipants(websiteID: string, sessionID: string) : Promise<ConversationParticipant[]> {
|
|
1021
|
+
return this.crisp.get(
|
|
1022
|
+
this.crisp.prepareRestUrl([
|
|
1023
|
+
"website", websiteID, "conversation", sessionID, "participants"
|
|
1024
|
+
])
|
|
1025
|
+
);
|
|
1026
|
+
};
|
|
1027
|
+
|
|
1028
|
+
/**
|
|
1029
|
+
* Save Conversation Participants
|
|
1030
|
+
*/
|
|
1031
|
+
saveConversationParticipants(websiteID: string, sessionID: string, participants: ConversationParticipantsSave) {
|
|
1032
|
+
return this.crisp.put(
|
|
1033
|
+
this.crisp.prepareRestUrl([
|
|
1034
|
+
"website", websiteID, "conversation", sessionID, "participants"
|
|
1035
|
+
]),
|
|
1036
|
+
|
|
1037
|
+
null, participants
|
|
1038
|
+
);
|
|
1039
|
+
};
|
|
1040
|
+
|
|
1041
|
+
/**
|
|
1042
|
+
* Get Block Status For Conversation
|
|
1043
|
+
*/
|
|
1044
|
+
getBlockStatusForConversation(websiteID: string, sessionID: string) : Promise<ConversationBlock> {
|
|
1045
|
+
return this.crisp.get(
|
|
1046
|
+
this.crisp.prepareRestUrl([
|
|
1047
|
+
"website", websiteID, "conversation", sessionID, "block"
|
|
1048
|
+
])
|
|
1049
|
+
);
|
|
1050
|
+
};
|
|
1051
|
+
|
|
1052
|
+
/**
|
|
1053
|
+
* Block Incoming Messages For Conversation
|
|
1054
|
+
*/
|
|
1055
|
+
blockIncomingMessagesForConversation(websiteID: string, sessionID: string, blocked: boolean) {
|
|
1056
|
+
return this.crisp.patch(
|
|
1057
|
+
this.crisp.prepareRestUrl([
|
|
1058
|
+
"website", websiteID, "conversation", sessionID, "block"
|
|
1059
|
+
]),
|
|
1060
|
+
|
|
1061
|
+
null,
|
|
1062
|
+
|
|
1063
|
+
{
|
|
1064
|
+
blocked: (blocked || false)
|
|
1065
|
+
}
|
|
1066
|
+
);
|
|
1067
|
+
};
|
|
1068
|
+
|
|
1069
|
+
/**
|
|
1070
|
+
* Get Verify Status For Conversation
|
|
1071
|
+
*/
|
|
1072
|
+
getVerifyStatusForConversation(websiteID: string, sessionID: string) : Promise<ConversationVerify> {
|
|
1073
|
+
return this.crisp.get(
|
|
1074
|
+
this.crisp.prepareRestUrl([
|
|
1075
|
+
"website", websiteID, "conversation", sessionID, "verify"
|
|
1076
|
+
])
|
|
1077
|
+
);
|
|
1078
|
+
};
|
|
1079
|
+
|
|
1080
|
+
/**
|
|
1081
|
+
* Update Verify Status For Conversation
|
|
1082
|
+
*/
|
|
1083
|
+
updateVerifyStatusForConversation(websiteID: string, sessionID: string, verified: boolean) {
|
|
1084
|
+
return this.crisp.patch(
|
|
1085
|
+
this.crisp.prepareRestUrl([
|
|
1086
|
+
"website", websiteID, "conversation", sessionID, "verify"
|
|
1087
|
+
]),
|
|
1088
|
+
|
|
1089
|
+
null,
|
|
1090
|
+
|
|
1091
|
+
{
|
|
1092
|
+
verified: (verified || false)
|
|
1093
|
+
}
|
|
1094
|
+
);
|
|
1095
|
+
};
|
|
1096
|
+
|
|
1097
|
+
/**
|
|
1098
|
+
* Request Identity Verification For Conversation
|
|
1099
|
+
*/
|
|
1100
|
+
requestIdentityVerificationForConversation(
|
|
1101
|
+
websiteID: string, sessionID: string, verification: ConversationVerifyIdentityRequest
|
|
1102
|
+
) {
|
|
1103
|
+
return this.crisp.post(
|
|
1104
|
+
this.crisp.prepareRestUrl([
|
|
1105
|
+
"website", websiteID, "conversation", sessionID, "verify", "identity"
|
|
1106
|
+
]),
|
|
1107
|
+
|
|
1108
|
+
null, verification
|
|
1109
|
+
);
|
|
1110
|
+
};
|
|
1111
|
+
|
|
1112
|
+
/**
|
|
1113
|
+
* Redeem Identity Verification Link For Conversation
|
|
1114
|
+
*/
|
|
1115
|
+
redeemIdentityVerificationLinkForConversation(
|
|
1116
|
+
websiteID: string, sessionID: string, verification: ConversationVerifyIdentityRedeem
|
|
1117
|
+
) {
|
|
1118
|
+
return this.crisp.put(
|
|
1119
|
+
this.crisp.prepareRestUrl([
|
|
1120
|
+
"website", websiteID, "conversation", sessionID, "verify", "identity",
|
|
1121
|
+
"link"
|
|
1122
|
+
]),
|
|
1123
|
+
|
|
1124
|
+
null, verification
|
|
1125
|
+
);
|
|
1126
|
+
};
|
|
1127
|
+
|
|
1128
|
+
/**
|
|
1129
|
+
* Request Email Transcript For Conversation
|
|
1130
|
+
*/
|
|
1131
|
+
requestEmailTranscriptForConversation(
|
|
1132
|
+
websiteID: string, sessionID: string, to: string, email?: string
|
|
1133
|
+
) {
|
|
1134
|
+
// Generate body
|
|
1135
|
+
let body = {
|
|
1136
|
+
to: to
|
|
1137
|
+
};
|
|
1138
|
+
|
|
1139
|
+
if (email) {
|
|
1140
|
+
// @ts-ignore
|
|
1141
|
+
body.email = email;
|
|
1142
|
+
}
|
|
1143
|
+
|
|
1144
|
+
return this.crisp.post(
|
|
1145
|
+
this.crisp.prepareRestUrl([
|
|
1146
|
+
"website", websiteID, "conversation", sessionID, "transcript"
|
|
1147
|
+
]),
|
|
1148
|
+
|
|
1149
|
+
null, body
|
|
1150
|
+
);
|
|
1151
|
+
};
|
|
1152
|
+
|
|
1153
|
+
/**
|
|
1154
|
+
* Request Chatbox Binding Purge For Conversation
|
|
1155
|
+
*/
|
|
1156
|
+
requestChatboxBindingPurgeForConversation(websiteID: string, sessionID: string) {
|
|
1157
|
+
return this.crisp.post(
|
|
1158
|
+
this.crisp.prepareRestUrl([
|
|
1159
|
+
"website", websiteID, "conversation", sessionID, "purge"
|
|
1160
|
+
]),
|
|
1161
|
+
|
|
1162
|
+
null,
|
|
1163
|
+
|
|
1164
|
+
null
|
|
1165
|
+
);
|
|
1166
|
+
};
|
|
1167
|
+
|
|
1168
|
+
/**
|
|
1169
|
+
* Request User Feedback For Conversation
|
|
1170
|
+
*/
|
|
1171
|
+
requestUserFeedbackForConversation(websiteID: string, sessionID: string) {
|
|
1172
|
+
return this.crisp.post(
|
|
1173
|
+
this.crisp.prepareRestUrl([
|
|
1174
|
+
"website", websiteID, "conversation", sessionID, "feedback"
|
|
1175
|
+
]),
|
|
1176
|
+
|
|
1177
|
+
null,
|
|
1178
|
+
|
|
1179
|
+
null
|
|
1180
|
+
);
|
|
1181
|
+
};
|
|
1182
|
+
|
|
1183
|
+
/**
|
|
1184
|
+
* List Browsing Sessions For Conversation
|
|
1185
|
+
*/
|
|
1186
|
+
listBrowsingSessionsForConversation(websiteID: string, sessionID: string) : Promise<ConversationBrowsing[]> {
|
|
1187
|
+
return this.crisp.get(
|
|
1188
|
+
this.crisp.prepareRestUrl([
|
|
1189
|
+
"website", websiteID, "conversation", sessionID, "browsing"
|
|
1190
|
+
])
|
|
1191
|
+
);
|
|
1192
|
+
};
|
|
1193
|
+
|
|
1194
|
+
/**
|
|
1195
|
+
* Initiate Browsing Session For Conversation
|
|
1196
|
+
*/
|
|
1197
|
+
initiateBrowsingSessionForConversation(websiteID: string, sessionID: string) {
|
|
1198
|
+
return this.crisp.post(
|
|
1199
|
+
this.crisp.prepareRestUrl([
|
|
1200
|
+
"website", websiteID, "conversation", sessionID, "browsing"
|
|
1201
|
+
]),
|
|
1202
|
+
|
|
1203
|
+
null,
|
|
1204
|
+
|
|
1205
|
+
null
|
|
1206
|
+
);
|
|
1207
|
+
};
|
|
1208
|
+
|
|
1209
|
+
/**
|
|
1210
|
+
* Send Action To An Existing Browsing Session
|
|
1211
|
+
*/
|
|
1212
|
+
sendActionToExistingBrowsingSession(
|
|
1213
|
+
websiteID: string, sessionID: string, browsingID: string, action: string
|
|
1214
|
+
) {
|
|
1215
|
+
return this.crisp.patch(
|
|
1216
|
+
this.crisp.prepareRestUrl([
|
|
1217
|
+
"website", websiteID, "conversation", sessionID, "browsing", browsingID
|
|
1218
|
+
]),
|
|
1219
|
+
|
|
1220
|
+
null,
|
|
1221
|
+
|
|
1222
|
+
{
|
|
1223
|
+
action: action
|
|
1224
|
+
}
|
|
1225
|
+
);
|
|
1226
|
+
};
|
|
1227
|
+
|
|
1228
|
+
/**
|
|
1229
|
+
* Assist Existing Browsing Session
|
|
1230
|
+
*/
|
|
1231
|
+
assistExistingBrowsingSession(
|
|
1232
|
+
websiteID: string, sessionID: string, browsingID: string, assist: object
|
|
1233
|
+
) {
|
|
1234
|
+
return this.crisp.patch(
|
|
1235
|
+
this.crisp.prepareRestUrl([
|
|
1236
|
+
"website", websiteID, "conversation", sessionID, "browsing", browsingID,
|
|
1237
|
+
"assist"
|
|
1238
|
+
]),
|
|
1239
|
+
|
|
1240
|
+
null, assist
|
|
1241
|
+
);
|
|
1242
|
+
};
|
|
1243
|
+
|
|
1244
|
+
/**
|
|
1245
|
+
* Initiate New Call Session For Conversation
|
|
1246
|
+
*/
|
|
1247
|
+
initiateNewCallSessionForConversation(
|
|
1248
|
+
websiteID: string, sessionID: string, mode: string
|
|
1249
|
+
) {
|
|
1250
|
+
return this.crisp.post(
|
|
1251
|
+
this.crisp.prepareRestUrl([
|
|
1252
|
+
"website", websiteID, "conversation", sessionID, "call"
|
|
1253
|
+
]),
|
|
1254
|
+
|
|
1255
|
+
null,
|
|
1256
|
+
|
|
1257
|
+
{
|
|
1258
|
+
mode: (mode || "audio")
|
|
1259
|
+
}
|
|
1260
|
+
);
|
|
1261
|
+
};
|
|
1262
|
+
|
|
1263
|
+
/**
|
|
1264
|
+
* Get Ongoing Call Session For Conversation
|
|
1265
|
+
*/
|
|
1266
|
+
getOngoingCallSessionForConversation(
|
|
1267
|
+
websiteID: string, sessionID: string
|
|
1268
|
+
) : Promise<ConversationCall> {
|
|
1269
|
+
return this.crisp.get(
|
|
1270
|
+
this.crisp.prepareRestUrl([
|
|
1271
|
+
"website", websiteID, "conversation", sessionID, "call"
|
|
1272
|
+
])
|
|
1273
|
+
);
|
|
1274
|
+
};
|
|
1275
|
+
|
|
1276
|
+
/**
|
|
1277
|
+
* Abort Ongoing Call Session For Conversation
|
|
1278
|
+
*/
|
|
1279
|
+
abortOngoingCallSessionForConversation(
|
|
1280
|
+
websiteID: string, sessionID: string, callID: string
|
|
1281
|
+
) {
|
|
1282
|
+
return this.crisp.delete(
|
|
1283
|
+
this.crisp.prepareRestUrl([
|
|
1284
|
+
"website", websiteID, "conversation", sessionID, "call", callID
|
|
1285
|
+
])
|
|
1286
|
+
);
|
|
1287
|
+
};
|
|
1288
|
+
|
|
1289
|
+
/**
|
|
1290
|
+
* Transmit Signaling On Ongoing Call Session
|
|
1291
|
+
*/
|
|
1292
|
+
transmitSignalingOnOngoingCallSession(
|
|
1293
|
+
websiteID: string, sessionID: string, callID: string, payload: object
|
|
1294
|
+
) {
|
|
1295
|
+
return this.crisp.patch(
|
|
1296
|
+
this.crisp.prepareRestUrl([
|
|
1297
|
+
"website", websiteID, "conversation", sessionID, "call", callID
|
|
1298
|
+
]),
|
|
1299
|
+
|
|
1300
|
+
null, payload
|
|
1301
|
+
);
|
|
1302
|
+
};
|
|
1303
|
+
|
|
1304
|
+
/**
|
|
1305
|
+
* Deliver Widget Button Action For Conversation
|
|
1306
|
+
*/
|
|
1307
|
+
deliverWidgetButtonActionForConversation(
|
|
1308
|
+
websiteID: string, sessionID: string, pluginID: string, sectionID: string, itemID: string, data: object, value?: string
|
|
1309
|
+
) {
|
|
1310
|
+
// Generate body
|
|
1311
|
+
let body = {
|
|
1312
|
+
section_id: sectionID,
|
|
1313
|
+
item_id: itemID,
|
|
1314
|
+
data: data
|
|
1315
|
+
};
|
|
1316
|
+
|
|
1317
|
+
if (typeof value !== "undefined") {
|
|
1318
|
+
// @ts-ignore
|
|
1319
|
+
body.value = value;
|
|
1320
|
+
}
|
|
1321
|
+
|
|
1322
|
+
return this.crisp.post(
|
|
1323
|
+
this.crisp.prepareRestUrl([
|
|
1324
|
+
"website", websiteID, "conversation", sessionID, "widget", pluginID,
|
|
1325
|
+
"button"
|
|
1326
|
+
]),
|
|
1327
|
+
|
|
1328
|
+
null, body
|
|
1329
|
+
);
|
|
1330
|
+
};
|
|
1331
|
+
|
|
1332
|
+
/**
|
|
1333
|
+
* Deliver Widget Data Fetch Action For Conversation
|
|
1334
|
+
*/
|
|
1335
|
+
deliverWidgetDataFetchActionForConversation(
|
|
1336
|
+
websiteID: string, sessionID: string, pluginID: string, sectionID: string, itemID: string, data: object
|
|
1337
|
+
) {
|
|
1338
|
+
return this.crisp.post(
|
|
1339
|
+
this.crisp.prepareRestUrl([
|
|
1340
|
+
"website", websiteID, "conversation", sessionID, "widget", pluginID,
|
|
1341
|
+
"data"
|
|
1342
|
+
]),
|
|
1343
|
+
|
|
1344
|
+
null,
|
|
1345
|
+
|
|
1346
|
+
{
|
|
1347
|
+
section_id: sectionID,
|
|
1348
|
+
item_id: itemID,
|
|
1349
|
+
data: data
|
|
1350
|
+
}
|
|
1351
|
+
);
|
|
1352
|
+
};
|
|
1353
|
+
|
|
1354
|
+
/**
|
|
1355
|
+
* Deliver Widget Data Edit Action For Conversation
|
|
1356
|
+
*/
|
|
1357
|
+
deliverWidgetDataEditActionForConversation(
|
|
1358
|
+
websiteID: string, sessionID: string, pluginID: string, sectionID: string, itemID: string, value: string
|
|
1359
|
+
) {
|
|
1360
|
+
return this.crisp.post(
|
|
1361
|
+
this.crisp.prepareRestUrl([
|
|
1362
|
+
"website", websiteID, "conversation", sessionID, "widget", pluginID,
|
|
1363
|
+
"data"
|
|
1364
|
+
]),
|
|
1365
|
+
|
|
1366
|
+
null,
|
|
1367
|
+
|
|
1368
|
+
{
|
|
1369
|
+
section_id: sectionID,
|
|
1370
|
+
item_id: itemID,
|
|
1371
|
+
value: value
|
|
1372
|
+
}
|
|
1373
|
+
);
|
|
1374
|
+
};
|
|
1375
|
+
|
|
1376
|
+
/**
|
|
1377
|
+
* Schedule A Reminder For Conversation
|
|
1378
|
+
*/
|
|
1379
|
+
scheduleReminderForConversation(
|
|
1380
|
+
websiteID: string, sessionID: string, date: string, note: string
|
|
1381
|
+
) {
|
|
1382
|
+
return this.crisp.post(
|
|
1383
|
+
this.crisp.prepareRestUrl([
|
|
1384
|
+
"website", websiteID, "conversation", sessionID, "reminder"
|
|
1385
|
+
]),
|
|
1386
|
+
|
|
1387
|
+
null,
|
|
1388
|
+
|
|
1389
|
+
{
|
|
1390
|
+
date: date,
|
|
1391
|
+
note: note
|
|
1392
|
+
}
|
|
1393
|
+
);
|
|
1394
|
+
};
|
|
1395
|
+
|
|
1396
|
+
/**
|
|
1397
|
+
* Report Conversation
|
|
1398
|
+
*/
|
|
1399
|
+
reportConversation(
|
|
1400
|
+
websiteID: string, sessionID: string, flag: string
|
|
1401
|
+
) {
|
|
1402
|
+
return this.crisp.post(
|
|
1403
|
+
this.crisp.prepareRestUrl([
|
|
1404
|
+
"website", websiteID, "conversation", sessionID, "report"
|
|
1405
|
+
]),
|
|
1406
|
+
|
|
1407
|
+
null,
|
|
1408
|
+
|
|
1409
|
+
{
|
|
1410
|
+
flag: flag
|
|
1411
|
+
}
|
|
1412
|
+
);
|
|
1413
|
+
};
|
|
1414
|
+
}
|
|
1415
|
+
|
|
1416
|
+
export default WebsiteConversation;
|