@carbon/ai-chat 0.1.0-alpha-2 → 0.1.0-alpha-3

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.
@@ -0,0 +1,4107 @@
1
+ /**
2
+ *
3
+ * (C) Copyright IBM Corp. 2017, 2024. All Rights Reserved.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
6
+ * in compliance with the License. You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software distributed under the License
11
+ * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
12
+ * or implied. See the License for the specific language governing permissions and limitations under
13
+ * the License.
14
+ * */
15
+
16
+ import React, { ReactNode } from 'react';
17
+ import { IntlShape } from 'react-intl';
18
+ import { DeepPartial } from 'ts-essentials';
19
+
20
+ declare enum TagType {
21
+ RED = 'red',
22
+ MAGENTA = 'magenta',
23
+ PURPLE = 'purple',
24
+ BLUE = 'blue',
25
+ CYAN = 'cyan',
26
+ TEAL = 'teal',
27
+ GREEN = 'green',
28
+ GRAY = 'gray',
29
+ COOL_GRAY = 'cool-gray',
30
+ WARM_GRAY = 'warm-gray',
31
+ HIGH_CONTRAST = 'high-contrast',
32
+ OUTLINE = 'outline',
33
+ }
34
+
35
+ /**
36
+ * Constants for the Carbon FileStatus type because they weren't kind enough to include their own enum.
37
+ */
38
+ declare enum FileStatusValue {
39
+ COMPLETE = 'complete',
40
+ EDIT = 'edit',
41
+ UPLOADING = 'uploading',
42
+ SUCCESS = 'success',
43
+ }
44
+
45
+ /**
46
+ * An interface that represents a file to upload and it's current upload status.
47
+ */
48
+ interface FileUpload {
49
+ /**
50
+ * A unique ID for the file.
51
+ */
52
+ id: string;
53
+
54
+ /**
55
+ * The file to upload.
56
+ */
57
+ file: File;
58
+
59
+ /**
60
+ * The current upload status.
61
+ */
62
+ status: FileStatusValue;
63
+
64
+ /**
65
+ * Indicates if the file contains an error or failed to upload.
66
+ */
67
+ isError?: boolean;
68
+
69
+ /**
70
+ * If the file failed to upload, this is an optional error message to display.
71
+ */
72
+ errorMessage?: string;
73
+ }
74
+
75
+ /**
76
+ * Whether a particular web chat view is visible or not.
77
+ */
78
+ interface ViewState {
79
+ /**
80
+ * Whether the launcher is visible or not.
81
+ */
82
+ launcher: boolean;
83
+
84
+ /**
85
+ * Whether the main window is visible or not.
86
+ */
87
+ mainWindow: boolean;
88
+
89
+ /**
90
+ * Whether a tour is visible or not.
91
+ */
92
+ tour: boolean;
93
+ }
94
+
95
+ /**
96
+ * A record of a notification to be shown in the UI.
97
+ */
98
+ interface NotificationMessage {
99
+ kind: 'error' | 'info' | 'info-square' | 'success' | 'warning' | 'warning-alt';
100
+
101
+ /**
102
+ * The title to show in the message.
103
+ */
104
+ title: string;
105
+
106
+ /**
107
+ * The message to show.
108
+ */
109
+ message: string;
110
+
111
+ /**
112
+ * An optional action button that a user can click. If there is an action button, we will not auto dismiss.
113
+ */
114
+ actionButtonLabel?: string;
115
+
116
+ /**
117
+ * The group id that associates notifications together. This can be used to remove the notification later.
118
+ */
119
+ groupID?: string;
120
+
121
+ /**
122
+ * The callback called when someone clicks on the action button.
123
+ */
124
+ onActionButtonClick?: () => void;
125
+
126
+ /**
127
+ * The callback called when someone clicks on the close button.
128
+ */
129
+ onCloseButtonClick?: () => void;
130
+ }
131
+
132
+ /**
133
+ * A language pack represent the set of display strings for a particular language.
134
+ */
135
+ interface LanguagePack {
136
+ [key: string]: string;
137
+ }
138
+
139
+ /**
140
+ * The different views that can be shown by web chat.
141
+ */
142
+ declare enum ViewType {
143
+ /**
144
+ * The launcher view is used to open the main window or tour.
145
+ */
146
+ LAUNCHER = 'launcher',
147
+
148
+ /**
149
+ * The main window view is used to ask WA questions and converse with an agent, as well as many other things. The
150
+ * string value is kept camel case to align with the viewState mainWindow property, both of which are used by the
151
+ * {@link ChatActions.changeView} function.
152
+ */
153
+ MAIN_WINDOW = 'mainWindow',
154
+
155
+ /**
156
+ * The tour view is used to guide the end user through a task.
157
+ */
158
+ TOUR = 'tour',
159
+ }
160
+
161
+ /**
162
+ * The different variations of the launcher that can exist.
163
+ */
164
+ declare enum LauncherType {
165
+ /**
166
+ * The launcher that expands to a "complex" variation on desktop.
167
+ */
168
+ DESKTOP = 'desktop',
169
+
170
+ /**
171
+ * The launcher that expands to an "extended" variation on mobile.
172
+ */
173
+ MOBILE = 'mobile',
174
+ }
175
+
176
+ /**
177
+ * This manager handles fetching an instance for manipulating the custom panel.
178
+ */
179
+ interface CustomPanels {
180
+ /**
181
+ * Gets a custom panel instance.
182
+ */
183
+ getPanel: () => CustomPanelInstance;
184
+ }
185
+
186
+ /**
187
+ * The custom panel instance for controlling and manipulating a custom panel in web chat.
188
+ */
189
+ interface CustomPanelInstance {
190
+ /**
191
+ * The custom panel hostElement.
192
+ */
193
+ hostElement: HTMLDivElement;
194
+
195
+ /**
196
+ * Opens the custom panel.
197
+ *
198
+ * @param options Custom panel options.
199
+ */
200
+ open: (options?: CustomPanelConfigOptions) => void;
201
+
202
+ /**
203
+ * Closes the custom panel.
204
+ */
205
+ close: () => void;
206
+ }
207
+
208
+ /**
209
+ * Describes general config options for a web chat panel. These options are also part of the
210
+ * {@link BasePanelComponentProps}, except the options here are also shared with {@link CustomPanelConfigOptions}.
211
+ *
212
+ * Any options specific to either the BasePanelComponent or CustomPanelConfigOptions should be added to the respective
213
+ * interface.
214
+ */
215
+ interface BasePanelConfigOptions {
216
+ /**
217
+ * The panel title which is left blank by default.
218
+ */
219
+ title?: string;
220
+
221
+ /**
222
+ * Indicates if the close button in the custom panel should be hidden.
223
+ */
224
+ hideCloseButton?: boolean;
225
+
226
+ /**
227
+ * Indicates if the close-and-restart (X) button in the custom panel should be hidden. This value only applies if
228
+ * the close-and-restart button is enabled.
229
+ */
230
+ hideCloseAndRestartButton?: boolean;
231
+
232
+ /**
233
+ * Indicates if the panel header should be hidden.
234
+ */
235
+ hidePanelHeader?: boolean;
236
+
237
+ /**
238
+ * Indicates if the back button in the custom panel should be hidden.
239
+ */
240
+ hideBackButton?: boolean;
241
+
242
+ /**
243
+ * This callback is called when the close button is clicked. This is called even if {@link disableDefaultCloseAction}
244
+ * is set to true.
245
+ */
246
+ onClickClose?: () => void;
247
+
248
+ /**
249
+ * This callback is called when the close-and-restart button is clicked. This is called even if {@link disableDefaultCloseAction}
250
+ * is set to true.
251
+ */
252
+ onClickCloseAndRestart?: () => void;
253
+
254
+ /**
255
+ * Called when the restart button is clicked.
256
+ */
257
+ onClickRestart?: () => void;
258
+
259
+ /**
260
+ * This callback is called when the back button is clicked.
261
+ */
262
+ onClickBack?: () => void;
263
+ }
264
+
265
+ /**
266
+ * Options that change how the custom panel looks.
267
+ */
268
+ interface CustomPanelConfigOptions extends BasePanelConfigOptions {
269
+ /**
270
+ * Determines if the panel open/close animation should be turned off.
271
+ */
272
+ disableAnimation?: boolean;
273
+
274
+ /**
275
+ * Disables the default action that is taken when the close or close-and-restart buttons are clicked. The default
276
+ * action closes web chat and disabling this will cause the button to not do anything. You can override the button
277
+ * behavior by using the {@link onClickClose} or {@link onClickCloseAndRestart} callback.
278
+ */
279
+ disableDefaultCloseAction?: boolean;
280
+ }
281
+
282
+ /**
283
+ * A single menu option.
284
+ */
285
+ interface CustomMenuOption {
286
+ /**
287
+ * The text to display for the menu option.
288
+ */
289
+ text: string;
290
+
291
+ /**
292
+ * The callback handler to call when the option is selected.
293
+ */
294
+ handler: () => void;
295
+ }
296
+
297
+ /**
298
+ * This represents the callback function that is called when an input field wants to determine if any completions
299
+ * should be displayed. This function is called every time the text in an input field changes. It is passed the text
300
+ * in the input field and the position of the cursor in the field.
301
+ *
302
+ * This function should return the list of completions that should be displayed to the user or null if no
303
+ * completions should be displayed.
304
+ */
305
+ type OnGetCompletions = (inputText: string, cursorPosition: number) => Promise<InputCompletionResult>;
306
+
307
+ /**
308
+ * This represents the callback that is called when a completion is selected from a completions popup on an input
309
+ * field. It is passed the completion that was selected which will one of the same object instances returned from the
310
+ * {@link OnGetCompletions} function.
311
+ */
312
+ type OnCompletionSelected = (completion: InputCompletion) => void;
313
+ interface InputCompletionResult {
314
+ /**
315
+ * The character position where the completion target begins.
316
+ */
317
+ completionStart: number;
318
+
319
+ /**
320
+ * The character position where the completion target ends.
321
+ */
322
+ completionEnd: number;
323
+
324
+ /**
325
+ * This list of possible completions.
326
+ */
327
+ completions: InputCompletion[];
328
+ }
329
+ interface InputCompletion {
330
+ /**
331
+ * The display text for the completion.
332
+ */
333
+ label: string;
334
+
335
+ /**
336
+ * The value to replace the completion target with.
337
+ */
338
+ targetValue: string;
339
+
340
+ /**
341
+ * An object that describes the tag to render beside the mention option.
342
+ */
343
+ tag?: {
344
+ /**
345
+ * The tag text.
346
+ */
347
+ label: string;
348
+
349
+ /**
350
+ * The tag color.
351
+ */
352
+ type: TagType;
353
+ };
354
+ }
355
+
356
+ /**
357
+ * This file contains the generic types for the API between a general chat widget and a chat back-end. It is
358
+ * intended to provide base types for a standalone widget and should not contain any imports of other types.
359
+ */
360
+
361
+ /**
362
+ * This is the main interface that represents a request from a user sent to a back-end.
363
+ */
364
+ interface MessageRequest<TInputType extends BaseMessageInput = MessageInput> {
365
+ /**
366
+ * The unique identifier for this request object. This value may be assigned by the client when a request is
367
+ * made but will be assigned by the service if one is not provided.
368
+ */
369
+ id?: string;
370
+
371
+ /**
372
+ * The history information to store as part of this request. This includes extra information that was provided to
373
+ * the user that was used in making the request.
374
+ */
375
+ history?: MessageHistory;
376
+
377
+ /**
378
+ * The input data to the back-end to make in this request.
379
+ */
380
+ input: TInputType;
381
+
382
+ /**
383
+ * Optional context which is added from external resources.
384
+ */
385
+ context?: MessageContext;
386
+ }
387
+
388
+ /**
389
+ * The set of possible message input types in a request.
390
+ */
391
+ declare enum MessageInputType {
392
+ /**
393
+ * Represents a simple text message.
394
+ */
395
+ TEXT = 'text',
396
+
397
+ /**
398
+ * Represents an event message that can be used to send control, updates, or action information to the back-end.
399
+ */
400
+ EVENT = 'event',
401
+ }
402
+ interface BaseMessageInput {
403
+ /**
404
+ * The type of user input.
405
+ */
406
+ message_type?: MessageInputType;
407
+ }
408
+
409
+ /**
410
+ * Base interface for an event message that can be used to send control, updates, or action information to the back-end.
411
+ */
412
+ interface EventInput<TEventInputType = EventInputData> extends BaseMessageInput {
413
+ /**
414
+ * Event messages have this as their input type.
415
+ */
416
+ message_type: MessageInputType.EVENT;
417
+
418
+ /**
419
+ * The type of the event.
420
+ */
421
+ event: TEventInputType;
422
+ }
423
+
424
+ /**
425
+ * Input for an event. The name of the event is mandatory. Additional fields depend on the event.
426
+ *
427
+ * @template TNameType The type of the name property for the event. This can just be a string or it can be a
428
+ * specific string in order to create type safety ensuring each event has the right name (e.g. "typeof MY_EVENT_NAME").
429
+ */
430
+ interface EventInputData<TNameType extends string = string> {
431
+ /**
432
+ * The name of the event.
433
+ */
434
+ name: TNameType;
435
+ }
436
+
437
+ /**
438
+ * The default interface for message input that is sent to a back-end in a message request. This represents basic text
439
+ * input.
440
+ */
441
+ interface MessageInput extends BaseMessageInput {
442
+ /**
443
+ * For messages that are sent between the user and a human agent, we assign an agent type to the message to distinguish what type it is.
444
+ */
445
+ agent_message_type?: AgentMessageType;
446
+
447
+ /**
448
+ * The text of the user input to send to the back-end.
449
+ */
450
+ text?: string;
451
+ }
452
+
453
+ /**
454
+ * This interface represents the main response content that is received by a client from a back-end. It is generally
455
+ * in response to a previous message request.
456
+ */
457
+ interface MessageResponse<TGenericType = GenericItem[]> {
458
+ /**
459
+ * A unique identifier for this response object. This value is assigned by the service when the request is generated.
460
+ */
461
+ id?: string;
462
+
463
+ /**
464
+ * The id of the request that this is the response of. It is expected that bot responses will match a specific request, however
465
+ * human agent responses may not be attached to a specific user request.
466
+ */
467
+ request_id?: string;
468
+
469
+ /**
470
+ * The output from the back-end to be rendered or processed by the client.
471
+ */
472
+ output: MessageOutput<TGenericType>;
473
+
474
+ /**
475
+ * The context information returned by the back-end.
476
+ */
477
+ context?: MessageContext;
478
+ }
479
+
480
+ /**
481
+ * The output context for a message response from a back-end.
482
+ */
483
+ interface MessageOutput<TGenericType = GenericItem[]> {
484
+ /**
485
+ * Responses intended to be processed by a generic channel. This will be an array of message response items.
486
+ */
487
+ generic?: TGenericType;
488
+ }
489
+
490
+ /**
491
+ * Contextual information gathered by the service.
492
+ */
493
+ interface MessageContext {
494
+ /**
495
+ * Global context.
496
+ */
497
+ global?: MessageGlobalContext;
498
+
499
+ /**
500
+ * Contains the context data for a message. The context data is divided into object for different skills that may
501
+ * be involved with the message.
502
+ */
503
+ skills?: {
504
+ /**
505
+ * The context associated with each skill. Note that "main skill" and "actions skill" are reserved skill names
506
+ * and should not be used outside of watsonx Assistant or watsonx Orchestrate.
507
+ */
508
+ [skill_name: string]: MessageSkillContext;
509
+ };
510
+ }
511
+ interface MessageGlobalContext {
512
+ /**
513
+ * Global system context
514
+ */
515
+ system?: MessageSystemContext;
516
+ }
517
+ interface MessageSystemContext {
518
+ /**
519
+ * The current timezone of the client.
520
+ */
521
+ timezone?: string;
522
+
523
+ /**
524
+ * The current system locale. Example: "en-US".
525
+ */
526
+ locale?: string;
527
+ }
528
+
529
+ /**
530
+ * The base interface for the content of a message context. The content of this will vary by which skill is involved
531
+ * in the message.
532
+ */
533
+ interface MessageSkillContext {}
534
+
535
+ /**
536
+ * The set of possible message types in a response from IBM watsonx Assistant.
537
+ */
538
+ declare enum MessageResponseTypes {
539
+ /**
540
+ * Represents a basic text response. The given text may contain rich content such as markdown.
541
+ */
542
+ TEXT = 'text',
543
+
544
+ /**
545
+ * A response that requests the user choose an option from a list. The list of options may be presented as a list
546
+ * of buttons or it may be from a drop-down.
547
+ */
548
+ OPTION = 'option',
549
+
550
+ /**
551
+ * Indicates that the conversation should be escalated to a human agent and offers that opportunity to the user.
552
+ */
553
+ CONNECT_TO_AGENT = 'connect_to_agent',
554
+
555
+ /**
556
+ * Displays an image to the user.
557
+ */
558
+ IMAGE = 'image',
559
+
560
+ /**
561
+ * Indicates that the chat should display a pause at this point in the conversation before displaying additional
562
+ * items.
563
+ */
564
+ PAUSE = 'pause',
565
+
566
+ /**
567
+ * A user defined response will be displayed according to custom logic in the client.
568
+ */
569
+ USER_DEFINED = 'user_defined',
570
+
571
+ /**
572
+ * Displays the contents of an iframe to the user.
573
+ */
574
+ IFRAME = 'iframe',
575
+
576
+ /**
577
+ * Displays a video to the user using a video player.
578
+ */
579
+ VIDEO = 'video',
580
+
581
+ /**
582
+ * Displays an audio clip to the user using an audio player.
583
+ */
584
+ AUDIO = 'audio',
585
+
586
+ /**
587
+ * Asks the user to provide a date. This may result in a date picker being presented to the user.
588
+ */
589
+ DATE = 'date',
590
+
591
+ /**
592
+ * Displays a table of data to the user.
593
+ */
594
+ TABLE = 'table',
595
+
596
+ /**
597
+ * Displays a general error message to the user and include developer info to be logged and to debug.
598
+ */
599
+ INLINE_ERROR = 'inline_error',
600
+ }
601
+
602
+ /**
603
+ * The basic class for items returned from a back-end as part of a message response. These are the items contained
604
+ * in the {@link MessageOutput.generic} array.
605
+ */
606
+ interface GenericItem<TUserDefinedType = Record<string, unknown>> {
607
+ /**
608
+ * For messages that are sent between the user and a human agent, we assign an agent type to the message to distinguish what type it is.
609
+ */
610
+ agent_message_type?: AgentMessageType;
611
+
612
+ /**
613
+ * The response type of this message item.
614
+ */
615
+ response_type: MessageResponseTypes;
616
+
617
+ /**
618
+ * Metadata used identify a generic item within the context of a stream in order to correlate any updates meant
619
+ * for a specific item.
620
+ */
621
+ streaming_metadata?: ItemStreamingMetadata;
622
+
623
+ /**
624
+ * An optional buckets of additional user defined properties for this item.
625
+ */
626
+ user_defined?: TUserDefinedType;
627
+ }
628
+
629
+ /**
630
+ * A user defined item returned in a message response from a back-end.
631
+ */
632
+ interface UserDefinedItem<TUserDefinedType = Record<string, unknown>> extends GenericItem<TUserDefinedType> {}
633
+
634
+ /**
635
+ * A text item returned in a message response from a back-end.
636
+ */
637
+ interface TextItem<TUserDefinedType = Record<string, unknown>> extends GenericItem<TUserDefinedType> {
638
+ /**
639
+ * The text of the response.
640
+ */
641
+ text?: string;
642
+
643
+ /**
644
+ * The optional formatting for the text response.
645
+ */
646
+ format?: {
647
+ /**
648
+ * If this is true, it means we are not going to get `<br />` to manage spacing and should add margin/padding
649
+ * to elements as required with CSS.
650
+ */
651
+ use_padding?: boolean;
652
+ };
653
+ }
654
+
655
+ /**
656
+ * A "connect to agent" item returned in a message response from a back-end. This is used when the back-end
657
+ * indicates that a user's conversation should be escalated to a human agent.
658
+ */
659
+ interface ConnectToAgentItem<TUserDefinedType = Record<string, unknown>> extends GenericItem<TUserDefinedType> {
660
+ /**
661
+ * A message to be sent to the human agent who will be taking over the conversation.
662
+ */
663
+ message_to_human_agent?: string;
664
+
665
+ /**
666
+ * Contains the message to be rendered if there are agents available.
667
+ */
668
+ agent_available?: {
669
+ message: string;
670
+ };
671
+
672
+ /**
673
+ * Contains the message to be rendered if there are no agents available.
674
+ */
675
+ agent_unavailable?: {
676
+ message: string;
677
+ };
678
+
679
+ /**
680
+ * When a conversation is escalated to an agent additional information is needed to fullfill the request. This
681
+ * additional information typically is added by the channel integration and cannot be deduced from the dialog
682
+ * itself.
683
+ */
684
+ transfer_info?: ConnectToAgentItemTransferInfo;
685
+ }
686
+
687
+ /**
688
+ * Additional information as part of a {@link ConnectToAgentItem} that may be need to perform a transfer to an agent.
689
+ */
690
+ interface ConnectToAgentItemTransferInfo {
691
+ /**
692
+ * A key used by the service desk to securely load the session history.
693
+ */
694
+ session_history_key?: string;
695
+
696
+ /**
697
+ * Each service desk may require different information to start the connection. It can be account details or
698
+ * security information. This is a bucket of all the service desk specific properties.
699
+ */
700
+ additional_data?: {
701
+ [key: string]: string;
702
+ };
703
+
704
+ /**
705
+ * An initial set of message items to send to the agent.
706
+ */
707
+ summary_message_to_agent?: TextItem[];
708
+ }
709
+
710
+ /**
711
+ * A pause item returned in a message response from a back-end. This indicates that the client should pause before
712
+ * displaying additional response items.
713
+ */
714
+ interface PauseItem<TUserDefinedType = Record<string, unknown>> extends GenericItem<TUserDefinedType> {
715
+ /**
716
+ * How long to pause, in milliseconds.
717
+ */
718
+ time?: number;
719
+
720
+ /**
721
+ * Whether to display an "is typing" indicator during the pause.
722
+ */
723
+ typing?: boolean;
724
+ }
725
+
726
+ /**
727
+ * An option item returned in a message response from a back-end. This response type is used when displaying a list
728
+ * of options to the user. How the options are displayed is up to the client but is often displayed in either a
729
+ * drop-down or as a list of buttons.
730
+ */
731
+ interface OptionItem<TUserDefinedType = Record<string, unknown>> extends GenericItem<TUserDefinedType> {
732
+ /**
733
+ * An array of objects describing the options from which the user can choose.
734
+ */
735
+ options: Option[];
736
+
737
+ /**
738
+ * An optional title to be shown alongside the options.
739
+ */
740
+ title?: string;
741
+
742
+ /**
743
+ * An optional description to be shown alongside the options.
744
+ */
745
+ description?: string;
746
+
747
+ /**
748
+ * The preferred type of control to display.
749
+ */
750
+ preference?: OptionItemPreference;
751
+ }
752
+
753
+ /**
754
+ * The set of possible response preferences for an options response.
755
+ */
756
+ declare enum OptionItemPreference {
757
+ /**
758
+ * Indicates the options should be displayed as a drop-down.
759
+ */
760
+ DROPDOWN = 'dropdown',
761
+
762
+ /**
763
+ * Indicates the options should be displayed as buttons.
764
+ */
765
+ BUTTON = 'button',
766
+ }
767
+
768
+ /**
769
+ * Represents an individual option that is part of an "options" response.
770
+ */
771
+ interface Option {
772
+ /**
773
+ * The user-facing label for the option or disambiguation suggestion. This label is taken from the user_label property
774
+ * of the corresponding dialog node.
775
+ */
776
+ label: string;
777
+ value: {
778
+ /**
779
+ * An input object that should be sent back to the assistant when this option is chosen by a user.
780
+ */
781
+ input: MessageInput;
782
+ };
783
+ }
784
+ interface IFrameItem<TUserDefinedType = Record<string, unknown>> extends GenericItem<TUserDefinedType> {
785
+ /**
786
+ * The source URL to an embeddable page
787
+ */
788
+ source: string;
789
+
790
+ /**
791
+ * The preview image of the source URL. This property is unfurled from the source URL at runtime. It is used when
792
+ * IFrameItemDisplayOption is set to 'panel' for the preview card to open the panel.
793
+ */
794
+ image_url?: string;
795
+
796
+ /**
797
+ * The title of the source URL. This property is unfurled from the source URL at runtime. It is used when
798
+ * IFrameItemDisplayOption is set to 'panel' for the preview card to open the panel.
799
+ */
800
+ title?: string;
801
+
802
+ /**
803
+ * The description of the source URL. This property is unfurled from the source URL at runtime. It is used when
804
+ * IFrameItemDisplayOption is set to 'panel' for the preview card to open the panel.
805
+ */
806
+ description?: string;
807
+
808
+ /**
809
+ * How the iframe should be displayed.
810
+ */
811
+ display?: IFrameItemDisplayOption;
812
+ }
813
+
814
+ /**
815
+ * Dimension information for displaying a media item.
816
+ */
817
+ interface MediaItemDimensions {
818
+ /**
819
+ * This property's value is used to calculate a responsive height for web chat's media player so that its aspect
820
+ * ratio is the same between different screen widths. This is set to a reasonable default depending on the response type
821
+ * and other details like what service you are pulling the content from (e.g. Youtube or SoundCloud).
822
+ */
823
+ base_height?: number;
824
+ }
825
+
826
+ /**
827
+ * The different ways an iframe item may be displayed.
828
+ */
829
+ declare enum IFrameItemDisplayOption {
830
+ /**
831
+ * The iframe is displayed inline in the main message list.
832
+ */
833
+ INLINE = 'inline',
834
+
835
+ /**
836
+ * The iframe is displayed in a separate panel after showing a card in the main message list.
837
+ */
838
+ PANEL = 'panel',
839
+ }
840
+
841
+ /**
842
+ * A reusable media object that may need to display a title and description with an alt_text to label the item for
843
+ * accessibility purposes. This is used by the Audio, Video and Image response types.
844
+ */
845
+ interface MediaItem<TUserDefinedType = Record<string, unknown>> extends GenericItem<TUserDefinedType> {
846
+ /**
847
+ * The url pointing to a media source, whether audio, video, or image.
848
+ *
849
+ * For video this can be a file like an .mp4 or a YouTube, Facebook, Vimeo, Twitch, Streamable, Wistia, or Vidyard url.
850
+ *
851
+ * For audio this can be a file like an .mp3 or a SoundCloud or Mixcloud url.
852
+ */
853
+ source: string;
854
+
855
+ /**
856
+ * The title for the item.
857
+ */
858
+ title?: string;
859
+
860
+ /**
861
+ * The description for the item.
862
+ */
863
+ description?: string;
864
+
865
+ /**
866
+ * The alt text for labeling the item. Screen readers will announce this text when the user's virtual cursor
867
+ * is focused on the item.
868
+ */
869
+ alt_text?: string;
870
+
871
+ /**
872
+ * Settings that control the dimensions for the media item.
873
+ */
874
+ dimensions?: MediaItemDimensions;
875
+ }
876
+
877
+ /**
878
+ * Citations for text generated by an AI to provide the user with relevant source information and context.
879
+ */
880
+ interface ConversationalSearchItemCitation {
881
+ /**
882
+ * Optional url of the citation. May not be a valid URL.
883
+ */
884
+ url?: string;
885
+
886
+ /**
887
+ * Optional explanation text for the citation.
888
+ */
889
+ text?: string;
890
+
891
+ /**
892
+ * Optional title of the citation URL.
893
+ */
894
+ title?: string;
895
+
896
+ /**
897
+ * Optional zero index based integer indicating where in `text` the citation starts from.
898
+ */
899
+ range_start?: number;
900
+
901
+ /**
902
+ * Optional zero index based integer indicating where in `text`` the citation ends at. Exclusive.
903
+ * So the word "hi", would have the range_start of 0 and range_end of 2.
904
+ */
905
+ range_end?: number;
906
+
907
+ /**
908
+ * A number corresponding to the index of the matching search result. This can be used to gather extra info about a
909
+ * specific citation from the matching search result.
910
+ */
911
+ search_result_idx?: number;
912
+ }
913
+
914
+ /**
915
+ * A text response generated by AI with an optional list of citations for where the information came from.
916
+ */
917
+ interface ConversationalSearchItem<TUserDefinedType = Record<string, unknown>> extends GenericItem<TUserDefinedType> {
918
+ /**
919
+ * The returned conversational text. Any HTML/Markdown will be ignored.
920
+ */
921
+ text: string;
922
+
923
+ /**
924
+ * A title to display above the citation list, default set to "How do we know?".
925
+ */
926
+ citations_title: string;
927
+
928
+ /**
929
+ * A string to explain that these results are generated, default set to "Accuracy of generated answers may vary.".
930
+ */
931
+ disclaimer: string;
932
+
933
+ /**
934
+ * Citations are used to connect specific text within a conversational search response with the relevant documents
935
+ * returned by the backend.
936
+ */
937
+ citations?: ConversationalSearchItemCitation[];
938
+ }
939
+
940
+ /**
941
+ * The image response type definition. This is currently the same as {@link MediaItem}.
942
+ */
943
+ type ImageItem = MediaItem;
944
+
945
+ /**
946
+ * The video response type definition for future reuse. This is currently the same as {@link MediaItem}.
947
+ */
948
+ type VideoItem = MediaItem;
949
+
950
+ /**
951
+ * The audio response type definition for future reuse. This is currently the same as {@link MediaItem}.
952
+ */
953
+ type AudioItem = MediaItem;
954
+
955
+ /**
956
+ * This is the response item that represents a request for a date which should prompt the client to use a date picker or
957
+ * similar control to provide a date. There are currently no additional properties of the response.
958
+ */
959
+ type DateItem = GenericItem;
960
+
961
+ /**
962
+ * Additional metadata associated with a specific message item (response type) inside of a message response.
963
+ */
964
+ interface ItemStreamingMetadata {
965
+ /**
966
+ * An identifier for this item within the full message response. This ID is used to correlate a partial or
967
+ * complete item chunk with other chunks that represent the same item. This ID is only unique for a given message
968
+ * response.
969
+ */
970
+ id: string;
971
+ }
972
+ interface Chunk {
973
+ /**
974
+ * Additional metadata associated with the stream.
975
+ */
976
+ streaming_metadata?: {
977
+ /**
978
+ * The ID of the complete message response object. This ID will be the ID of the full message that is received
979
+ * in the final chunk of the stream.
980
+ */
981
+ response_id: string;
982
+ };
983
+ }
984
+
985
+ /**
986
+ * The interface for a chunk that represents a partial update (or first time chunk) to a message item.
987
+ */
988
+ interface PartialItemChunk extends Chunk {
989
+ /**
990
+ * The partial details of the item. The client will decide what rules to follow for merging this in with any
991
+ * existing data for the same item (which is identified using the {@link ItemStreamingMetadata.id} property).
992
+ */
993
+ partial_item: DeepPartial<GenericItem>;
994
+ }
995
+
996
+ /**
997
+ * The interface for a chunk that represents a complete update to a message item. The item provided here should have
998
+ * all the data necessary to render the item including any data that was previously received from partial chunks.
999
+ * This chunk may contain corrections to previous chunks.
1000
+ */
1001
+ interface CompleteItemChunk extends Chunk {
1002
+ complete_item: GenericItem;
1003
+ }
1004
+
1005
+ /**
1006
+ * The interface for a chunk that represents the entire completed message response. The response provided here
1007
+ * should have all the data necessary to render the response including any data that was previously received from item
1008
+ * chunks. This final response may contain corrections to previous chunks.
1009
+ *
1010
+ * The ID of the message should match the ID that was previously provided by {@link PartialItemChunk.streaming_metadata.id}.
1011
+ */
1012
+ interface FinalResponseChunk {
1013
+ final_response: MessageResponse;
1014
+ }
1015
+ type StreamChunk = PartialItemChunk | CompleteItemChunk | FinalResponseChunk;
1016
+
1017
+ /**
1018
+ * Profile information about a specific agent that can be used to display information to the user. This may
1019
+ * represent a human agent or a virtual/bot agent.
1020
+ */
1021
+ interface AgentProfile {
1022
+ /**
1023
+ * Indicates if the agent's profile information should be hidden. This will hide the entire avatar line
1024
+ * including the agent name, avatar and timestamp.
1025
+ */
1026
+ hidden?: boolean;
1027
+
1028
+ /**
1029
+ * A unique identifier for this agent.
1030
+ */
1031
+ id: string;
1032
+
1033
+ /**
1034
+ * The visible name for the agent. Can be the full name or just a first name.
1035
+ */
1036
+ nickname: string;
1037
+
1038
+ /**
1039
+ * An url pointing to an avatar for the agent.
1040
+ */
1041
+ profile_picture_url?: string;
1042
+ }
1043
+
1044
+ /**
1045
+ * A general type to indicate any message.
1046
+ */
1047
+ type Message = MessageRequest<MessageInput> | MessageRequest<EventInput> | MessageResponse;
1048
+
1049
+ /**
1050
+ * TODO TOUR: If we end up supporting this user_defined approach longer term, instead of something officially supported
1051
+ * by the backend, then we need to add this to the types repo.
1052
+ */
1053
+ interface TourStepGenericItem<TUserDefinedType = Record<string, unknown>> extends GenericItem<TUserDefinedType> {
1054
+ /**
1055
+ * A way for the authors to label steps so they can use the {@link TourFunctions.goToStep} function to change to a
1056
+ * specific tour step.
1057
+ */
1058
+ step_id: string;
1059
+ }
1060
+ declare enum ButtonItemKind {
1061
+ DEFAULT = 'default',
1062
+ SECONDARY = 'secondary',
1063
+ TERTIARY = 'tertiary',
1064
+ DANGER = 'danger',
1065
+ LINK = 'link',
1066
+ }
1067
+ declare enum ButtonItemType {
1068
+ POST_BACK = 'post_back',
1069
+ CUSTOM_EVENT = 'custom_event',
1070
+ SHOW_PANEL = 'show_panel',
1071
+ URL = 'url',
1072
+ }
1073
+ interface WithBodyAndFooter {
1074
+ /**
1075
+ * A list of message items to render in a web chat panel.
1076
+ */
1077
+ body?: GenericItem[];
1078
+
1079
+ /**
1080
+ * A list of button items that are rendered under the panel body.
1081
+ */
1082
+ footer?: ButtonItem[];
1083
+ }
1084
+ interface MessageItemPanelInfo extends WithBodyAndFooter {
1085
+ /**
1086
+ * The title to give the panel in web chat.
1087
+ */
1088
+ title?: string;
1089
+
1090
+ /**
1091
+ * Determines if the panel header should not be visible or not.
1092
+ */
1093
+ show_header?: boolean;
1094
+
1095
+ /**
1096
+ * Determines if the panel close and open animations should be enabled or not.
1097
+ */
1098
+ show_animations?: boolean;
1099
+ }
1100
+
1101
+ /**
1102
+ * This message item represents a link to a downloadable file.
1103
+ */
1104
+ interface ButtonItem<TUserDefinedType = Record<string, unknown>> extends GenericItem<TUserDefinedType> {
1105
+ /**
1106
+ * The style of button to display.
1107
+ */
1108
+ kind?: ButtonItemKind;
1109
+
1110
+ /**
1111
+ * The type of button.
1112
+ */
1113
+ button_type: ButtonItemType;
1114
+
1115
+ /**
1116
+ * The URL for the user to visit when the button is clicked.
1117
+ */
1118
+ url?: string;
1119
+
1120
+ /**
1121
+ * Where to open the link. The default value is _self.
1122
+ */
1123
+ target?: string;
1124
+
1125
+ /**
1126
+ * The display text for the link.
1127
+ */
1128
+ label?: string;
1129
+
1130
+ /**
1131
+ * A custom event that can be listened to by web chat when the button item is clicked.
1132
+ */
1133
+ custom_event_name?: string;
1134
+ value?: {
1135
+ /**
1136
+ * An input object that should be sent back to the assistant when this option is chosen by a user.
1137
+ */
1138
+ input: MessageInput;
1139
+ };
1140
+
1141
+ /**
1142
+ * The panel options to display in a panel when the "show_panel" button type is clicked.
1143
+ */
1144
+ panel?: MessageItemPanelInfo;
1145
+
1146
+ /**
1147
+ * The URL pointing to an image.
1148
+ */
1149
+ image_url?: string;
1150
+
1151
+ /**
1152
+ * The alt text for labeling the item. Screen readers will announce this text when the user's virtual cursor
1153
+ * is focused on the item.
1154
+ */
1155
+ alt_text?: string;
1156
+ }
1157
+ type PartialOrCompleteItemChunk = PartialItemChunk | CompleteItemChunk;
1158
+
1159
+ /**
1160
+ * This file contains the generic types for the API between a general chat widget and a chat back-end. It is
1161
+ * intended to provide base types for a standalone widget and should not contain any imports of other types. This file
1162
+ * is the same as wa-types-chat.ts except that contains extensions beyond the watsonx Assistant store API.
1163
+ */
1164
+ declare const EVENT_NAME_UPDATE_HISTORY = 'update_history';
1165
+
1166
+ /**
1167
+ * This interface contains information about the history of a given message. This information will eventually be
1168
+ * saved in the history store.
1169
+ */
1170
+ interface MessageHistory {
1171
+ /**
1172
+ * The time at which this message occurred.
1173
+ */
1174
+ timestamp?: number;
1175
+
1176
+ /**
1177
+ * For session history the data passed to instance.updateHistoryUserDefined() is returned to the user here (on page
1178
+ * change/refresh).
1179
+ */
1180
+ user_defined?: unknown;
1181
+
1182
+ /**
1183
+ * The user-friendly label that was associated with this message. This is used on messages that were sent by the
1184
+ * user to the assistant to request a response. This is the user displayed text that was entered or selected by
1185
+ * the user when that request was made.
1186
+ */
1187
+ label?: string;
1188
+
1189
+ /**
1190
+ * If the message was a welcome node request.
1191
+ */
1192
+ is_welcome_request?: boolean;
1193
+
1194
+ /**
1195
+ * If this message is related to another message, this is the ID of that other message. This is used when a user
1196
+ * choices an option and it includes the ID of the message response that presented the options to the user so we
1197
+ * can associate the user's request with that earlier response and display the appropriate selected state.
1198
+ */
1199
+ relatedMessageID?: string;
1200
+ }
1201
+
1202
+ /**
1203
+ * An event that is fired when a messageResponse is updated. This is triggered either by the end user updating messages in the pre:receive or customResponse
1204
+ * events, or by us (internal) when we want to save state of a response type (ex. connect to agent).
1205
+ */
1206
+ interface UpdateHistoryEvent<TMessageType = MessageResponse | MessageRequest>
1207
+ extends EventInputData<typeof EVENT_NAME_UPDATE_HISTORY> {
1208
+ /**
1209
+ * The messageID of the original message that we're saving the update in history for.
1210
+ */
1211
+ messageID: string;
1212
+
1213
+ /**
1214
+ * The partial message response to be saved to the backend and used on session history reload to update the state of a
1215
+ * previous message.
1216
+ */
1217
+ partial_message?: DeepPartial<TMessageType>;
1218
+ }
1219
+
1220
+ /**
1221
+ * A single interaction in the Session History.
1222
+ */
1223
+ interface HistoryItem {
1224
+ /**
1225
+ * The message represented by this history item.
1226
+ */
1227
+ message: MessageRequest<BaseMessageInput> | MessageRequest<EventInput> | MessageResponse;
1228
+
1229
+ /**
1230
+ * Time this message occurred. ISO Format (e.g. 2020-03-15T08:59:56.952Z).
1231
+ */
1232
+ time: string;
1233
+ }
1234
+
1235
+ /**
1236
+ * The types of home screen backgrounds supported.
1237
+ */
1238
+ declare enum HomeScreenBackgroundType {
1239
+ NONE = 'none', // The home screen background is the same color as the chat background.
1240
+ SOLID = 'solid', // All solid color for home screen.
1241
+ TOP_CORNER_OUT = 'top_corner_out', // A top corner outward gradient color.
1242
+ BOTTOM_UP = 'bottom_up',
1243
+ }
1244
+
1245
+ /**
1246
+ * A conversation starter button on the home screen. Currently, only label is provided by tooling.
1247
+ */
1248
+ interface HomeScreenStarterButton {
1249
+ /**
1250
+ * The display label of the button. This is also the value that is sent as the user's utterance to the assistant
1251
+ * when the button is clicked.
1252
+ */
1253
+ label: string;
1254
+
1255
+ /**
1256
+ * Indicates if the button was previously clicked and should be displayed as selected.
1257
+ */
1258
+ isSelected?: boolean;
1259
+ }
1260
+
1261
+ /**
1262
+ * Starter buttons that appear on home screen.
1263
+ */
1264
+ interface HomeScreenStarterButtons {
1265
+ is_on?: boolean;
1266
+ buttons?: HomeScreenStarterButton[];
1267
+ }
1268
+
1269
+ /**
1270
+ * Configuration for the optional home screen that appears before the bot chat window.
1271
+ */
1272
+ interface HomeScreenConfig {
1273
+ /**
1274
+ * If the home page is turned on via config or remote config.
1275
+ */
1276
+ is_on?: boolean;
1277
+
1278
+ /**
1279
+ * The greeting to show to the user to prompt them to start a conversation.
1280
+ */
1281
+ greeting?: string;
1282
+
1283
+ /**
1284
+ * Optional conversation starter utterances that are displayed as buttons.
1285
+ */
1286
+ starters?: HomeScreenStarterButtons;
1287
+
1288
+ /**
1289
+ * An image url that will override the bot avatar displayed in home screen.
1290
+ */
1291
+ bot_avatar_url?: string;
1292
+
1293
+ /**
1294
+ * Do not show the greeting, starters, or avatar url.
1295
+ */
1296
+ custom_content_only?: boolean;
1297
+
1298
+ /**
1299
+ * The type of home screen background to render.
1300
+ */
1301
+ background?: HomeScreenBackgroundType;
1302
+ }
1303
+
1304
+ /**
1305
+ * The interface represents the API contract with the chat widget and contains all the public methods and properties
1306
+ * that can be used with web chat.
1307
+ */
1308
+ interface ChatInstance extends EventHandlers, ChatActions {
1309
+ /**
1310
+ * This function will be called customer code after 'loadWatsonAssistantChat' has been called and after any login or
1311
+ * subscription operations have been performed that are required before the user's history can be loaded and the
1312
+ * widget rendered. When called, this will load the history and then render the widget.
1313
+ */
1314
+ render: () => Promise<ChatInstance>;
1315
+
1316
+ /**
1317
+ * Destroy the chat widget and return initial content to the DOM.
1318
+ */
1319
+ destroy: () => void;
1320
+
1321
+ /**
1322
+ * Returns the version number of code the widget is running.
1323
+ */
1324
+ getWidgetVersion: () => string;
1325
+
1326
+ /**
1327
+ * Returns state information of the web chat that could be useful.
1328
+ */
1329
+ getState: () => PublicWebChatState;
1330
+
1331
+ /**
1332
+ * Returns an instance of the intl object that is used for generating translated text. Note that the object
1333
+ * returned from this function changes each time the locale or language pack is changed.
1334
+ */
1335
+ getIntl: () => IntlShape;
1336
+ }
1337
+
1338
+ /**
1339
+ * This is the state made available by calling getState. This is a public method that returns immutable values.
1340
+ */
1341
+ interface PublicWebChatState {
1342
+ /**
1343
+ * Is the web chat currently in an open state.
1344
+ */
1345
+ isWebChatOpen: boolean;
1346
+
1347
+ /**
1348
+ * Is the web chat currently connected with a human agent.
1349
+ */
1350
+ isConnectedWithHumanAgent: boolean;
1351
+
1352
+ /**
1353
+ * Indicates if web chat has requested to be connected to a human agent but an agent has not yet joined the
1354
+ * conversation.
1355
+ */
1356
+ isConnectingWithHumanAgent: boolean;
1357
+
1358
+ /**
1359
+ * Is the home screen open.
1360
+ */
1361
+ isHomeScreenOpen: boolean;
1362
+
1363
+ /**
1364
+ * Indicates if debugging is enabled.
1365
+ */
1366
+ isDebugEnabled: boolean;
1367
+
1368
+ /**
1369
+ * Has the user sent a message that isn't requesting the welcome node.
1370
+ */
1371
+ hasUserSentMessage: boolean;
1372
+
1373
+ /**
1374
+ * Whether there is an active tour currently.
1375
+ */
1376
+ isTourActive: boolean;
1377
+
1378
+ /**
1379
+ * The current viewState of the web chat.
1380
+ */
1381
+ viewState: ViewState;
1382
+
1383
+ /**
1384
+ * State regarding service desks.
1385
+ */
1386
+ serviceDesk: PublicWebChatServiceDeskState;
1387
+ }
1388
+ interface PublicWebChatServiceDeskState {
1389
+ /**
1390
+ * Is the web chat currently connected with a human agent.
1391
+ */
1392
+ isConnected: boolean;
1393
+
1394
+ /**
1395
+ * Indicates if web chat has requested to be connected to a human agent but an agent has not yet joined the
1396
+ * conversation.
1397
+ */
1398
+ isConnecting: boolean;
1399
+
1400
+ /**
1401
+ * Indicates if a conversation with a human agent has been suspended.
1402
+ */
1403
+ isSuspended: boolean;
1404
+ }
1405
+
1406
+ /**
1407
+ * This is a subset of the public interface that is managed by the event bus that is used for registering and
1408
+ * unregistering event listeners on the bus.
1409
+ */
1410
+ interface EventHandlers {
1411
+ /**
1412
+ * Adds the given event handler as a listener for events of the given type.
1413
+ *
1414
+ * @param handlers The handler or handlers along with the event type to start listening for events.
1415
+ * @returns The instance for method chaining.
1416
+ */
1417
+ on: (handlers: TypeAndHandler | TypeAndHandler[]) => EventHandlers;
1418
+
1419
+ /**
1420
+ * Removes an event listener that was previously added via {@link on} or {@link once}.
1421
+ *
1422
+ * @param handlers The handler or handlers along with the event type to stop listening for events.
1423
+ * @returns The instance for method chaining.
1424
+ */
1425
+ off: (handlers: TypeAndHandler | TypeAndHandler[]) => EventHandlers;
1426
+
1427
+ /**
1428
+ * Adds the given event handler as a listener for events of the given type. After the first event is handled, this
1429
+ * handler will automatically be removed.
1430
+ *
1431
+ * @param handlers The handler or handlers along with the event type to start listening for an event.
1432
+ * @returns The instance for method chaining.
1433
+ */
1434
+ once: (handlers: TypeAndHandler | TypeAndHandler[]) => EventHandlers;
1435
+ }
1436
+
1437
+ /**
1438
+ * The type of handler for event bus events. This function may return a Promise in which case, the bus will await
1439
+ * the result and the loop will block until the Promise is resolved.
1440
+ */
1441
+ type EventBusHandler<T extends BusEvent = BusEvent> = (event: T, instance: ChatInstance) => unknown;
1442
+
1443
+ /**
1444
+ * The type of the object that is passed to the event bus functions (e.g. "on") when registering a handler.
1445
+ */
1446
+ interface TypeAndHandler {
1447
+ /**
1448
+ * The type of event this handler is for.
1449
+ */
1450
+ type: BusEventType;
1451
+
1452
+ /**
1453
+ * The handler for events of this type.
1454
+ */
1455
+ handler: EventBusHandler;
1456
+ }
1457
+
1458
+ /**
1459
+ * This is a subset of the public interface that provides methods that can be used by the user to control the widget
1460
+ * and have it perform certain actions.
1461
+ */
1462
+ interface ChatActions {
1463
+ /**
1464
+ * Messaging actions for a chat instance.
1465
+ */
1466
+ messaging: ChatInstanceMessaging;
1467
+
1468
+ /**
1469
+ * This function can be called when another component wishes this component to gain focus. It is up to the
1470
+ * component to decide where focus belongs. This may return true or false to indicate if a suitable focus location
1471
+ * was found.
1472
+ */
1473
+ requestFocus: () => boolean | void;
1474
+
1475
+ /**
1476
+ * Sends the given message to the assistant on the remote server. This will result in a "pre:send" and "send" event
1477
+ * being fired on the event bus. The returned promise will resolve once a response has received and processed and
1478
+ * both the "pre:receive" and "receive" events have fired. It will reject when too many errors have occurred and
1479
+ * the system gives up retrying.
1480
+ *
1481
+ * @param message The message to send.
1482
+ * @param options Options for the message sent.
1483
+ */
1484
+ send: (message: MessageRequest | string, options?: SendOptions) => Promise<void>;
1485
+
1486
+ /**
1487
+ * Updates the current locale. This will override the default values of the language pack. You can use
1488
+ * {@link getLocale} to identify the current locale if you need to make an update based on the user's locale.
1489
+ */
1490
+ updateLocale: (newLocale: string) => Promise<void>;
1491
+
1492
+ /**
1493
+ * Updates the current language pack using the values from the provided language pack. This language pack does
1494
+ * not need to be complete; only the strings contained in it will be updated. Any strings that are missing will be
1495
+ * ignored and the current values will remain unchanged. You can use {@link getLocale} to identify the current
1496
+ * locale if you need to make an update based on the user's locale.
1497
+ */
1498
+ updateLanguagePack: (newPack: DeepPartial<LanguagePack>) => void;
1499
+
1500
+ /**
1501
+ * Returns the current locale in use by the widget. This may not match the locale that was provided in the
1502
+ * original public configuration if that value was invalid or if the locale has been changed since then.
1503
+ *
1504
+ * @returns A string containing the language and possibly a region code. Example values include: 'en' and 'en-us'.
1505
+ */
1506
+ getLocale: () => string;
1507
+
1508
+ /**
1509
+ * Clears the current state and removes all references to the current session. Does not start a new session unless a
1510
+ * new message is subsequently sent.
1511
+ */
1512
+ destroySession: () => Promise<void>;
1513
+
1514
+ /**
1515
+ * If the messageID provided is the id of a response then save the data provided within history.user_defined so it can
1516
+ * be used to repopulate a message upon reload/page change with session history.
1517
+ */
1518
+ updateHistoryUserDefined: (messageID: string, data: unknown) => Promise<void>;
1519
+
1520
+ /**
1521
+ * This updates the map that can be used to override the values for CSS variables in the application. Each key of the
1522
+ * map is the name of a variable (without the "--cds-chat-" prefix) and the value is whatever the value of
1523
+ * the variable should be set at. This function may only be called if publicConfig.__ibm__.allowPrivateMethods has
1524
+ * been set. The values in the provided map will be merged with any variables that may already be defined in
1525
+ * the public config which allows this function to update only the specific variables desired.
1526
+ *
1527
+ * @param publicVars A map of CSS variables. Each key of the map is the name of a variable (without the
1528
+ * "--cds-chat-" prefix) and the value is whatever the value of the variable should be set at.
1529
+ */
1530
+ updateCSSVariables: (publicVars: Record<string, string>) => void;
1531
+
1532
+ /**
1533
+ * Fire the view:pre:change and view:change events and change the view of the web chat. If a {@link ViewType} is
1534
+ * provided then that view will become visible and the rest will be hidden. If a {@link ViewState} is provided that
1535
+ * includes all of the views then all of the views will be changed accordingly. If a partial {@link ViewState} is
1536
+ * provided then only the views provided will be changed.
1537
+ */
1538
+ changeView: (newView: ViewType | ViewState) => Promise<void>;
1539
+
1540
+ /**
1541
+ * Returns elements that Deb can write content to. This object is indirectly exposed to Deb using a proxy returned
1542
+ * from {@link createWriteableElementsProxy}.
1543
+ */
1544
+ writeableElements: WriteableElements;
1545
+
1546
+ /**
1547
+ * The elements of web chat that need to be exposed for customers to manipulate. Unlike writeable elements, these
1548
+ * elements have existing content
1549
+ */
1550
+ elements: InstanceElements;
1551
+
1552
+ /**
1553
+ * Methods provided to developers to interact with the tour feature.
1554
+ */
1555
+ tours: ChatInstanceTours;
1556
+
1557
+ /**
1558
+ * Allow being able to set the input field to be invisible on assistant facing (not agent) views. Helpful for when
1559
+ * you want to force input into a button, etc.
1560
+ */
1561
+ updateAssistantInputFieldVisibility: (isVisible: boolean) => void;
1562
+
1563
+ /**
1564
+ * Changes the state of web chat to allow or disallow input. This includes the input field as well as inputs like
1565
+ * buttons and dropdowns.
1566
+ */
1567
+ updateInputIsDisabled: (isDisabled: boolean) => void;
1568
+
1569
+ /**
1570
+ * Updates the visibility of the custom unread indicator that appears on the launcher. This indicator appears as a
1571
+ * small empty circle on the launcher. If there are any unread messages from a human agent, this indicator will be
1572
+ * shown with a number regardless of the custom setting of this flag.
1573
+ */
1574
+ updateBotUnreadIndicatorVisibility: (isVisible: boolean) => void;
1575
+
1576
+ /**
1577
+ * Updates the currently active homeScreenConfig. Currently only used in tooling to show live updates when editing web
1578
+ * chat configuration.
1579
+ */
1580
+ updateHomeScreenConfig: (homeScreenConfig: HomeScreenConfig) => void;
1581
+
1582
+ /**
1583
+ * Scrolls to the (original) message with the given ID. Since there may be multiple message items in a given
1584
+ * message, this will scroll the first message to the top of the message window.
1585
+ *
1586
+ * @param messageID The (original) message ID to scroll to.
1587
+ * @param animate Whether or not the scroll should be animated. Defaults to true.
1588
+ */
1589
+ scrollToMessage: (messageID: string, animate?: boolean) => void;
1590
+
1591
+ /**
1592
+ * Set the greeting message text for the launcher. Optionally specify which launcher, desktop or mobile, that the
1593
+ * greeting message is being set for.
1594
+ */
1595
+ updateLauncherGreetingMessage: (
1596
+ greetingMessage: string,
1597
+ launcherType?: LauncherType.DESKTOP | LauncherType.MOBILE,
1598
+ ) => void;
1599
+
1600
+ /**
1601
+ * Control when the greeting message should appear. The default time is 0s which will cause it to appear immediately.
1602
+ * Optionally specify which launcher, desktop or mobile, that the time should be set for.
1603
+ */
1604
+ showLauncherGreetingMessage: (time: number, launcherType?: LauncherType.DESKTOP | LauncherType.MOBILE) => void;
1605
+
1606
+ /**
1607
+ * An instance of the custom panel with methods to manipulate the behavior of the custom panels.
1608
+ */
1609
+ customPanels: CustomPanels;
1610
+
1611
+ /**
1612
+ * Updates the custom menu options.
1613
+ */
1614
+ updateCustomMenuOptions: (options: CustomMenuOption[]) => void;
1615
+
1616
+ /**
1617
+ * Restarts the conversation with the assistant. This does not make any changes to a conversation with a human agent.
1618
+ * This will clear all the current assistant messages from the main bot view and cancel any outstanding
1619
+ * messages. This will also clear the current assistant session which will force a new session to start on the
1620
+ * next message.
1621
+ */
1622
+ restartConversation: () => Promise<void>;
1623
+
1624
+ /**
1625
+ * Initiates a {@link Chat#doAutoScroll} on the currently visible chat panel.
1626
+ */
1627
+ doAutoScroll: () => void;
1628
+
1629
+ /**
1630
+ * Ends the conversation with a human agent. This does not request confirmation from the user first. If the user
1631
+ * is not connected or connecting to a human agent, this function has no effect. You can determine if the user is
1632
+ * connected or connecting by calling {@link ChatInstance.getState}. Note that this function
1633
+ * returns a Promise that only resolves when the conversation has ended. This includes after the
1634
+ * {@link BusEventType.AGENT_PRE_END_CHAT} and {@link BusEventType.AGENT_END_CHAT} events have been fired and
1635
+ * resolved.
1636
+ */
1637
+ agentEndConversation: () => Promise<void>;
1638
+
1639
+ /**
1640
+ * Either increases or decreases the internal counter that indicates whether the "bot is typing" indicator is
1641
+ * shown. If the count is greater than zero, then the indicator is shown. Values of "increase" or "decrease" will
1642
+ * increase or decrease the value. Any other value with log an error. Currently, this is the same as the loading
1643
+ * indicator.
1644
+ */
1645
+ updateIsTypingCounter: (direction: IncreaseOrDecrease) => void;
1646
+
1647
+ /**
1648
+ * Either increases or decreases the internal counter that indicates whether the "bot is loading" indicator is
1649
+ * shown. If the count is greater than zero, then the indicator is shown. Values of "increase" or "decrease" will
1650
+ * increase or decrease the value. Any other value with log an error. Currently, this is the same as the typing
1651
+ * indicator.
1652
+ */
1653
+ updateIsLoadingCounter: (direction: string) => void;
1654
+
1655
+ /**
1656
+ * Updates the title of the bot panel. This value defaults to the bot name with the AI theme turned off and defaults
1657
+ * to nothing when the AI theme is turned on.
1658
+ */
1659
+ updateMainHeaderTitle: (title?: null | string) => void;
1660
+
1661
+ /**
1662
+ * Add a system level notification to the list of system notifications.
1663
+ * @deprecated
1664
+ */
1665
+ addNotification: (notification: NotificationMessage) => void;
1666
+
1667
+ /**
1668
+ * The state of notifications in the chat.
1669
+ */
1670
+ notifications: ChatInstanceNotifications;
1671
+
1672
+ /**
1673
+ * Actions that are related to a service desk integration.
1674
+ */
1675
+ serviceDesk: ChatInstanceServiceDeskActions;
1676
+ }
1677
+ type IncreaseOrDecrease = 'increase' | 'decrease';
1678
+
1679
+ /**
1680
+ * This interface represents the options for when a MessageRequest is sent to the server with the send method.
1681
+ */
1682
+ interface SendOptions {
1683
+ /**
1684
+ * If you want to send a message to the API, but NOT have it show up in the UI, set this to true. The "pre:send"
1685
+ * and "send" events will still be fired but the message will not be added to the local message list displayed in
1686
+ * the UI. Note that the response message will still be added.
1687
+ */
1688
+ silent?: boolean;
1689
+
1690
+ /**
1691
+ * Indicates if the forced pause displayed with the response should be skipped. By default, web chat will insert a
1692
+ * pause to produce a delay of 2 seconds after the response has been received. This is to give the bot a more
1693
+ * natural, conversational feeling to it.
1694
+ */
1695
+ skipPause?: boolean;
1696
+ }
1697
+
1698
+ /**
1699
+ * An object of elements we expose to developers to write to. Currently, this only encompasses above the welcome node,
1700
+ * but may grow to include portions of home page, etc.
1701
+ */
1702
+ type WriteableElements = Record<WriteableElementName, HTMLElement>;
1703
+ declare enum WriteableElementName {
1704
+ /**
1705
+ * An element that appears in the AI theme only and is shown beneath the title and description in the AI tooltip
1706
+ * content.
1707
+ */
1708
+ AI_TOOLTIP_AFTER_DESCRIPTION_ELEMENT = 'aiTooltipAfterDescriptionElement',
1709
+
1710
+ /**
1711
+ * An element that appears in the main message body directly above the welcome node.
1712
+ */
1713
+ WELCOME_NODE_BEFORE_ELEMENT = 'welcomeNodeBeforeElement',
1714
+
1715
+ /**
1716
+ * An element that appears in the header on a new line. Only visible while talking to the bot.
1717
+ */
1718
+ HEADER_BOTTOM_ELEMENT = 'headerBottomElement',
1719
+
1720
+ /**
1721
+ * An element that appears after the messages area and before the input area.
1722
+ */
1723
+ BEFORE_INPUT_ELEMENT = 'beforeInputElement',
1724
+
1725
+ /**
1726
+ * An element that appears above the input field on the home screen.
1727
+ */
1728
+ HOME_SCREEN_BEFORE_INPUT_ELEMENT = 'homeScreenBeforeInputElement',
1729
+
1730
+ /**
1731
+ * An element that appears on the home screen after the conversation starters.
1732
+ */
1733
+ HOME_SCREEN_AFTER_STARTERS_ELEMENT = 'homeScreenAfterStartersElement',
1734
+
1735
+ /**
1736
+ * An element that appears on the home screen above the welcome message and conversation starters.
1737
+ */
1738
+ HOME_SCREEN_HEADER_BOTTOM_ELEMENT = 'homeScreenHeaderBottomElement',
1739
+ }
1740
+
1741
+ /**
1742
+ * The interface represents the elements that web chat provides access to.
1743
+ */
1744
+ interface InstanceElements {
1745
+ /**
1746
+ * Returns the element that represents the main window.
1747
+ */
1748
+ getMainWindow: () => HasAddRemoveClassName;
1749
+
1750
+ /**
1751
+ * Returns the element that represents the input field (text area) on the main message area.
1752
+ */
1753
+ getMessageInput: () => InstanceInputElement;
1754
+
1755
+ /**
1756
+ * Returns the element that represents the input field (text area) on the home screen.
1757
+ */
1758
+ getHomeScreenInput: () => InstanceInputElement;
1759
+ }
1760
+
1761
+ /**
1762
+ * Represents one of the input elements that web chat provides access to custom code.
1763
+ */
1764
+ interface InstanceInputElement {
1765
+ /**
1766
+ * The raw HTML element for the element.
1767
+ */
1768
+ getHTMLElement: () => HTMLTextAreaElement;
1769
+
1770
+ /**
1771
+ * Sets the current text value inside the input.
1772
+ */
1773
+ setValue: (value: string) => void;
1774
+
1775
+ /**
1776
+ * Enables or disables the handling of the enter key by the input field.
1777
+ */
1778
+ setEnableEnterKey: (isEnabled: boolean) => void;
1779
+
1780
+ /**
1781
+ * Adds a listener that will fire whenever the value in the input field is changed. This fires immediately like an
1782
+ * "input" event and not only when focus is lost like a "change".
1783
+ */
1784
+ addChangeListener: (listener: ChangeFunction) => void;
1785
+
1786
+ /**
1787
+ * Removes a change listener that was previously added.
1788
+ */
1789
+ removeChangeListener: (listener: ChangeFunction) => void;
1790
+
1791
+ /**
1792
+ * Sets the callback listener that is called before input is sent. This is called before the input field is
1793
+ * cleared after that send occurs.
1794
+ *
1795
+ * @param onBeforeSend The callback to call before the input is sent. The return value of this function will be passed
1796
+ * to the subsequent "pre:send" and "send" events that get fired with the actual message request.
1797
+ */
1798
+ setOnBeforeSend: (onBeforeSend: () => unknown) => void;
1799
+
1800
+ /**
1801
+ * Sets the callback to call to fetch a list of matching completions for entered text. This function is called
1802
+ * whenever the input in the input field is changed. This function may be asynchronous but it will be called again
1803
+ * if the user changes the input before the previous call is complete. In that case, the previous call is ignored.
1804
+ *
1805
+ * Also note that additional actions taken by the user (such as moving the cursor position) will cancel
1806
+ * completions resulting in any outstanding asynchronous calls being ignored.
1807
+ */
1808
+ setOnGetCompletions: (onGetCompletions: OnGetCompletions) => void;
1809
+
1810
+ /**
1811
+ * Sets the callback that is called when a completion is selected from the completions popup.
1812
+ */
1813
+ setOnCompletionSelected: (onCompletionSelected: OnCompletionSelected) => void;
1814
+ }
1815
+
1816
+ /**
1817
+ * Methods provided to developers to interact with the tour feature.
1818
+ */
1819
+ interface ChatInstanceTours {
1820
+ /**
1821
+ * Sends the given message to the backend with the skipTourCard option set to true. When a tour response is received,
1822
+ * this method automatically starts the tour and skips the tour card. If a response other than a tour is received,
1823
+ * then an error is logged.
1824
+ */
1825
+ startTour: (message: string) => void;
1826
+
1827
+ /**
1828
+ * Clears all tour data, closes the tour, and switches to the launcher.
1829
+ */
1830
+ endTour: () => void;
1831
+
1832
+ /**
1833
+ * Moves forward one step in the tour.
1834
+ */
1835
+ goToNextStep: () => void;
1836
+
1837
+ /**
1838
+ * Looks for the provided stepId string within the tour step items. If a step with a matching step_id is found then
1839
+ * moves to that step within the tour.
1840
+ */
1841
+ goToStep: (stepId: string) => void;
1842
+ }
1843
+ interface ChatInstanceNotifications {
1844
+ /**
1845
+ * Add a system level notification to the list of system notifications.
1846
+ */
1847
+ addNotification: (notification: NotificationMessage) => void;
1848
+
1849
+ /**
1850
+ * Remove a system level notification from the list of system notifications.
1851
+ */
1852
+ removeNotifications: (groupID: string) => void;
1853
+
1854
+ /**
1855
+ * Remove all system level notifications from the list of system notifications.
1856
+ */
1857
+ removeAllNotifications: () => void;
1858
+ }
1859
+ type ChangeFunction = (text: string) => void;
1860
+
1861
+ /**
1862
+ * Represents an item that can add or remove class names.
1863
+ */
1864
+ interface HasAddRemoveClassName {
1865
+ /**
1866
+ * Adds the given class name to the element.
1867
+ */
1868
+ addClassName(name: string): void;
1869
+
1870
+ /**
1871
+ * Removes the given class name from the element.
1872
+ */
1873
+ removeClassName(name: string): void;
1874
+ }
1875
+ interface FileUploadCapabilities {
1876
+ /**
1877
+ * Indicates that file uploads may be performed by the user.
1878
+ */
1879
+ allowFileUploads: boolean;
1880
+
1881
+ /**
1882
+ * If file uploads are allowed, this indicates if more than one file may be selected at a time. The default is false.
1883
+ */
1884
+ allowMultipleFileUploads: boolean;
1885
+
1886
+ /**
1887
+ * If file uploads are allowed, this is the set a file types that are allowed. This is filled into the "accept"
1888
+ * field for the file input element.
1889
+ */
1890
+ allowedFileUploadTypes: string;
1891
+ }
1892
+ interface ChatInstanceServiceDeskActions {
1893
+ /**
1894
+ * Ends the conversation with a human agent. This does not request confirmation from the user first. If the user
1895
+ * is not connected or connecting to a human agent, this function has no effect. You can determine if the user is
1896
+ * connected or connecting by calling {@link ChatInstance.getState}. Note that this function
1897
+ * returns a Promise that only resolves when the conversation has ended. This includes after the
1898
+ * {@link BusEventType.AGENT_PRE_END_CHAT} and {@link BusEventType.AGENT_END_CHAT} events have been fired and
1899
+ * resolved.
1900
+ */
1901
+ endConversation: () => Promise<void>;
1902
+
1903
+ /**
1904
+ * Sets the suspended state for an agent conversation. A conversation can be suspended or un-suspended only if the
1905
+ * user is currently connecting or connected to an agent. If a conversation is suspended, then messages from the user
1906
+ * will no longer be routed to the service desk and incoming messages from the service desk will not be displayed. In
1907
+ * addition, the current connection status with an agent will not be shown.
1908
+ */
1909
+ updateIsSuspended: (isSuspended: boolean) => Promise<void>;
1910
+ }
1911
+
1912
+ /**
1913
+ * The section of the public config that contains configuration options for service desk integrations.
1914
+ */
1915
+ interface ServiceDeskPublicConfig {
1916
+ /**
1917
+ * The timeout value in seconds to use when determining agent availability. When a connect_to_agent response is
1918
+ * received, the system will ask the service desk if any agents are available. If no response is received within
1919
+ * the timeout window, the system will return "false" to indicate no agents are available.
1920
+ */
1921
+ availabilityTimeoutSeconds?: number;
1922
+
1923
+ /**
1924
+ * Indicates if web chat should auto-connect to an agent whenever it receives a connect_to_agent response and
1925
+ * agents are available. This essentially mimics the user clicking the "Request agent" button on the card. The
1926
+ * card is still displayed to the user.
1927
+ */
1928
+ skipConnectAgentCard?: boolean;
1929
+
1930
+ /**
1931
+ * The timeout value is seconds to use when waiting for an agent to join the chat after an agent has been
1932
+ * requested. If no agent joins after this time, the chat will be ended and an error message will be displayed to
1933
+ * the user. By default, there is no timeout.
1934
+ */
1935
+ agentJoinTimeoutSeconds?: number;
1936
+
1937
+ /**
1938
+ * Indicates whether the conversation between a user and a service desk should be stored in session history.
1939
+ */
1940
+ disableAgentSessionHistory?: boolean;
1941
+
1942
+ /**
1943
+ * This indicates which of the client-only service desk integrations to use.
1944
+ */
1945
+ integrationType?: string;
1946
+
1947
+ /**
1948
+ * Configuration data for the Genesys Web Messenger integration
1949
+ */
1950
+ genesysMessenger?: GenesysMessengerConfig;
1951
+
1952
+ /**
1953
+ * Configuration data for the Nice DFO integration
1954
+ */
1955
+ niceDFO?: NiceDFOConfig;
1956
+ }
1957
+
1958
+ /**
1959
+ * The configuration in the main config that is needed to initialize the SDK.
1960
+ */
1961
+ interface NiceDFOConfig {
1962
+ /**
1963
+ * The channel ID from the Nice embed code.
1964
+ */
1965
+ channelID: string;
1966
+
1967
+ /**
1968
+ * The brand ID from the Nice embed code.
1969
+ */
1970
+ brandID: number;
1971
+
1972
+ /**
1973
+ * The Nice environment where the account is hosted.
1974
+ */
1975
+ environment: string;
1976
+
1977
+ /**
1978
+ * Indicates if the web chat user ID should be used. By default, if web chat is using a web chat generated
1979
+ * anonymous ID, then a new unique ID is generated for the user on each interaction with Nice. If web chat is
1980
+ * using a user ID provided by the host page, then that ID will be used instead. This value can be used to
1981
+ * override that behavior. If this value is true, then the web chat user ID will be used even if it's for an
1982
+ * anonymous user. If this value is false, then a new unique ID will be generated instead.
1983
+ */
1984
+ useWebChatUserID?: boolean;
1985
+ }
1986
+
1987
+ /**
1988
+ * The configuration needed to connect to Genesys for a Web Messenger deployment.
1989
+ */
1990
+ interface GenesysMessengerConfig {
1991
+ /**
1992
+ * The environment to connect to.
1993
+ */
1994
+ environment: string;
1995
+
1996
+ /**
1997
+ * The deployment ID for the deployment.
1998
+ */
1999
+ deploymentID: string;
2000
+
2001
+ /**
2002
+ * The script URL for the SDK to use.
2003
+ */
2004
+ scriptURL: string;
2005
+ }
2006
+
2007
+ /**
2008
+ * Represents the different states for the availability of a human agent from a service desk.
2009
+ */
2010
+ declare enum AgentsOnlineStatus {
2011
+ /**
2012
+ * Indicates that agents are online.
2013
+ */
2014
+ ONLINE = 'online',
2015
+
2016
+ /**
2017
+ * Indicates that no agents are online.
2018
+ */
2019
+ OFFLINE = 'offline',
2020
+
2021
+ /**
2022
+ * Indicates that it is unknown whether any agents are available. This may be because the service desk being used
2023
+ * doesn't support the ability to determine this information.
2024
+ */
2025
+ UNKNOWN = 'unknown',
2026
+ }
2027
+
2028
+ /**
2029
+ * The parameters that are passed to a service desk factory.
2030
+ */
2031
+ interface ServiceDeskFactoryParameters {
2032
+ /**
2033
+ * The callback used by the service desk to communicate with the widget.
2034
+ */
2035
+ callback: ServiceDeskCallback;
2036
+
2037
+ /**
2038
+ * The instance of web chat.
2039
+ */
2040
+ instance: ChatInstance;
2041
+
2042
+ /**
2043
+ * Any state that was stored for the service desk. This value may be undefined if no state has been stored.
2044
+ */
2045
+ persistedState: unknown;
2046
+ }
2047
+
2048
+ /**
2049
+ * This interface represents the operations that a service desk integration can call on web chat when it wants web
2050
+ * chat to do something. When a service desk integration instance is created, web chat will provide an
2051
+ * implementation of this interface to the integration for it to use.
2052
+ */
2053
+ interface ServiceDeskCallback<TPersistedStateType = unknown> {
2054
+ /**
2055
+ * Updates web chat with the capabilities supported by the service desk. Some of these capabilities may support
2056
+ * being changed dynamically and can be updated at any time.
2057
+ *
2058
+ * @param capabilities The set of capabilities to update. Only properties that need to be changed need to be included.
2059
+ */
2060
+ updateCapabilities(capabilities: Partial<ServiceDeskCapabilities>): void;
2061
+
2062
+ /**
2063
+ * Sends updated availability information to the chat widget for a user who is waiting to be connected to an
2064
+ * agent (e.g. the user is number 2 in line). This may be called at any point while waiting for the connection to
2065
+ * provide newer information.
2066
+ *
2067
+ * Note: Of the fields in the AgentAvailability object, only one of position_in_queue and estimated_wait_time can be
2068
+ * rendered in the widget. If both fields are provided, estimated_wait_time will take priority and the
2069
+ * position_in_queue field will be ignored.
2070
+ *
2071
+ * @param availability The availability information to display to the user.
2072
+ */
2073
+ updateAgentAvailability(availability: AgentAvailability): Promise<void>;
2074
+
2075
+ /**
2076
+ * Informs the chat widget that an agent has joined the chat.
2077
+ */
2078
+ agentJoined(profile: AgentProfile): Promise<void>;
2079
+
2080
+ /**
2081
+ * Informs the chat widget that the agent has read all the messages that have been sent to the service desk.
2082
+ */
2083
+ agentReadMessages(): Promise<void>;
2084
+
2085
+ /**
2086
+ * Tells the chat widget if an agent has started or stopped typing.
2087
+ *
2088
+ * @param isTyping If true, indicates that the agent is typing. False indicates the agent has stopped typing.
2089
+ */
2090
+ agentTyping(isTyping: boolean): Promise<void>;
2091
+
2092
+ /**
2093
+ * Sends a message to the chat widget from an agent.
2094
+ *
2095
+ * Note: The text response type from the standard Watson API is supported in addition to the web chat specific
2096
+ * MessageResponseTypes.INLINE_ERROR response type.
2097
+ *
2098
+ * @param message The message to display to the user. Note, the ability to pass a string for the message was added in
2099
+ * web chat 6.7.0. Earlier versions of web chat will not work if you pass just a string.
2100
+ * @param agentID The ID of the agent who is sending the message. If this is not provided, then the ID of the last
2101
+ * agent who joined the conversation will be used.
2102
+ */
2103
+ sendMessageToUser(message: MessageResponse | string, agentID?: string): Promise<void>;
2104
+
2105
+ /**
2106
+ * Informs the chat widget that a transfer to another agent is in progress. The agent profile information is
2107
+ * optional if the service desk doesn't have the information available. This message simply tells the chat widget
2108
+ * that the transfer has started. The service desk should inform the widget when the transfer is complete by
2109
+ * sending a {@link agentJoined} message later.
2110
+ */
2111
+ beginTransferToAnotherAgent(profile?: AgentProfile): Promise<void>;
2112
+
2113
+ /**
2114
+ * Informs the chat widget that the agent has left the conversation. This does not end the conversation itself,
2115
+ * rather the only action that occurs is the visitor receives the agent left status message. If the user sends
2116
+ * another message, it is up to the service desk to decide what to do with it.
2117
+ */
2118
+ agentLeftChat(): Promise<void>;
2119
+
2120
+ /**
2121
+ * Informs the chat widget that the agent has ended the conversation.
2122
+ */
2123
+ agentEndedChat(): Promise<void>;
2124
+
2125
+ /**
2126
+ * Sets the state of the given error type.
2127
+ *
2128
+ * @param errorInfo Details for the error whose state is being set.
2129
+ */
2130
+ setErrorStatus(errorInfo: ServiceDeskErrorInfo): Promise<void>;
2131
+
2132
+ /**
2133
+ * Updates the status of a file upload. The upload may either be successful or an error may have occurred. The
2134
+ * location of a file upload may be in one of two places. The first occurs when the user has selected a file to be
2135
+ * uploaded but has not yet sent the file. In this case, the file appears inside the web chat input area. If an
2136
+ * error is indicated on the file, the error message will be displayed along with the file and the user must
2137
+ * remove the file from the input area before a message can be sent.
2138
+ *
2139
+ * The second occurs after the user has sent the file and the service desk has begun to upload the file. In this
2140
+ * case, the file no longer appears in the input area but appears as a sent message in the message list. If an
2141
+ * error occurs during this time, an icon will appear next to the message to indicate an error occurred and an
2142
+ * error message will be added to the message list.
2143
+ *
2144
+ * @param fileID The ID of the file upload to update.
2145
+ * @param isError Indicates that the upload has an error or failed to upload.
2146
+ * @param errorMessage An error message to display along with a file in error.
2147
+ */
2148
+ setFileUploadStatus(fileID: string, isError?: boolean, errorMessage?: string): Promise<void>;
2149
+
2150
+ /**
2151
+ * Requests that the user share their screen with the agent. This will present a modal dialog to the user who must
2152
+ * respond before continuing the conversation. This method returns a Promise that resolves when the user has
2153
+ * responded to the request or the request times out.
2154
+ *
2155
+ * @returns Returns a Promise that will resolve with the state the of the request. This Promise will reject if no
2156
+ * chat with an agent is currently running.
2157
+ */
2158
+ screenShareRequest(): Promise<ScreenShareState>;
2159
+
2160
+ /**
2161
+ * Informs web chat that a screen sharing session has ended or been cancelled. This may occur while waiting for a
2162
+ * screen sharing request to be accepted or while screen sharing is in progress.
2163
+ */
2164
+ screenShareEnded(): Promise<void>;
2165
+
2166
+ /**
2167
+ * Returns the persisted agent state from the store. This is the current state as updated by
2168
+ * {@link updatePersistedState}. The object returned here is frozen and may not be modified.
2169
+ */
2170
+ persistedState(): TPersistedStateType;
2171
+
2172
+ /**
2173
+ * Allows the service desk to store state that may be retrieved when web chat is reloaded on a page. This information
2174
+ * is stored in browser session storage which has a total limit of 5MB per origin so the storage should be used
2175
+ * sparingly. Also, the value provided here must be JSON serializable.
2176
+ *
2177
+ * When web chat is reloaded, the data provided here will be returned to the service desk via the
2178
+ * ServiceDeskFactoryParameters.persistedState property. This data may also be retrieved by using the
2179
+ * {@link persistedState} method.
2180
+ *
2181
+ * @param state The state to update.
2182
+ * @param mergeWithCurrent Indicates if the new state should be merged into the existing state. If false, then the
2183
+ * existing state will be fully replaced with the new state. Merging with existing state expects the state to be
2184
+ * an object. This argument is true by default.
2185
+ */
2186
+ updatePersistedState(state: DeepPartial<TPersistedStateType>, mergeWithCurrent?: boolean): void;
2187
+ }
2188
+
2189
+ /**
2190
+ * The set of capabilities and parameters that are supported by the service desk.
2191
+ */
2192
+ interface ServiceDeskCapabilities extends FileUploadCapabilities {}
2193
+
2194
+ /**
2195
+ * The possible state changes for a screen sharing request.
2196
+ */
2197
+ declare enum ScreenShareState {
2198
+ /**
2199
+ * Indicates the screen sharing was accepted by the user.
2200
+ */
2201
+ ACCEPTED = 'accepted',
2202
+
2203
+ /**
2204
+ * Indicates the screen sharing was declined by the user.
2205
+ */
2206
+ DECLINED = 'declined',
2207
+
2208
+ /**
2209
+ * Indicates the screen sharing request was cancelled.
2210
+ */
2211
+ CANCELLED = 'cancelled',
2212
+
2213
+ /**
2214
+ * Indicates that screen sharing has ended.
2215
+ */
2216
+ ENDED = 'ended',
2217
+ }
2218
+
2219
+ /**
2220
+ * Information about the current availability of an agent while a user is waiting to be connected. If these are not set
2221
+ * the web chat will provide generic messaging letting the user know that a request for an agent has been sent.
2222
+ *
2223
+ * Note that only one of these fields will be used by web chat if more than one has been assigned a value. Priority
2224
+ * first goes to estimated_wait_time, then position_in_queue, and then message.
2225
+ */
2226
+ interface AgentAvailability {
2227
+ /**
2228
+ * The current position of the user in a queue. E.g. "You are number 2 in line."
2229
+ */
2230
+ position_in_queue?: number;
2231
+
2232
+ /**
2233
+ * The estimated wait time for the user in minutes. E.g. "Current wait time is 2 minutes."
2234
+ */
2235
+ estimated_wait_time?: number;
2236
+
2237
+ /**
2238
+ * A custom message to display to the user containing the updated status. This may contain markdown.
2239
+ *
2240
+ * @since Web chat 6.7.0. This value will be ignored if used with earlier versions of web chat.
2241
+ */
2242
+ message?: string;
2243
+ }
2244
+
2245
+ /**
2246
+ * The possible events that may have some form of error status.
2247
+ */
2248
+ declare enum ErrorType {
2249
+ /**
2250
+ * This error is meant to be displayed while the user is attempting to connect to a service desk and before an
2251
+ * agent has joined. If this error is generated by the service desk, it is expected that the service desk will
2252
+ * treat the chat as having ended (or never started).
2253
+ */
2254
+ CONNECTING = 1,
2255
+
2256
+ /**
2257
+ * This is used to indicate the state of errors that can happen any time during a chat where the service desk
2258
+ * implementation has lost a connection to the back-end. If this error occurs while the user is waiting for an
2259
+ * agent to join, it will be treated as a {@link CONNECTING} error instead.
2260
+ */
2261
+ DISCONNECTED = 2,
2262
+
2263
+ /**
2264
+ * This error is used to report when there was an error sending a message to the agent.
2265
+ */
2266
+ USER_MESSAGE = 3,
2267
+ }
2268
+
2269
+ /**
2270
+ * This is the parent interface for the information passed to {@link ServiceDeskCallback#setErrorStatus}. It is used
2271
+ * as a discriminating union where the {@link #type} property is the discriminating value that determines which
2272
+ * child interface is to be used.
2273
+ */
2274
+ interface BaseErrorInfo {
2275
+ /**
2276
+ * An optional value that will be logged to the console as an error.
2277
+ */
2278
+ logInfo?: unknown;
2279
+ }
2280
+
2281
+ /**
2282
+ * This error is meant to be displayed while the user is attempting to connect to a service desk and before an
2283
+ * agent has joined. If this error is generated by the service desk, it is expected that the service desk will
2284
+ * treat the chat as having ended (or never started).
2285
+ */
2286
+ interface ConnectingErrorInfo extends BaseErrorInfo {
2287
+ /**
2288
+ * The discriminating value for this type.
2289
+ */
2290
+ type: ErrorType.CONNECTING;
2291
+
2292
+ /**
2293
+ * An optional message that is displayed to the user in the bot view. If this value is not provided, a default
2294
+ * message will be shown instead.
2295
+ *
2296
+ * Note that support for this field was added in web chat 6.7.0. It will be ignored in earlier versions.
2297
+ */
2298
+ messageToUser?: string;
2299
+ }
2300
+
2301
+ /**
2302
+ * This is used to indicate the state of errors that can happen any time during a chat where the service desk
2303
+ * implementation has lost a connection to the back-end. If this error occurs while the user is waiting for an
2304
+ * agent to join, it will be treated as a {@link CONNECTING} error instead.
2305
+ */
2306
+ interface DisconnectedErrorInfo extends BaseErrorInfo {
2307
+ /**
2308
+ * The discriminating value for this type.
2309
+ */
2310
+ type: ErrorType.DISCONNECTED;
2311
+
2312
+ /**
2313
+ * Indicates if the service desk has become disconnected. A value of true can be passed that will indicate that a
2314
+ * previous disconnection is over and the service desk is now connected again.
2315
+ */
2316
+ isDisconnected: boolean;
2317
+ }
2318
+
2319
+ /**
2320
+ * This error is used to report when there was an error sending a message to the agent. {
2321
+ */
2322
+ interface UserMessageErrorInfo extends BaseErrorInfo {
2323
+ /**
2324
+ * The discriminating value for this type.
2325
+ */
2326
+ type: ErrorType.USER_MESSAGE;
2327
+
2328
+ /**
2329
+ * The ID of the message that is in error.
2330
+ */
2331
+ messageID: string;
2332
+ }
2333
+
2334
+ /**
2335
+ * The type for the information passed to {@link ServiceDeskCallback#setErrorStatus}. It is a discriminating union
2336
+ * where the {@link #type} property is the discriminating value that determines which child interface is to be used.
2337
+ */
2338
+ type ServiceDeskErrorInfo = ConnectingErrorInfo | DisconnectedErrorInfo | UserMessageErrorInfo;
2339
+
2340
+ /**
2341
+ * Additional options that may be passed to the service desk when a chat is started.
2342
+ */
2343
+ interface StartChatOptions<TPayloadType = unknown> {
2344
+ /**
2345
+ * Information necessary for loading an agent app version of web chat.
2346
+ */
2347
+ agentAppInfo?: AgentAppInfo;
2348
+
2349
+ /**
2350
+ * Some arbitrary payload of data that was provided as part of the "agent:pre:startChat" event.
2351
+ */
2352
+ preStartChatPayload: TPayloadType;
2353
+ }
2354
+
2355
+ /**
2356
+ * This data is used to configure a read only web chat inside the service desk.
2357
+ */
2358
+ interface AgentAppInfo {
2359
+ /**
2360
+ * A string that is separated by AGENT_APP_KEY_SEPARATOR that can be used to create a PublicConfig. It includes base
2361
+ * connect info like integrationID, etc., and by pass JWT security with a one time auth code.
2362
+ *
2363
+ * @see ConnectToAgentItemTransferInfo.session_history_key
2364
+ */
2365
+ sessionHistoryKey: string;
2366
+ }
2367
+
2368
+ /**
2369
+ * Additional info that may be provided when a chat is ended.
2370
+ */
2371
+ interface EndChatInfo<TPayloadType = unknown> {
2372
+ /**
2373
+ * Before a chat is ended, a {@link BusEventType.AGENT_PRE_END_CHAT} is fired. The payload value assigned to this
2374
+ * event by a listener is provided here.
2375
+ */
2376
+ preEndChatPayload: TPayloadType;
2377
+
2378
+ /**
2379
+ * Indicates if the chat was ended by the agent (or by the service desk integration). If false, indicates the chat
2380
+ * was ended by the user or by web chat.
2381
+ */
2382
+ endedByAgent: boolean;
2383
+ }
2384
+
2385
+ /**
2386
+ * This is a set of additional data that may be included when the user sends a message to an agent.
2387
+ */
2388
+ interface AdditionalDataToAgent {
2389
+ /**
2390
+ * A set of files that user has selected to upload to an agent. This value may be undefined if there are no files
2391
+ * to upload.
2392
+ */
2393
+ filesToUpload?: FileUpload[];
2394
+ }
2395
+
2396
+ /**
2397
+ * This is the public interface for a human agent service desk integration. This is the interface between the chat
2398
+ * widget and the implementation of the human agent interface with one of the various supported service desks.
2399
+ */
2400
+ interface ServiceDesk {
2401
+ /**
2402
+ * Returns a name for this service desk integration. This value should reflect the service desk that is being
2403
+ * integrated to (e.g. "genesys web messenger"). This information will be reported to IBM and may be used to gauge
2404
+ * interest in various service desks for the possibility of creating fully supported out-of-the-box implementations.
2405
+ *
2406
+ * This value is required for custom service desks and may have a maximum of 40 characters.
2407
+ */
2408
+ getName?: () => string;
2409
+
2410
+ /**
2411
+ * Instructs the service desk to start a new chat. This will be called when a user requests to connect to an agent
2412
+ * and web chat initiates the process (typically when the user clicks the button on the "Connect to Agent" card).
2413
+ * It will make the appropriate calls to the service desk to start the chat and will make use of the callback to
2414
+ * inform web chat when an agent joins or messages are received.
2415
+ *
2416
+ * This may be called multiple times by web chat. If a user begins a chat with an agent, ends the chat and then
2417
+ * begins a new chat with an agent, this function will be called again.
2418
+ *
2419
+ * If the integration is unable to start a chat (such as if the service desk is down or no agents are available)
2420
+ * then this function should throw an error to let web chat know that the chat could not be started.
2421
+ *
2422
+ * The {@link areAnyAgentsOnline} function is called before this function is called and is called as soon as a
2423
+ * "connect_to_agent" message has been received from the assistant. This determines if the "Connect to Agent" card
2424
+ * should be displayed to the user or if the "no agents are available" message configured in the skill should be
2425
+ * shown instead.
2426
+ *
2427
+ * @param connectMessage The original server message response that caused the connection to an agent. It will
2428
+ * contain specific information to send to the service desk as part of the connection. This can include things
2429
+ * like a message to display to a human agent.
2430
+ * @param startChatOptions Additional configuration for startChat.
2431
+ * @returns Returns a Promise that resolves when the service desk has successfully started a new chat. This does
2432
+ * not necessarily mean that an agent has joined the conversation or has read any messages sent by the user.
2433
+ */
2434
+ startChat: (connectMessage: MessageResponse, startChatOptions: StartChatOptions) => Promise<void>;
2435
+
2436
+ /**
2437
+ * Tells the service desk to terminate the chat.
2438
+ *
2439
+ * @param info Additional info that may be provided as part of ending the chat.
2440
+ * @returns Returns a Promise that resolves when the service desk has successfully handled the call.
2441
+ */
2442
+ endChat: (info: EndChatInfo) => Promise<void>;
2443
+
2444
+ /**
2445
+ * Sends a message to the agent in the service desk. Note that the message text may be empty if the user has
2446
+ * selected files to upload and has not chosen to include a message to go along with the files.
2447
+ *
2448
+ * @param message The message from the user.
2449
+ * @param messageID The unique ID of the message assigned by the widget.
2450
+ * @param additionalData Additional data to include in the message to the agent.
2451
+ * @returns Returns a Promise that resolves when the service desk has successfully handled the call.
2452
+ */
2453
+ sendMessageToAgent: (
2454
+ message: MessageRequest,
2455
+ messageID: string,
2456
+ additionalData: AdditionalDataToAgent,
2457
+ ) => Promise<void>;
2458
+
2459
+ /**
2460
+ * Informs the service desk of a change in the state of the web chat that is relevant to the service desks. These
2461
+ * values may change at any time.
2462
+ */
2463
+ updateState?: (state: ServiceDeskStateFromWAC) => void;
2464
+
2465
+ /**
2466
+ * Tells the service desk if a user has started or stopped typing.
2467
+ *
2468
+ * @param isTyping If true, indicates that the user is typing. False indicates the user has stopped typing.
2469
+ * @returns Returns a Promise that resolves when the service desk has successfully handled the call.
2470
+ * @since 5.1.1
2471
+ */
2472
+ userTyping?: (isTyping: boolean) => Promise<void>;
2473
+
2474
+ /**
2475
+ * Informs the service desk that the user has read all the messages that have been sent by the service desk.
2476
+ *
2477
+ * @returns Returns a Promise that resolves when the service desk has successfully handled the call.
2478
+ */
2479
+ userReadMessages?: () => Promise<void>;
2480
+
2481
+ /**
2482
+ * Checks if any agents are online and can connect to a user when they become available. This does not necessarily
2483
+ * mean that an agent is immediately available; when a chat is started, the user may still have to wait for an
2484
+ * agent to become available. The callback function {@link ServiceDeskCallback.updateAgentAvailability} is used to
2485
+ * give the user more up-to-date information while they are waiting for an agent to become available.
2486
+ *
2487
+ * @param connectMessage The message that contains the transfer_info object that may be used by the service desk,
2488
+ * so it can perform a more specific check.
2489
+ * @returns True if some agents are available or false if no agents are available. This may also return null which
2490
+ * means the availability status of agents is unknown or the service desk doesn't support this information.
2491
+ */
2492
+ areAnyAgentsOnline?: (connectMessage: MessageResponse) => Promise<boolean | null>;
2493
+
2494
+ /**
2495
+ * Indicates that the user has selected some files to be uploaded but that the user has not yet chosen to send
2496
+ * them to the agent. This method can use this as an opportunity to perform any early validation of the files in
2497
+ * order to display an error to the user. It should not actually upload the files at this point. If the user
2498
+ * chooses to send the files to the agent, they will be included later when {@link #sendMessageToAgent} is called.
2499
+ *
2500
+ * This method may be called multiple times before a user sends the files.
2501
+ *
2502
+ * If there are errors in the files, this method should use {@link ServiceDeskCallback#setFileUploadStatus} to update
2503
+ * the status with an error message. The user will not be able to upload any files until any files in error are
2504
+ * removed.
2505
+ */
2506
+ filesSelectedForUpload?: (uploads: FileUpload[]) => void;
2507
+
2508
+ /**
2509
+ * Tells the service desk that the user has requested to stop sharing their screen.
2510
+ */
2511
+ screenShareStop?: () => Promise<void>;
2512
+
2513
+ /**
2514
+ * This will be called when the service desk is first initialized and it is determined that the user was previously
2515
+ * connected to an agent. This function should perform whatever steps are necessary to reconnect the user. Web chat
2516
+ * will assume the user is permitted to send messages and is connected to the same agent when this function resolves.
2517
+ *
2518
+ * @returns true to indicate that the reconnect was successful.
2519
+ */
2520
+ reconnect?: () => Promise<boolean>;
2521
+ }
2522
+
2523
+ /**
2524
+ * This interface represents the pieces of web chat state that can be provided to the service desks. Any of these
2525
+ * bits of state may be updated at any time and the service desks need to be prepared to handle the changes to these
2526
+ * values.
2527
+ */
2528
+ interface ServiceDeskStateFromWAC {
2529
+ /**
2530
+ * The current session ID. This may change at any point if the user's session times out and a new session is created.
2531
+ */
2532
+ sessionID: string;
2533
+
2534
+ /**
2535
+ * The ID of the current user. This can be changed when a user becomes authenticated.
2536
+ */
2537
+ userID: string;
2538
+
2539
+ /**
2540
+ * The current locale.
2541
+ */
2542
+ locale: string;
2543
+ }
2544
+
2545
+ /**
2546
+ * These are the human agent specific message types.
2547
+ */
2548
+ declare enum AgentMessageType {
2549
+ INLINE_ERROR = 'inline_error',
2550
+ FROM_AGENT = 'from_agent',
2551
+ FROM_USER = 'from_user',
2552
+ AGENT_LEFT_CHAT = 'agent_left_chat',
2553
+ AGENT_ENDED_CHAT = 'agent_ended_chat',
2554
+ AGENT_JOINED = 'agent_joined',
2555
+ RELOAD_WARNING = 'user_connected_warning',
2556
+ TRANSFER_TO_AGENT = 'transfer_to_agent',
2557
+ USER_ENDED_CHAT = 'user_ended_chat',
2558
+ CHAT_WAS_ENDED = 'chat_was_ended',
2559
+ DISCONNECTED = 'disconnected',
2560
+ RECONNECTED = 'reconnected',
2561
+ SHARING_REQUESTED = 'sharing_requested',
2562
+ SHARING_ACCEPTED = 'sharing_accepted',
2563
+ SHARING_DECLINED = 'sharing_declined',
2564
+ SHARING_CANCELLED = 'sharing_cancelled',
2565
+ SHARING_ENDED = 'sharing_ended',
2566
+ SYSTEM = 'system',
2567
+ }
2568
+
2569
+ /**
2570
+ * This file contains the type definitions for the event bus.
2571
+ */
2572
+
2573
+ declare const enum BusEventType {
2574
+ CLOSE_PANEL_BUTTON_TOGGLED = 'closePanelButton:toggled',
2575
+ PRE_RECEIVE = 'pre:receive',
2576
+ RECEIVE = 'receive',
2577
+ PRE_SEND = 'pre:send',
2578
+ SEND = 'send',
2579
+ VIEW_PRE_CHANGE = 'view:pre:change',
2580
+ VIEW_CHANGE = 'view:change',
2581
+ MESSAGE_ITEM_CUSTOM = 'messageItemCustom',
2582
+ CUSTOM_RESPONSE = 'customResponse',
2583
+ USER_DEFINED_RESPONSE = 'userDefinedResponse',
2584
+ PROCESS_OPEN = 'process:open',
2585
+ PROCESS_CLOSE = 'process:close',
2586
+ PROCESS_CANCEL = 'process:cancel',
2587
+ HISTORY_BEGIN = 'history:begin',
2588
+ HISTORY_END = 'history:end',
2589
+ IDENTITY_EXPIRED = 'identityTokenExpired',
2590
+ PRE_RESTART_CONVERSATION = 'pre:restartConversation',
2591
+ RESTART_CONVERSATION = 'restartConversation',
2592
+ CHAT_READY = 'chat:ready',
2593
+ CUSTOM_PANEL_PRE_OPEN = 'customPanel:pre:open',
2594
+ CUSTOM_PANEL_OPEN = 'customPanel:open',
2595
+ CUSTOM_PANEL_PRE_CLOSE = 'customPanel:pre:close',
2596
+ CUSTOM_PANEL_CLOSE = 'customPanel:close',
2597
+ SESSION_EXPIRED = 'sessionExpired',
2598
+ TOUR_START = 'tour:start',
2599
+ TOUR_END = 'tour:end',
2600
+ TOUR_STEP = 'tour:step',
2601
+
2602
+ /**
2603
+ * This event is fired before web chat processes a message received from a human agent from a service desk.
2604
+ */
2605
+ AGENT_PRE_RECEIVE = 'agent:pre:receive',
2606
+
2607
+ /**
2608
+ * This event is fired after web chat processes a message received from a human agent from a service desk.
2609
+ */
2610
+ AGENT_RECEIVE = 'agent:receive',
2611
+
2612
+ /**
2613
+ * This event is fired before web chat sends a message to a human agent from a service desk.
2614
+ */
2615
+ AGENT_PRE_SEND = 'agent:pre:send',
2616
+
2617
+ /**
2618
+ * This event is fired after web chat sends a message to a human agent from a service desk.
2619
+ */
2620
+ AGENT_SEND = 'agent:send',
2621
+
2622
+ /**
2623
+ * This event is fired before a chat with a service desk has started. This occurs as soon as the user clicks the
2624
+ * "Request agent" button and before any attempt is made to communicate with the service desk.
2625
+ */
2626
+ AGENT_PRE_START_CHAT = 'agent:pre:startChat',
2627
+
2628
+ /**
2629
+ * This event is fired before a chat with an agent is ended. This occurs after the user has selected "Yes" from the
2630
+ * confirmation modal but it can also be fired if the chat is ended by the agent. Note that this is not fired if a
2631
+ * request for an agent is cancelled. The agent:endChat event however is fired in that case.
2632
+ */
2633
+ AGENT_PRE_END_CHAT = 'agent:pre:endChat',
2634
+
2635
+ /**
2636
+ * This event is fired after a chat with an agent has ended. This is fired after {@link AGENT_PRE_END_CHAT} but
2637
+ * can be fired both from the user leaving the chat or the agent ending the chat.
2638
+ */
2639
+ AGENT_END_CHAT = 'agent:endChat',
2640
+
2641
+ /**
2642
+ * This event is fired after web chat calls "areAnyAgentsOnline" for a service desk. It will report the value returned
2643
+ * from that call. This is particularly useful if some custom code wants to take action if no agents are online.
2644
+ */
2645
+ AGENT_ARE_ANY_AGENTS_ONLINE = 'agent:areAnyAgentsOnline',
2646
+
2647
+ /**
2648
+ * This event is fired before a message between the user and a live agent is added to session history. It allows
2649
+ * the customer to modify the message in order to do things like remove PII from being stored by IBM watsonx
2650
+ * Assistant.
2651
+ */
2652
+ AGENT_PRE_SESSION_HISTORY = 'agent:pre:sessionHistory',
2653
+ GENESYS_MESSENGER_AUTH_PROVIDER = 'agent:genesysMessenger:AuthProvider',
2654
+ GENESYS_MESSENGER_GET_AUTH_CODE = 'agent:genesysMessenger:getAuthCode',
2655
+ GENESYS_MESSENGER_REAUTHENTICATE = 'agent:genesysMessenger:reAuthenticate',
2656
+ GENESYS_MESSENGER_LOGGED_OUT = 'agent:genesysMessenger:loggedOut',
2657
+ GENESYS_MESSENGER_AUTH_ERROR = 'agent:genesysMessenger:authError',
2658
+ NICE_DFO_GET_AUTH_CODE = 'agent:niceDFO:getAuthCode',
2659
+ CHUNK_USER_DEFINED_RESPONSE = 'chunk:userDefinedResponse',
2660
+ ALL_EVENTS = '*',
2661
+ }
2662
+
2663
+ /**
2664
+ * The possible reasons why the view may be changed.
2665
+ */
2666
+ declare enum ViewChangeReason {
2667
+ /**
2668
+ * Indicates the web chat has loaded for the first time and a view is trying to open. If {@link openChatByDefault} is
2669
+ * true then the main window will be trying to open, otherwise the launcher will be trying to open.
2670
+ */
2671
+ WEB_CHAT_LOADED = 'webChatLoaded',
2672
+
2673
+ /**
2674
+ * Indicates the user clicked on our built-in launcher button that opened either a tour or the main window.
2675
+ */
2676
+ LAUNCHER_CLICKED = 'launcherClicked',
2677
+
2678
+ /**
2679
+ * Indicates the view is trying to change after loading session history.
2680
+ */
2681
+ SESSION_HISTORY = 'sessionHistory',
2682
+
2683
+ /**
2684
+ * Indicates the main window was opened by a call to {@link ChatInstance.openWindow} or
2685
+ * {@link ChatInstance.toggleOpen}.
2686
+ */
2687
+ CALLED_OPEN_WINDOW = 'calledOpenWindow',
2688
+
2689
+ /**
2690
+ * Indicates the main window was opened because a link ID was found that started a specific conversation.
2691
+ */
2692
+ LINK_ID = 'linkID',
2693
+
2694
+ /**
2695
+ * Indicates the main window was opened from a tour.
2696
+ */
2697
+ TOUR_OPENED_OTHER_VIEW = 'tourOpenedOtherView',
2698
+
2699
+ /**
2700
+ * Indicates the {@link ChatInstance.restartConversation} method was used while a tour was visible.
2701
+ */
2702
+ CALLED_RESTART_CONVERSATION = 'calledRestartConversation',
2703
+
2704
+ /**
2705
+ * Indicates the main window is being opened as a result of a channel transfer.
2706
+ */
2707
+ CHANNEL_TRANSFER = 'channelTransfer',
2708
+
2709
+ /**
2710
+ * Indicates the user clicked on our built-in minimize button that closed to either the launcher or a tour.
2711
+ */
2712
+ MAIN_WINDOW_MINIMIZED = 'mainWindowMinimized',
2713
+
2714
+ /**
2715
+ * Indicates the main window was closed by a call to {@link ChatInstance.closeWindow} or
2716
+ * {@link ChatInstance.toggleOpen}.
2717
+ */
2718
+ CALLED_CLOSE_WINDOW = 'calledCloseWindow',
2719
+
2720
+ /**
2721
+ * Indicates a tour was started by the start tour button in the main window.
2722
+ */
2723
+ TOUR_CARD_STARTED_TOUR = 'tourCardStartedTour',
2724
+
2725
+ /**
2726
+ * Indicates a tour was resumed by the resume button in the main window.
2727
+ */
2728
+ TOUR_CARD_RESUMED_TOUR = 'tourCardResumedTour',
2729
+
2730
+ /**
2731
+ * Indicates a tour was restarted by the restart button in the main window.
2732
+ */
2733
+ TOUR_CARD_RESTARTED_TOUR = 'tourCardRestartedTour',
2734
+
2735
+ /**
2736
+ * Indicates a tour was started by the {@link startTour} instance method.
2737
+ */
2738
+ CALLED_START_TOUR = 'calledStartTour',
2739
+
2740
+ /**
2741
+ * Indicates a tour was started by a tour response type that included the 'skip_card' flag.
2742
+ */
2743
+ TOUR_SKIP_CARD = 'tourSkipCard',
2744
+
2745
+ /**
2746
+ * Indicates the user clicked the close and restart button that minimized to the launcher.
2747
+ */
2748
+ MAIN_WINDOW_CLOSED_AND_RESTARTED = 'mainWindowClosedAndRestarted',
2749
+
2750
+ /**
2751
+ * Indicates the user clicked on the minimize button within the tour to close to the launcher.
2752
+ */
2753
+ TOUR_MINIMIZED = 'tourMinimized',
2754
+
2755
+ /**
2756
+ * Indicates the close button was used to close a tour.
2757
+ */
2758
+ TOUR_CLOSED = 'tourClosed',
2759
+
2760
+ /**
2761
+ * Indicates the done button was used to close a tour.
2762
+ */
2763
+ TOUR_DONE = 'tourDone',
2764
+
2765
+ /**
2766
+ * Indicates the view was changed by a call to {@link ChatInstance.changeView}.
2767
+ */
2768
+ CALLED_CHANGE_VIEW = 'calledChangeView',
2769
+
2770
+ /**
2771
+ * Indicates the {@link ChatInstance.tours.endTour} method was used to close a tour.
2772
+ */
2773
+ CALLED_END_TOUR = 'calledEndTour',
2774
+ }
2775
+
2776
+ /**
2777
+ * The different sources that can cause a send event to occur.
2778
+ */
2779
+ declare enum MessageSendSource {
2780
+ /**
2781
+ * The user has entered a value from the main input on the message list.
2782
+ */
2783
+ MESSAGE_INPUT = 'messageInput',
2784
+
2785
+ /**
2786
+ * The user has entered a value from the input on the home screen.
2787
+ */
2788
+ HOME_SCREEN_INPUT = 'homeScreenInput',
2789
+
2790
+ /**
2791
+ * The user clicked a button from an option response.
2792
+ */
2793
+ OPTION_BUTTON = 'optionButton',
2794
+
2795
+ /**
2796
+ * The user selected a value from a dropdown for an option response.
2797
+ */
2798
+ OPTION_DROP_DOWN = 'optionDropDown',
2799
+
2800
+ /**
2801
+ * The automatic follow-up message that occurs after a skip-user-input response.
2802
+ */
2803
+ SKIP_USER_INPUT = 'skipUserInput',
2804
+
2805
+ /**
2806
+ * The message was sent as an automatic re-send when web chat is loaded. This occurs when web chat sees that the
2807
+ * last message request did not receive a response.
2808
+ */
2809
+ HYDRATE_RESEND = 'hydrateResend',
2810
+
2811
+ /**
2812
+ * The message was sent as an event history update.
2813
+ */
2814
+ HISTORY_UPDATE = 'historyUpdate',
2815
+
2816
+ /**
2817
+ * An external call to the public "instance.send" method was made.
2818
+ */
2819
+ INSTANCE_SEND = 'instanceSend',
2820
+
2821
+ /**
2822
+ * The user chose a value from the date picker.
2823
+ */
2824
+ DATE_PICKER = 'datePicker',
2825
+
2826
+ /**
2827
+ * The user clicked a post back button from a button response.
2828
+ */
2829
+ POST_BACK_BUTTON = 'postBackButton',
2830
+
2831
+ /**
2832
+ * A link ID was detected on the page and an automatic "welcome request" was sent.
2833
+ */
2834
+ LINK_ID = 'linkID',
2835
+
2836
+ /**
2837
+ * The user clicked a starter from the home screen.
2838
+ */
2839
+ HOME_SCREEN_STARTER = 'homeScreenStarter',
2840
+
2841
+ /**
2842
+ * The user made a choice from a disambiguation response.
2843
+ */
2844
+ DISAMBIGUATION = 'disambiguation',
2845
+
2846
+ /**
2847
+ * The startTour method has called.
2848
+ */
2849
+ START_TOUR_METHOD = 'startTourMethod',
2850
+
2851
+ /**
2852
+ * A default request for the welcome message was made.
2853
+ */
2854
+ WELCOME_REQUEST = 'welcomeRequest',
2855
+
2856
+ /**
2857
+ * This is used for message events.
2858
+ */
2859
+ EVENT = 'event',
2860
+
2861
+ /**
2862
+ * Some other source.
2863
+ */
2864
+ OTHER = 'other',
2865
+
2866
+ /**
2867
+ * The user chose an alternate response message from the suggestions menu.
2868
+ */
2869
+ SUGGESTIONS_MESSAGE = 'suggestionsMessage',
2870
+
2871
+ /**
2872
+ * The user chose a home screen starter from the suggestions menu.
2873
+ */
2874
+ SUGGESTIONS_STARTER = 'suggestionsStarter',
2875
+
2876
+ /**
2877
+ * The user chose the contact option from the suggestions menu.
2878
+ */
2879
+ SUGGESTIONS_CONTACT = 'suggestionsContact',
2880
+
2881
+ /**
2882
+ * A 3rd strike occurred and an automatic suggestions contact message was sent.
2883
+ */
2884
+ SUGGESTIONS_3RD_STRIKE = 'suggestions3rdStrike',
2885
+ }
2886
+
2887
+ /**
2888
+ * The possible reasons why a tour could be started. Purposefully not firing this event when the restart button is
2889
+ * clicked.
2890
+ */
2891
+ declare enum TourStartReason {
2892
+ /**
2893
+ * If the {@link startTour} instance method was used to start the tour.
2894
+ */
2895
+ START_TOUR_METHOD = 'start_tour_method',
2896
+
2897
+ /**
2898
+ * If the skip_card property was true within the tour json.
2899
+ */
2900
+ SKIP_CARD = 'skip_card',
2901
+
2902
+ /**
2903
+ * If the user clicked the tour card's start button.
2904
+ */
2905
+ START_TOUR_CLICKED = 'start_tour_clicked',
2906
+ }
2907
+
2908
+ /**
2909
+ * The possible reasons why a tour could have ended. Purposefully not firing this event when the close button is clicked
2910
+ * or the {@link endTour} instance method is used.
2911
+ */
2912
+ declare enum TourEndReason {
2913
+ /**
2914
+ * If the user clicked the done button.
2915
+ */
2916
+ DONE_CLICKED = 'done_clicked',
2917
+ }
2918
+ interface BusEvent {
2919
+ /**
2920
+ * The type of this event.
2921
+ */
2922
+ type: BusEventType;
2923
+ }
2924
+
2925
+ /**
2926
+ * This event is for the
2927
+ */
2928
+ interface BusEventClosePanelButtonClicked extends BusEvent {
2929
+ type: BusEventType.CLOSE_PANEL_BUTTON_TOGGLED;
2930
+ }
2931
+ interface BusEventPreReceive extends BusEvent {
2932
+ type: BusEventType.PRE_RECEIVE;
2933
+ data: MessageResponse;
2934
+
2935
+ /**
2936
+ * Defaulted to true. If true then changes made to the message object in pre:receive will be saved in the session
2937
+ * history for the length of the session. If the changes are saved then the message will look the same to the end user
2938
+ * before and after page change/reload as long as the session history feature is enabled. If updateHistory is false
2939
+ * the changes will not be saved in the history. While the message will still initially update successfully if this is
2940
+ * false, the changes won't be preserved and the end user will see the original message (that was received before the
2941
+ * pre:receive changes) when a page change/reload occurs.
2942
+ */
2943
+ updateHistory: boolean;
2944
+ }
2945
+ interface BusEventReceive extends BusEvent {
2946
+ type: BusEventType.RECEIVE;
2947
+ data: MessageResponse;
2948
+ }
2949
+ interface BusEventPreSend extends BusEvent {
2950
+ type: BusEventType.PRE_SEND;
2951
+ data: MessageRequest;
2952
+
2953
+ /**
2954
+ * The source of the message being sent.
2955
+ */
2956
+ source: MessageSendSource;
2957
+
2958
+ /**
2959
+ * An optional payload object that was provided as part of the "onBeforeSend" callback from an input field.
2960
+ */
2961
+ beforeSendPayload?: unknown;
2962
+ }
2963
+ interface BusEventSend extends BusEvent {
2964
+ type: BusEventType.SEND;
2965
+ data: MessageRequest;
2966
+
2967
+ /**
2968
+ * The source of the message being sent.
2969
+ */
2970
+ source: MessageSendSource;
2971
+
2972
+ /**
2973
+ * An optional payload object that was provided as part of the "onBeforeSend" callback from an input field.
2974
+ */
2975
+ beforeSendPayload?: unknown;
2976
+ }
2977
+ interface BusEventAgentPreReceive extends BusEvent {
2978
+ type: BusEventType.AGENT_PRE_RECEIVE;
2979
+ data: MessageResponse;
2980
+ agentProfile?: AgentProfile;
2981
+ }
2982
+ interface BusEventAgentReceive extends BusEvent {
2983
+ type: BusEventType.AGENT_RECEIVE;
2984
+ data: MessageResponse;
2985
+ agentProfile?: AgentProfile;
2986
+ }
2987
+ interface BusEventAgentPreSend extends BusEvent {
2988
+ type: BusEventType.AGENT_PRE_SEND;
2989
+ data: MessageRequest;
2990
+ files: FileUpload[];
2991
+ }
2992
+ interface BusEventAgentSend extends BusEvent {
2993
+ type: BusEventType.AGENT_SEND;
2994
+ data: MessageRequest;
2995
+ files: FileUpload[];
2996
+ }
2997
+ interface BusEventViewPreChange extends BusEvent {
2998
+ type: BusEventType.VIEW_PRE_CHANGE;
2999
+
3000
+ /**
3001
+ * The reason the view is changing.
3002
+ */
3003
+ reason: ViewChangeReason;
3004
+
3005
+ /**
3006
+ * The previous view state before this event.
3007
+ */
3008
+ oldViewState: ViewState;
3009
+
3010
+ /**
3011
+ * The new view state that web chat is going to switch to. This new state can be changed by the event handler.
3012
+ */
3013
+ newViewState: ViewState;
3014
+
3015
+ /**
3016
+ * This is used by the event handler to indicate that the view change should be cancelled and web chat's view should
3017
+ * not be changed.
3018
+ */
3019
+ cancelViewChange: boolean;
3020
+ }
3021
+ interface BusEventViewChange extends BusEvent {
3022
+ type: BusEventType.VIEW_CHANGE;
3023
+
3024
+ /**
3025
+ * The reason the view is changing.
3026
+ */
3027
+ reason: ViewChangeReason;
3028
+
3029
+ /**
3030
+ * The previous view state from before the view:pre:change event.
3031
+ */
3032
+ oldViewState: ViewState;
3033
+
3034
+ /**
3035
+ * The new view state that web chat has switched to. This new state can be changed by the event handler.
3036
+ */
3037
+ newViewState: ViewState;
3038
+
3039
+ /**
3040
+ * This is used by the event handler to indicate that the view change should be cancelled and web chat's view should
3041
+ * not be changed. Since the view has already changed when this event is fired, this property will cause the view to
3042
+ * change back. Note that the view change events are *not* fired when the view changes back.
3043
+ */
3044
+ cancelViewChange: boolean;
3045
+ }
3046
+ interface BusEventReset extends BusEvent {
3047
+ type: BusEventType.RESTART_CONVERSATION;
3048
+ }
3049
+ interface BusEventChatReady extends BusEvent {
3050
+ type: BusEventType.CHAT_READY;
3051
+ }
3052
+ interface BusEventPreReset extends BusEvent {
3053
+ type: BusEventType.PRE_RESTART_CONVERSATION;
3054
+ }
3055
+
3056
+ /**
3057
+ * A list of custom event types that can trigger a custom event.
3058
+ */
3059
+ declare enum CustomEventType {
3060
+ BUTTON_ITEM_CLICKED = 'buttonItemClicked',
3061
+ }
3062
+
3063
+ /**
3064
+ * This describes a custom event that can be authored with the button response type of type "option". When clicked,
3065
+ * this event will fire and provide information authored in the custom event.
3066
+ */
3067
+ interface BusEventMessageItemCustom extends BusEvent {
3068
+ type: BusEventType.MESSAGE_ITEM_CUSTOM;
3069
+
3070
+ /**
3071
+ * The event type that triggered the custom event.
3072
+ */
3073
+ customEventType: CustomEventType;
3074
+
3075
+ /**
3076
+ * The button item that triggered this custom event.
3077
+ */
3078
+ messageItem: ButtonItem;
3079
+
3080
+ /**
3081
+ * The full message response that contained the button item that triggered this custom event.
3082
+ */
3083
+ fullMessage: MessageResponse;
3084
+ }
3085
+ interface BusEventUserDefinedResponse extends BusEvent {
3086
+ type: BusEventType.USER_DEFINED_RESPONSE;
3087
+ data: {
3088
+ /**
3089
+ * The individual message item that is being displayed in this custom response.
3090
+ */
3091
+ message: GenericItem;
3092
+
3093
+ /**
3094
+ * The full message (response or request) that contains the message item.
3095
+ */
3096
+ fullMessage: Message;
3097
+
3098
+ /**
3099
+ * The element to which customers can add the custom code to render for the custom response.
3100
+ */
3101
+ element?: HTMLElement;
3102
+
3103
+ /**
3104
+ * An assignable property that the event listener can assign that will indicate if the response is supposed to
3105
+ * be full width.
3106
+ */
3107
+ fullWidth?: boolean;
3108
+ };
3109
+ }
3110
+ interface BusEventChunkUserDefinedResponse extends BusEvent {
3111
+ type: BusEventType.CHUNK_USER_DEFINED_RESPONSE;
3112
+ data: {
3113
+ /**
3114
+ * The individual message item that is being displayed in this custom response.
3115
+ */
3116
+ messageItem: DeepPartial<GenericItem>;
3117
+
3118
+ /**
3119
+ * The full chunk that contained the user defined response.
3120
+ */
3121
+ chunk: PartialOrCompleteItemChunk;
3122
+
3123
+ /**
3124
+ * The element to which customers can add the custom code to render for the custom response.
3125
+ */
3126
+ element?: HTMLElement;
3127
+
3128
+ /**
3129
+ * An assignable property that the event listener can assign that will indicate if the response is supposed to
3130
+ * be full width.
3131
+ */
3132
+ fullWidth?: boolean;
3133
+ };
3134
+ }
3135
+
3136
+ /**
3137
+ * The event is fired whenever the widget begins processing a list of messages that have been loaded from history.
3138
+ * This event may be fired not only when the history is first loaded but it may be fired later during the life of
3139
+ * the widget if additional messages are loaded from history.
3140
+ *
3141
+ * This event is fired when this process begins. This is fired before all the "pre:receive" and "receive" events are
3142
+ * fired which means that the messages here are the original messages before any possible modifications by the event
3143
+ * handlers.
3144
+ */
3145
+ interface BusEventHistoryBegin extends BusEvent {
3146
+ /**
3147
+ * The discriminating type of this event.
3148
+ */
3149
+ type: BusEventType.HISTORY_BEGIN;
3150
+
3151
+ /**
3152
+ * The list of all the messages that are being loaded by this history event.
3153
+ */
3154
+ messages: Message[];
3155
+ }
3156
+
3157
+ /**
3158
+ * The event is fired whenever the widget begins processing a list of messages that have been loaded from history.
3159
+ * This event may be fired not only when the history is first loaded but it may be fired later during the life of
3160
+ * the widget if additional messages are loaded from history.
3161
+ *
3162
+ * This event is fired when this process ends. This is fired after all the "pre:receive" and "receive" events are
3163
+ * fired which means that the messages here are the potentially modified messages after any possible modifications
3164
+ * by the event handlers.
3165
+ */
3166
+ interface BusEventHistoryEnd extends BusEvent {
3167
+ /**
3168
+ * The discriminating type of this event.
3169
+ */
3170
+ type: BusEventType.HISTORY_END;
3171
+
3172
+ /**
3173
+ * The list of all the messages that were loaded by this history event.
3174
+ */
3175
+ messages: Message[];
3176
+ }
3177
+ interface BusEventCustomPanelPreOpen extends BusEvent {
3178
+ type: BusEventType.CUSTOM_PANEL_PRE_OPEN;
3179
+ }
3180
+ interface BusEventCustomPanelOpen extends BusEvent {
3181
+ type: BusEventType.CUSTOM_PANEL_OPEN;
3182
+ }
3183
+ interface BusEventCustomPanelPreClose extends BusEvent {
3184
+ type: BusEventType.CUSTOM_PANEL_PRE_CLOSE;
3185
+ }
3186
+ interface BusEventCustomPanelClose extends BusEvent {
3187
+ type: BusEventType.CUSTOM_PANEL_CLOSE;
3188
+ }
3189
+
3190
+ /**
3191
+ * Fired when a tour is started. The tour could be started upon receipt of a tour message with skip_card true, when a
3192
+ * developer used the {@link startTour} instance method, or when the start tour card is clicked by the user.
3193
+ * Purposefully not firing this event when the restart button is clicked.
3194
+ */
3195
+ interface BusEventTourStart extends BusEvent {
3196
+ type: BusEventType.TOUR_START;
3197
+
3198
+ /**
3199
+ * The reason for the tour starting.
3200
+ */
3201
+ reason: TourStartReason;
3202
+ }
3203
+
3204
+ /**
3205
+ * Fired when the tour is ended by clicking the done button at the end of the tour. Purposefully not firing this event
3206
+ * when the close button is clicked or the {@link endTour} instance method is used.
3207
+ */
3208
+ interface BusEventTourEnd extends BusEvent {
3209
+ type: BusEventType.TOUR_END;
3210
+
3211
+ /**
3212
+ * The reason for the tour ending.
3213
+ */
3214
+ reason: TourEndReason;
3215
+ }
3216
+
3217
+ /**
3218
+ * Fired when a new step is shown to the user. This could be caused by a tour starting/restarting, the user clicking the
3219
+ * next or previous buttons within the tour, or by a developer calling the {@link goToNextStep} or {@link goToStep}
3220
+ * instance methods. Purposefully not firing this event when a tour is resumed.
3221
+ */
3222
+ interface BusEventTourStep extends BusEvent {
3223
+ type: BusEventType.TOUR_STEP;
3224
+
3225
+ /**
3226
+ * The details of the new step item.
3227
+ */
3228
+ step: TourStepGenericItem;
3229
+ }
3230
+
3231
+ /**
3232
+ * This event is fired before the user is connected to a service desk. This occurs as soon as the user clicks the
3233
+ * "Request agent" button and before any attempt is made to communicate with the service desk.
3234
+ */
3235
+ interface BusEventAgentPreStartChat<TPayloadType = unknown> extends BusEvent {
3236
+ /**
3237
+ * The type of the event.
3238
+ */
3239
+ type: BusEventType.AGENT_PRE_START_CHAT;
3240
+
3241
+ /**
3242
+ * The message that was used to trigger the connection to the agent.
3243
+ */
3244
+ message: MessageResponse;
3245
+
3246
+ /**
3247
+ * This flag can be set by a listener to indicate that the connection process should be cancelled.
3248
+ */
3249
+ cancelStartChat?: boolean;
3250
+
3251
+ /**
3252
+ * Some arbitrary payload of data that will be passed to the service desk when a chat is started.
3253
+ */
3254
+ preStartChatPayload?: TPayloadType;
3255
+
3256
+ /**
3257
+ * The key that can be provided for the agent app configuration to load an agent app version of web chat.
3258
+ */
3259
+ sessionHistoryKey: string;
3260
+ }
3261
+
3262
+ /**
3263
+ * This event is fired before a chat with an agent is ended. This occurs after the user has selected "Yes" from the
3264
+ * confirmation modal but it can also be fired if the chat is ended by the agent.
3265
+ */
3266
+ interface BusEventAgentPreEndChat<TPayloadType = unknown> extends BusEvent {
3267
+ /**
3268
+ * The type of the event.
3269
+ */
3270
+ type: BusEventType.AGENT_PRE_END_CHAT;
3271
+
3272
+ /**
3273
+ * Indicates if the chat was ended by the agent.
3274
+ */
3275
+ endedByAgent: boolean;
3276
+
3277
+ /**
3278
+ * An arbitrary payload object that a listener may set. This payload will be passed to the service desk
3279
+ * {@link ServiceDesk#endChat} function.
3280
+ */
3281
+ preEndChatPayload: TPayloadType;
3282
+
3283
+ /**
3284
+ * This value may be set by a listener to indicate that the process of ending the chat should be cancelled.
3285
+ */
3286
+ cancelEndChat: boolean;
3287
+ }
3288
+
3289
+ /**
3290
+ * This event is fired after a chat with an agent has ended. This is fired after {@link AGENT_PRE_END_CHAT} but
3291
+ * can be fired both from the user leaving the chat or the agent ending the chat.
3292
+ */
3293
+ interface BusEventAgentEndChat extends BusEvent {
3294
+ /**
3295
+ * The type of the event.
3296
+ */
3297
+ type: BusEventType.AGENT_END_CHAT;
3298
+
3299
+ /**
3300
+ * Indicates if the chat was ended by the agent.
3301
+ */
3302
+ endedByAgent: boolean;
3303
+
3304
+ /**
3305
+ * Indicates if the chat was ended because the request for an agent was cancelled or an error occurred while
3306
+ * starting the chat. This means the start never fully started.
3307
+ */
3308
+ requestCancelled: boolean;
3309
+ }
3310
+
3311
+ /**
3312
+ * This event is fired after web chat calls "areAnyAgentsOnline" for a service desk. It will report the value returned
3313
+ * from that call. This is particularly useful if some custom code wants to take action if no agents are online.
3314
+ */
3315
+ interface BusEventAgentAreAnyAgentsOnline extends BusEvent {
3316
+ /**
3317
+ * The type of the event.
3318
+ */
3319
+ type: BusEventType.AGENT_ARE_ANY_AGENTS_ONLINE;
3320
+
3321
+ /**
3322
+ * The result that was returned from "areAnyAgentsOnline". If an error occurred, this will be
3323
+ * {@link AgentsOnlineStatus.OFFLINE}.
3324
+ */
3325
+ areAnyAgentsOnline: AgentsOnlineStatus;
3326
+ }
3327
+
3328
+ /**
3329
+ * This event is fired before a message from a live agent or the user (to an agent) is added to session history. It
3330
+ * gives the customer the opportunity to filter out PII from the messages so they are not stored by IBM watsonx
3331
+ * Assistant.
3332
+ */
3333
+ interface BusEventAgentPreSessionHistory extends BusEvent {
3334
+ /**
3335
+ * The type of the event.
3336
+ */
3337
+ type: BusEventType.AGENT_PRE_SESSION_HISTORY;
3338
+
3339
+ /**
3340
+ * The message that is to be saved in session history.
3341
+ */
3342
+ message: MessageRequest | MessageResponse;
3343
+ }
3344
+ interface BusEventGenesysMessengerAuthProvider extends BusEvent {
3345
+ /**
3346
+ * The type of the event.
3347
+ */
3348
+ type: BusEventType.GENESYS_MESSENGER_AUTH_PROVIDER;
3349
+
3350
+ /**
3351
+ * The AuthProvider plugin that was created.
3352
+ */
3353
+ authProvider: unknown;
3354
+ }
3355
+ interface BusEventGenesysMessengerGetAuthCode extends BusEvent {
3356
+ /**
3357
+ * The type of the event.
3358
+ */
3359
+ type: BusEventType.GENESYS_MESSENGER_GET_AUTH_CODE;
3360
+
3361
+ /**
3362
+ * The event provided by Genesys.
3363
+ */
3364
+ genesysEvent: unknown;
3365
+ }
3366
+ interface BusEventGenesysMessengerAuthError extends BusEvent {
3367
+ /**
3368
+ * The type of the event.
3369
+ */
3370
+ type: BusEventType.GENESYS_MESSENGER_AUTH_ERROR;
3371
+
3372
+ /**
3373
+ * The error provided by Genesys.
3374
+ */
3375
+ genesysError: unknown;
3376
+ }
3377
+ interface BusEventGenesysMessengerLoggedOut extends BusEvent {
3378
+ /**
3379
+ * The type of the event.
3380
+ */
3381
+ type: BusEventType.GENESYS_MESSENGER_LOGGED_OUT;
3382
+
3383
+ /**
3384
+ * The event provided by Genesys.
3385
+ */
3386
+ genesysEvent: unknown;
3387
+ }
3388
+ interface BusEventGenesysMessengerReauthenticate extends BusEvent {
3389
+ /**
3390
+ * The type of the event.
3391
+ */
3392
+ type: BusEventType.GENESYS_MESSENGER_REAUTHENTICATE;
3393
+
3394
+ /**
3395
+ * The event provided by Genesys.
3396
+ */
3397
+ genesysEvent: unknown;
3398
+ }
3399
+ interface BusEventNiceDFOGetAuthCode extends BusEvent {
3400
+ /**
3401
+ * The type of the event.
3402
+ */
3403
+ type: BusEventType.NICE_DFO_GET_AUTH_CODE;
3404
+
3405
+ /**
3406
+ * The authentication code set by the event handler. This code will be provided to Nice.
3407
+ */
3408
+ authCode: string;
3409
+
3410
+ /**
3411
+ * The visitor ID code set by the event handler. This code will be provided to Nice.
3412
+ */
3413
+ visitorID?: string;
3414
+ }
3415
+
3416
+ /**
3417
+ * Messaging actions for a chat instance.
3418
+ */
3419
+ interface ChatInstanceMessaging {
3420
+ /**
3421
+ * Instructs the widget to process the given message as an incoming message received from the assistant. This will
3422
+ * fire a "pre:receive" event immediately and a "receive" event after the event has been processed by the widget.
3423
+ *
3424
+ * @param message A v2 message API Response object.
3425
+ */
3426
+ addMessage: (message: MessageResponse) => Promise<void>;
3427
+
3428
+ /**
3429
+ * Adds a streaming message chunk to the chat widget.
3430
+ */
3431
+ addMessageChunk: (chunk: StreamChunk) => Promise<void>;
3432
+
3433
+ /**
3434
+ * Removes the messages with the given IDs from the chat view.
3435
+ */
3436
+ removeMessages: (messageIDs: string[]) => Promise<void>;
3437
+
3438
+ /**
3439
+ * Clears the current conversation. This will trigger a restart of the conversation but will not start a new
3440
+ * conversation (hydration).
3441
+ */
3442
+ clearConversation: () => Promise<void>;
3443
+
3444
+ /**
3445
+ * Inserts the given messages into the chat window as part of the chat history. This will fire the history:begin
3446
+ * and history:end events.
3447
+ */
3448
+ insertHistory: (messages: HistoryItem[]) => Promise<void>;
3449
+ }
3450
+ interface CustomSendMessageOptions {
3451
+ /**
3452
+ * A signal to let customSendMessage to cancel a request if it has exceeded web chat's timeout.
3453
+ */
3454
+ signal: AbortSignal;
3455
+ }
3456
+
3457
+ /**
3458
+ * This file contains the definition for the public application configuration operations that are provided by the
3459
+ * host page.
3460
+ */
3461
+ interface PublicConfig {
3462
+ /**
3463
+ * The callback function that is called by the loadWatsonAssistantChat script once it is loaded. This is optional;
3464
+ * to use web chat without this requires using the "window.loadWatsonAssistantChat" function instead.
3465
+ */
3466
+ onLoad?: (instance: ChatInstance) => void;
3467
+
3468
+ /**
3469
+ * This is a one-off listener for errors. This value may be provided in the initial page config as a hook for
3470
+ * customers to listen for errors. We use this instead of a normal event bus handler because this function can be
3471
+ * defined and called before the event bus has been created which allows it to be used in loadWatsonAssistantChat.
3472
+ */
3473
+ onError?: (data: OnErrorData) => void;
3474
+
3475
+ /**
3476
+ * An optional element the page can use as a custom in to which to render the widget.
3477
+ */
3478
+ element?: Element;
3479
+
3480
+ /**
3481
+ * Render the chat launcher element used to open and close the chat window. If you elect to not show our built in
3482
+ * chat launcher, you will be responsible for firing the launcher:toggle, launcher:open or launcher:close events
3483
+ * from your own chat launcher. Or, you can use options.openChatByDefault to just have the chat interface be open
3484
+ * at initialization.
3485
+ */
3486
+ showLauncher?: boolean;
3487
+
3488
+ /**
3489
+ * By default, the chat window will be rendered in a "closed" state.
3490
+ */
3491
+ openChatByDefault?: boolean;
3492
+
3493
+ /**
3494
+ * Beta version of disclaimer screen. No tooling for this.
3495
+ */
3496
+ disclaimer?: DisclaimerPublicConfig;
3497
+
3498
+ /**
3499
+ * This value is only used when a custom element is being used to render the widget. By default, a number of
3500
+ * enhancements to the widget are activated on mobile devices which can interfere with a custom element. This
3501
+ * value can be used to disable those enhancements while using a custom element.
3502
+ */
3503
+ disableCustomElementMobileEnhancements?: boolean;
3504
+
3505
+ /**
3506
+ * Add a bunch of noisy console.log messages!
3507
+ */
3508
+ debug?: boolean;
3509
+ themeConfig?: ThemeConfig;
3510
+
3511
+ /**
3512
+ * A nonce value to set on restricted elements to allow them to satisfy a Content-Security-Policy. If a website is
3513
+ * using a Content-Security-Policy along with a nonce to whitelist which style and script elements are allowed,
3514
+ * the site can provide this nonce value here which will then be added to the dynamic script and style tags
3515
+ * generated by the widget which will allow them to run.
3516
+ */
3517
+ cspNonce?: string;
3518
+
3519
+ /**
3520
+ * This is a factory for producing custom implementations of service desks. If this value is set, then this will
3521
+ * be used to create an instance of a {@link ServiceDesk} when the user attempts to connect to an agent.
3522
+ */
3523
+ serviceDeskFactory?: (parameters: ServiceDeskFactoryParameters) => Promise<ServiceDesk>;
3524
+
3525
+ /**
3526
+ * Agent app is a mode of web chat used in service desk UIs to show the chat history to the agent. Setting this flag
3527
+ * will adjust the way web chat renders and behaves, e.g. with no input field, opens by default, etc
3528
+ */
3529
+ agentAppConfig?: AgentAppConfig;
3530
+
3531
+ /**
3532
+ * Any public config to apply to service desks.
3533
+ */
3534
+ serviceDesk?: ServiceDeskPublicConfig;
3535
+
3536
+ /**
3537
+ * If the web chat should grab focus if the web chat is open on page load. This applies to session history open
3538
+ * states as well as openByChatByDefault. This should be set to false if the web chat is embedded in the tooling, for
3539
+ * instance.
3540
+ */
3541
+ shouldTakeFocusIfOpensAutomatically?: boolean;
3542
+
3543
+ /**
3544
+ * An optional namespace that can be added to the web chat that must be 30 characters or under. This value is
3545
+ * intended to enable multiple instances of the web chat to be used on the same page. The namespace for this web
3546
+ * chat. This value is used to generate a value to append to anything unique (id, session keys, etc) to allow
3547
+ * multiple web chats on the same page.
3548
+ *
3549
+ * Note: this value is used in the aria region label for the web chat. This means this value will be read out loud
3550
+ * by users using a screen reader.
3551
+ */
3552
+ namespace?: string;
3553
+
3554
+ /**
3555
+ * Indicates if a focus trap should be enabled when the web chat is open.
3556
+ */
3557
+ enableFocusTrap?: boolean;
3558
+
3559
+ /**
3560
+ * The configuration that defines how web chat responds to link page requests (where there's a link reference in the
3561
+ * URL).
3562
+ */
3563
+ pageLinkConfig?: PageLinkConfig;
3564
+
3565
+ /**
3566
+ * If true, disables functionality in web chat that changes the window title.
3567
+ */
3568
+ disableWindowTitleChanges?: boolean;
3569
+
3570
+ /**
3571
+ * Indicates if web chat should sanitize HTML from a user or from the assistant.
3572
+ */
3573
+ shouldSanitizeHTML?: boolean;
3574
+
3575
+ /**
3576
+ * Indicates if the internal web chat PDF viewer should be disabled. If true, web chat will present links to PDFs
3577
+ * as actual links that will open in the user's web browser using the browser's native viewer instead of the web chat
3578
+ * viewer.
3579
+ */
3580
+ disablePDFViewer?: boolean;
3581
+
3582
+ /**
3583
+ * A config object to modify tours.
3584
+ */
3585
+ tourConfig?: {
3586
+ /**
3587
+ * Indicates if the minimize button should be hidden.
3588
+ */
3589
+ hideMinimizeButton?: boolean;
3590
+
3591
+ /**
3592
+ * Indicates if the chat button should be hidden.
3593
+ */
3594
+ hideChatButton?: boolean;
3595
+ };
3596
+
3597
+ /**
3598
+ * Configuration to control how streaming works.
3599
+ */
3600
+ streaming?: {
3601
+ /**
3602
+ * Indicates if streaming is disabled or not. Streaming is disabled by default but can be enabled through this
3603
+ * configuration or tooling. When streaming is enabled, the assistant may return a text/event-stream response for a
3604
+ * message request.
3605
+ */
3606
+ disabled?: boolean;
3607
+ };
3608
+
3609
+ /**
3610
+ * Extra config for controlling the behavior of the header.
3611
+ */
3612
+ headerConfig?: HeaderConfig;
3613
+
3614
+ /**
3615
+ * The config object for changing web chat's layout.
3616
+ */
3617
+ layout?: LayoutConfig;
3618
+
3619
+ /**
3620
+ * Config options for controlling messaging.
3621
+ */
3622
+ messaging?: PublicConfigMessaging;
3623
+ }
3624
+ declare enum MinimizeButtonIconType {
3625
+ /**
3626
+ * This shows an "X" icon.
3627
+ */
3628
+ CLOSE = 'close',
3629
+
3630
+ /**
3631
+ * This shows a "-" icon.
3632
+ */
3633
+ MINIMIZE = 'minimize',
3634
+
3635
+ /**
3636
+ * This shows an icon that indicates that the web chat can be collapsed into a side panel.
3637
+ */
3638
+ SIDE_PANEL_LEFT = 'side-panel-left',
3639
+
3640
+ /**
3641
+ * This shows an icon that indicates that the web chat can be collapsed into a side panel.
3642
+ */
3643
+ SIDE_PANEL_RIGHT = 'side-panel-right',
3644
+ }
3645
+ interface HeaderConfig {
3646
+ /**
3647
+ * Indicates the icon to use for the close button in the header.
3648
+ */
3649
+ minimizeButtonIconType?: MinimizeButtonIconType;
3650
+
3651
+ /**
3652
+ * Hide the ability to minimize the web chat.
3653
+ */
3654
+ hideMinimizeButton?: boolean;
3655
+
3656
+ /**
3657
+ * If true, shows the restart conversation button in the header of home screen and main chat.
3658
+ */
3659
+ showRestartButton?: boolean;
3660
+
3661
+ /**
3662
+ * Indicates if the close and restart (X) button should be rendered.
3663
+ *
3664
+ */
3665
+ showCloseAndRestartButton?: boolean;
3666
+ }
3667
+
3668
+ /**
3669
+ * When web chat is being used as the view for the human agent.
3670
+ */
3671
+ interface AgentAppConfig {
3672
+ /**
3673
+ * Sets chat to be in "agent app" mode. This means no user input is allowed and an "auth_code" will be included in the
3674
+ * request to fetch the conversation history.
3675
+ */
3676
+ is_on: boolean;
3677
+
3678
+ /**
3679
+ * The auth_code passed from the connect_to_agent response type used to authenticate the session. This can be used to
3680
+ * embed a web chat into an agent application as an iframe and load the conversation history for the agent to see.
3681
+ */
3682
+ auth_code?: string;
3683
+ }
3684
+
3685
+ /**
3686
+ * The configuration that defines how web chat responds to link page requests (where there's a link reference in the
3687
+ * URL).
3688
+ */
3689
+ interface PageLinkConfig {
3690
+ /**
3691
+ * The configuration for all the link IDs. The keys are the link IDs and the values are the configurations
3692
+ * specific to each link ID.
3693
+ */
3694
+ linkIDs: Record<string, PageLinkIDConfig>;
3695
+ }
3696
+
3697
+ /**
3698
+ * The link configuration for a specific link ID.
3699
+ */
3700
+ interface PageLinkIDConfig {
3701
+ /**
3702
+ * The text of the utterance that will be sent to the assistant when the page is loaded and the given link ID is
3703
+ * found.
3704
+ */
3705
+ text: string;
3706
+ }
3707
+ interface LayoutConfig {
3708
+ /**
3709
+ * Indicates if the web chat widget should keep its border and box-shadow.
3710
+ */
3711
+ showFrame?: boolean;
3712
+ }
3713
+
3714
+ /**
3715
+ * Config options for controlling messaging.
3716
+ */
3717
+ interface PublicConfigMessaging {
3718
+ /**
3719
+ * A callback for web chat to use to send messages to the assistant. When this is provided, this will be used as
3720
+ * an alternative for its built-in message service. Note that this is not used for human agent communication
3721
+ * (except for the event messages to update history).
3722
+ *
3723
+ * Web chat will queue up any additional user messages until the Promise from a previous call to customSendMessage
3724
+ * has resolved. This does not include event messages. If the Promise rejects, an error indicator will be
3725
+ * displayed next to the user's message.
3726
+ *
3727
+ * If the request takes longer than PublicConfigMessaging.messageTimeoutSecs than the AbortSignal will be sent.
3728
+ */
3729
+ customSendMessage?: (
3730
+ request: MessageRequest,
3731
+ requestOptions: CustomSendMessageOptions,
3732
+ instance: ChatInstance,
3733
+ ) => Promise<void> | void;
3734
+
3735
+ /**
3736
+ * This is a callback function that is used by web chat to retrieve history data for populating the web chat. If
3737
+ * this function is defined, it will be used instead of any other mechanism for fetching history.
3738
+ */
3739
+ customLoadHistory?: (instance: ChatInstance) => Promise<HistoryItem[]>;
3740
+
3741
+ /**
3742
+ * Indicates if web chat should make a request for the welcome message when a new conversation begins. If this is
3743
+ * true, then web chat will start with an empty conversation.
3744
+ */
3745
+ skipWelcome?: boolean;
3746
+
3747
+ /**
3748
+ * Changes the timeout used by the message service when making message calls. The timeout is in seconds. The
3749
+ * default is 40 seconds. After this time, an error will be shown in the client and an Abort signal will be sent
3750
+ * to customSendMessage.
3751
+ */
3752
+ messageTimeoutSecs?: number;
3753
+
3754
+ /**
3755
+ * Indicates if the context from the previous response should be copied on the next request. This is true by default.
3756
+ */
3757
+ copyPreviousContextOnRequest?: boolean;
3758
+ }
3759
+ interface DisclaimerPublicConfig {
3760
+ /**
3761
+ * If the disclaimer is turned on.
3762
+ */
3763
+ isOn: boolean;
3764
+
3765
+ /**
3766
+ * HTML content to show in disclaimer.
3767
+ */
3768
+ disclaimerHTML: string;
3769
+ }
3770
+
3771
+ /**
3772
+ * A string identifying what Carbon Theme we should base UI variables off of. Defaults to 'g10'. See
3773
+ * https://carbondesignsystem.com/guidelines/color/tokens.
3774
+ */
3775
+ declare enum CarbonTheme {
3776
+ WHITE = 'white',
3777
+ G10 = 'g10',
3778
+ G90 = 'g90',
3779
+ G100 = 'g100',
3780
+ }
3781
+
3782
+ /**
3783
+ * The types of corners web chat can have.
3784
+ */
3785
+ declare enum CornersType {
3786
+ ROUND = 'round',
3787
+ SQUARE = 'square',
3788
+ }
3789
+
3790
+ /**
3791
+ * The different categories of errors that the system can record. These values are published for end user consumption.
3792
+ */
3793
+ declare enum OnErrorType {
3794
+ /**
3795
+ * Indicates an error loading the remote init config.
3796
+ */
3797
+ INITIAL_CONFIG = 'INITIAL_CONFIG',
3798
+
3799
+ /**
3800
+ * Indicates an error loading the main config.
3801
+ */
3802
+ OPEN_CONFIG = 'OPEN_CONFIG',
3803
+
3804
+ /**
3805
+ * Indicates an error sending a message to the assistant. This error is only generated after all retries have
3806
+ * failed and the system has given up.
3807
+ */
3808
+ MESSAGE_COMMUNICATION = 'MESSAGE_COMMUNICATION',
3809
+
3810
+ /**
3811
+ * This indicates an error in one of the React components that occurs as part of rendering the UI.
3812
+ */
3813
+ RENDER = 'RENDER',
3814
+
3815
+ /**
3816
+ * This indicates an error with the identity token.
3817
+ */
3818
+ IDENTITY_TOKEN = 'IDENTITY_TOKEN',
3819
+
3820
+ /**
3821
+ * This indicates an error with the MCSP identity token.
3822
+ */
3823
+ MCSP_IDENTITY_TOKEN = 'MCSP_IDENTITY_TOKEN',
3824
+
3825
+ /**
3826
+ * This indicates a known error with the configuration for the integration or assistant. The only current case
3827
+ * is when the web chat receives a connect_to_agent response and no service desk has been configured. These are
3828
+ * generally user errors.
3829
+ */
3830
+ INTEGRATION_ERROR = 'INTEGRATION_ERROR',
3831
+
3832
+ /**
3833
+ * The agent in the service desk waited too long to pick up the request and the session has expired so history cannot
3834
+ * be fetched.
3835
+ */
3836
+ AGENT_APP_EXPIRED_SESSION = 'AGENT_APP_EXPIRED_SESSION',
3837
+
3838
+ /**
3839
+ * This indicates that some error occurred while trying to hydrate web chat. This will prevent web chat from
3840
+ * functioning.
3841
+ */
3842
+ HYDRATION = 'HYDRATION',
3843
+
3844
+ /**
3845
+ * Indicates that an attempt to load the preview link was made but security was enabled.
3846
+ */
3847
+ PREVIEW_LINK_SECURITY = 'PREVIEW_LINK_SECURITY',
3848
+ }
3849
+
3850
+ /**
3851
+ * The possible reasons that loading the web chat may fail.
3852
+ */
3853
+ declare enum CatastrophicErrorType {
3854
+ /**
3855
+ * Indicates it failed for some other reason.
3856
+ */
3857
+ FAILED = 'FAILED',
3858
+
3859
+ /**
3860
+ * Indicates it failed because there was no skill attached to the assistant.
3861
+ */
3862
+ NO_SKILL = 'NO_SKILL',
3863
+
3864
+ /**
3865
+ * Indicates it failed because the welcome node was throttled by the service.
3866
+ */
3867
+ THROTTLED = 'THROTTLED',
3868
+
3869
+ /**
3870
+ * The agent in the service desk waited too long to pick up the request and the session has expired so history cannot
3871
+ * be fetched.
3872
+ */
3873
+ AGENT_APP_EXPIRED_SESSION = 'AGENT_APP_EXPIRED_SESSION',
3874
+ }
3875
+ interface OnErrorData {
3876
+ /**
3877
+ * The type of error that occurred.
3878
+ */
3879
+ errorType: OnErrorType;
3880
+
3881
+ /**
3882
+ * A message associated with the error.
3883
+ */
3884
+ message: string;
3885
+
3886
+ /**
3887
+ * A possible error code associated with this error. The meaning of this value may vary based on the error type.
3888
+ */
3889
+ errorCode?: number;
3890
+
3891
+ /**
3892
+ * An optional transaction ID to associate with the error.
3893
+ */
3894
+ transactionID?: string;
3895
+
3896
+ /**
3897
+ * An extra blob of data associated with the error. This may be a stack trace for thrown errors.
3898
+ */
3899
+ otherData?: unknown;
3900
+
3901
+ /**
3902
+ * If the error is of the severity that requires a whole restart of web chat.
3903
+ */
3904
+ catastrophicErrorType?: CatastrophicErrorType;
3905
+ }
3906
+ interface ThemeConfig {
3907
+ /**
3908
+ * A string identifying what Carbon Theme we should base UI variables off of. Defaults to 'g10'. See
3909
+ * https://carbondesignsystem.com/guidelines/color/tokens.
3910
+ */
3911
+ carbonTheme?: CarbonTheme;
3912
+
3913
+ /**
3914
+ * This flag is used to disable web chat's rounded corners.
3915
+ */
3916
+ corners?: CornersType;
3917
+ }
3918
+
3919
+ /**
3920
+ * The type of the render function that is used to render user defined responses and chunks. This function should return a
3921
+ * component that renders the display for the message contained in the given event.
3922
+ *
3923
+ * @param event The BusEventUserDefinedResponse that was originally fired by web chat when the user defined response
3924
+ * was first fired.
3925
+ * @param instance The current instance of the web chat.
3926
+ */
3927
+ type RenderUserDefinedResponse = (event: BusEventUserDefinedResponse, instance: ChatInstance) => ReactNode;
3928
+ interface ChatContainerProps {
3929
+ /**
3930
+ * The config to use to load web chat. Note that the "onLoad" property is overridden by this component. If you
3931
+ * need to perform any actions after web chat been loaded, use the "onBeforeRender" or "onAfterRender" props.
3932
+ */
3933
+ config: PublicConfig;
3934
+
3935
+ /**
3936
+ * This function is called before the render function of web chat is called. This function can return a Promise
3937
+ * which will cause web chat to wait for it before rendering.
3938
+ */
3939
+ onBeforeRender?: (instance: ChatInstance) => Promise<void> | void;
3940
+
3941
+ /**
3942
+ * This function is called after the render function of web chat is called. This function can return a Promise
3943
+ * which will cause web chat to wait for it before rendering.
3944
+ */
3945
+ onAfterRender?: (instance: ChatInstance) => Promise<void> | void;
3946
+
3947
+ /**
3948
+ * This is the function that this component will call when a user defined response should be rendered.
3949
+ */
3950
+ renderUserDefinedResponse?: RenderUserDefinedResponse;
3951
+
3952
+ /**
3953
+ * ReactDOM.render and createRoot can't be used together in the same application.
3954
+ * Web chat detects if ReactDOM is React 18 or React 17, but they could be using React 18 in React 17 mode.
3955
+ */
3956
+ forceReact17Mode?: boolean;
3957
+ }
3958
+
3959
+ declare function ChatContainer({
3960
+ config,
3961
+ onBeforeRender,
3962
+ onAfterRender,
3963
+ renderUserDefinedResponse,
3964
+ forceReact17Mode,
3965
+ }: ChatContainerProps): React.JSX.Element;
3966
+
3967
+ /**
3968
+ * This is the React component for people injecting a web chat with a custom element.
3969
+ *
3970
+ * It provides said element any class or id defined on itself for styling.
3971
+ *
3972
+ */
3973
+ interface ChatCustomElementProps extends ChatContainerProps {
3974
+ /**
3975
+ * An optional classname that will be added to the custom element.
3976
+ */
3977
+ className?: string;
3978
+
3979
+ /**
3980
+ * An optional id that will be added to the custom element.
3981
+ */
3982
+ id?: string;
3983
+
3984
+ /**
3985
+ * An optional listener for "view:change" events. Such a listener is required when using a custom element in order
3986
+ * to control the visibility of the web chat main window. If no callback is provided here, a default one will be
3987
+ * used that injects styling into the app that will show and hide the web chat main window and also change the
3988
+ * size of the custom element so it doesn't take up space when the main window is closed.
3989
+ *
3990
+ * You can provide a different callback here if you want custom behavior such as an animation when the main window
3991
+ * is opened or closed.
3992
+ *
3993
+ * Note that this function can only be provided before web chat is loaded. After web chat is loaded, the event
3994
+ * handler will not be updated.
3995
+ */
3996
+ onViewChange?: (event: BusEventViewChange, instance: ChatInstance) => void;
3997
+ }
3998
+ declare function ChatCustomElement({
3999
+ config,
4000
+ onBeforeRender,
4001
+ onAfterRender,
4002
+ renderUserDefinedResponse,
4003
+ className,
4004
+ id,
4005
+ onViewChange,
4006
+ }: ChatCustomElementProps): React.JSX.Element;
4007
+
4008
+ export {
4009
+ type AgentAppConfig,
4010
+ type AudioItem,
4011
+ type BaseMessageInput,
4012
+ type BusEventAgentAreAnyAgentsOnline,
4013
+ type BusEventAgentEndChat,
4014
+ type BusEventAgentPreEndChat,
4015
+ type BusEventAgentPreReceive,
4016
+ type BusEventAgentPreSend,
4017
+ type BusEventAgentPreSessionHistory,
4018
+ type BusEventAgentPreStartChat,
4019
+ type BusEventAgentReceive,
4020
+ type BusEventAgentSend,
4021
+ type BusEventChatReady,
4022
+ type BusEventChunkUserDefinedResponse,
4023
+ type BusEventClosePanelButtonClicked,
4024
+ type BusEventCustomPanelClose,
4025
+ type BusEventCustomPanelOpen,
4026
+ type BusEventCustomPanelPreClose,
4027
+ type BusEventCustomPanelPreOpen,
4028
+ type BusEventGenesysMessengerAuthError,
4029
+ type BusEventGenesysMessengerAuthProvider,
4030
+ type BusEventGenesysMessengerGetAuthCode,
4031
+ type BusEventGenesysMessengerLoggedOut,
4032
+ type BusEventGenesysMessengerReauthenticate,
4033
+ type BusEventHistoryBegin,
4034
+ type BusEventHistoryEnd,
4035
+ type BusEventMessageItemCustom,
4036
+ type BusEventNiceDFOGetAuthCode,
4037
+ type BusEventPreReceive,
4038
+ type BusEventPreReset,
4039
+ type BusEventPreSend,
4040
+ type BusEventReceive,
4041
+ type BusEventReset,
4042
+ type BusEventSend,
4043
+ type BusEventTourEnd,
4044
+ type BusEventTourStart,
4045
+ type BusEventTourStep,
4046
+ BusEventType,
4047
+ type BusEventUserDefinedResponse,
4048
+ type BusEventViewChange,
4049
+ type BusEventViewPreChange,
4050
+ CarbonTheme,
4051
+ ChatContainer,
4052
+ type ChatContainerProps,
4053
+ ChatCustomElement,
4054
+ type ChatCustomElementProps,
4055
+ type ChatInstance,
4056
+ type Chunk,
4057
+ type CompleteItemChunk,
4058
+ type ConnectToAgentItem,
4059
+ type ConversationalSearchItem,
4060
+ type ConversationalSearchItemCitation,
4061
+ CornersType,
4062
+ type CustomSendMessageOptions,
4063
+ type DateItem,
4064
+ type DisclaimerPublicConfig,
4065
+ type EventInput,
4066
+ type EventInputData,
4067
+ type FinalResponseChunk,
4068
+ type GenericItem,
4069
+ type HeaderConfig,
4070
+ type HistoryItem,
4071
+ type IFrameItem,
4072
+ IFrameItemDisplayOption,
4073
+ type ImageItem,
4074
+ type ItemStreamingMetadata,
4075
+ type LayoutConfig,
4076
+ type MediaItem,
4077
+ type MediaItemDimensions,
4078
+ type MessageContext,
4079
+ type MessageGlobalContext,
4080
+ type MessageHistory,
4081
+ type MessageInput,
4082
+ MessageInputType,
4083
+ type MessageOutput,
4084
+ type MessageRequest,
4085
+ type MessageResponse,
4086
+ MessageResponseTypes,
4087
+ type MessageSkillContext,
4088
+ MinimizeButtonIconType,
4089
+ type OnErrorData,
4090
+ type Option,
4091
+ type OptionItem,
4092
+ OptionItemPreference,
4093
+ type PageLinkConfig,
4094
+ type PageLinkIDConfig,
4095
+ type PartialItemChunk,
4096
+ type PauseItem,
4097
+ type PublicConfig,
4098
+ type PublicConfigMessaging,
4099
+ type StreamChunk,
4100
+ type TextItem,
4101
+ type ThemeConfig,
4102
+ type UpdateHistoryEvent,
4103
+ type UserDefinedItem,
4104
+ type VideoItem,
4105
+ type ViewState,
4106
+ ViewType,
4107
+ };