@nlxai/core 1.2.4-alpha.1 → 1.2.4-alpha.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/docs/README.md ADDED
@@ -0,0 +1,1930 @@
1
+ ## Functions
2
+
3
+ ### createConversation()
4
+
5
+ ```ts
6
+ function createConversation(configuration): ConversationHandler;
7
+ ```
8
+
9
+ Call this to create a conversation handler.
10
+
11
+ #### Parameters
12
+
13
+ ##### configuration
14
+
15
+ [`Config`](#config)
16
+
17
+ The necessary configuration to create the conversation.
18
+
19
+ #### Returns
20
+
21
+ [`ConversationHandler`](#conversationhandler)
22
+
23
+ The [ConversationHandler](#conversationhandler) is a bundle of functions to interact with the conversation.
24
+
25
+ #### Example
26
+
27
+ ```typescript
28
+ import { createConversation } from "@nlx/core";
29
+
30
+ const conversation = createConversation({
31
+ applicationUrl: "https://apps.nlx.ai/c/cfab3-243ad-232dc",
32
+ headers: {
33
+ "nlx-api-key": "4393029032-dwsd",
34
+ },
35
+ userId: "abcd-1234",
36
+ languageCode: "en-US",
37
+ });
38
+ ```
39
+
40
+ ---
41
+
42
+ ### isConfigValid()
43
+
44
+ ```ts
45
+ function isConfigValid(configuration): boolean;
46
+ ```
47
+
48
+ Check whether a configuration is valid.
49
+
50
+ #### Parameters
51
+
52
+ ##### configuration
53
+
54
+ [`Config`](#config)
55
+
56
+ Conversation configuration
57
+
58
+ #### Returns
59
+
60
+ `boolean`
61
+
62
+ Whether the configuration is valid?
63
+
64
+ ---
65
+
66
+ ### shouldReinitialize()
67
+
68
+ ```ts
69
+ function shouldReinitialize(config1, config2): boolean;
70
+ ```
71
+
72
+ Helper method to decide when a new [Config](#config) requires creating a new [ConversationHandler](#conversationhandler) or whether the old `Config`'s
73
+ `ConversationHandler` can be used.
74
+
75
+ The order of configs doesn't matter.
76
+
77
+ #### Parameters
78
+
79
+ ##### config1
80
+
81
+ [`Config`](#config)
82
+
83
+ ##### config2
84
+
85
+ [`Config`](#config)
86
+
87
+ #### Returns
88
+
89
+ `boolean`
90
+
91
+ true if `createConversation` should be called again
92
+
93
+ ---
94
+
95
+ ### getCurrentExpirationTimestamp()
96
+
97
+ ```ts
98
+ function getCurrentExpirationTimestamp(responses): number | null;
99
+ ```
100
+
101
+ Get current expiration timestamp from a list of responses. Can be used to determine if a conversation has timed out.
102
+
103
+ #### Parameters
104
+
105
+ ##### responses
106
+
107
+ [`Response`](#response)[]
108
+
109
+ The current list of user and application responses (first argument in the subscribe callback)
110
+
111
+ #### Returns
112
+
113
+ `number` \| `null`
114
+
115
+ An expiration timestamp in Unix Epoch (`new Date().getTime()`), or `null` if this is not known (typically occurs if the application has not responded yet)
116
+
117
+ #### Example
118
+
119
+ ```typescript
120
+ import { useState } from "react";
121
+ import { getCurrentExpirationTimestamp } from "@nlxai/core";
122
+
123
+ const [isTimedOut, setIsTimedOut] = useState(false);
124
+
125
+ conversation.subscribe((responses) => {
126
+ const expirationTimestamp = getCurrentExpirationTimestamp(responses);
127
+ if (expirationTimestamp != null && expirationTimestamp < new Date().getTime()) {
128
+ setIsTimedOut(true);
129
+ }
130
+ });
131
+
132
+ return (<div>
133
+ {isTimedOut ? (
134
+ <p>Your session has timed out. Please start a new conversation.</p>
135
+ ) : (
136
+ <p>Your session is active.</p>
137
+ )}
138
+ </div>
139
+ ```
140
+
141
+ ---
142
+
143
+ ### promisify()
144
+
145
+ ```ts
146
+ function promisify<Params>(
147
+ fn,
148
+ convo,
149
+ timeout,
150
+ ): (payload) => Promise<Response | null>;
151
+ ```
152
+
153
+ This package is intentionally designed with a subscription-based API as opposed to a promise-based one where each message corresponds to a single application response, available asynchronously.
154
+
155
+ If you need a promise-based wrapper, you can use the `promisify` helper available in the package:
156
+
157
+ #### Type Parameters
158
+
159
+ ##### Params
160
+
161
+ `Params`
162
+
163
+ the type of the function's params, e.g. for `sendText` it's `text: string, context?: Context`
164
+
165
+ #### Parameters
166
+
167
+ ##### fn
168
+
169
+ (`payload`) => `void`
170
+
171
+ the function to wrap (e.g. `convo.sendText`, `convo.sendChoice`, etc.)
172
+
173
+ ##### convo
174
+
175
+ [`ConversationHandler`](#conversationhandler)
176
+
177
+ the `ConversationHandler` (from [createConversation](#createconversation))
178
+
179
+ ##### timeout
180
+
181
+ `number` = `10000`
182
+
183
+ the timeout in milliseconds
184
+
185
+ #### Returns
186
+
187
+ A promise-wrapped version of the function. The function, when called, returns a promise that resolves to the Conversation's next response.
188
+
189
+ ```ts
190
+ (payload): Promise<Response | null>;
191
+ ```
192
+
193
+ ##### Parameters
194
+
195
+ ###### payload
196
+
197
+ `Params`
198
+
199
+ ##### Returns
200
+
201
+ `Promise`\<[`Response`](#response) \| `null`\>
202
+
203
+ #### Example
204
+
205
+ ```typescript
206
+ import { createConversation, promisify } from "@nlxai/core";
207
+
208
+ const convo = createConversation(config);
209
+
210
+ const sendTextWrapped = promisify(convo.sendText, convo);
211
+
212
+ sendTextWrapped("Hello").then((response) => {
213
+ console.log(response);
214
+ });
215
+ ```
216
+
217
+ ## Variables
218
+
219
+ ### version
220
+
221
+ ```ts
222
+ const version: string = packageJson.version;
223
+ ```
224
+
225
+ Package version
226
+
227
+ ## Interfaces
228
+
229
+ ### Config
230
+
231
+ The configuration necessary to create a conversation.
232
+
233
+ #### Properties
234
+
235
+ ##### applicationUrl?
236
+
237
+ ```ts
238
+ optional applicationUrl: string;
239
+ ```
240
+
241
+ The URL at which your conversational application is running.
242
+ Fetch this from the application's API channel tab.
243
+
244
+ ##### headers
245
+
246
+ ```ts
247
+ headers: Record<string, string> & object;
248
+ ```
249
+
250
+ Headers to forward to the NLX API.
251
+
252
+ ###### Type Declaration
253
+
254
+ ###### nlx-api-key
255
+
256
+ ```ts
257
+ nlx-api-key: string;
258
+ ```
259
+
260
+ The `nlx-api-key` is required. Fetch this from the application's API channel tab.
261
+
262
+ ##### conversationId?
263
+
264
+ ```ts
265
+ optional conversationId: string;
266
+ ```
267
+
268
+ Set `conversationId` to continue an existing conversation. If not set, a new conversation will be started (and a new conversationId will be generated internally).
269
+
270
+ ##### userId?
271
+
272
+ ```ts
273
+ optional userId: string;
274
+ ```
275
+
276
+ Setting the `userID` allows it to be searchable in application history, as well as usable via `{System.userId}` in the flow.
277
+
278
+ ##### responses?
279
+
280
+ ```ts
281
+ optional responses: Response[];
282
+ ```
283
+
284
+ When `responses` is set, initialize the chatHandler with historical messages. This is useful when restoring a previous conversation, that perhaps started on a different page.
285
+
286
+ ##### failureMessage?
287
+
288
+ ```ts
289
+ optional failureMessage: string;
290
+ ```
291
+
292
+ When set, this overrides the default failure message ("We encountered an issue. Please try again soon.").
293
+
294
+ ##### languageCode
295
+
296
+ ```ts
297
+ languageCode: string;
298
+ ```
299
+
300
+ The language code to use for the application. In the browser this can be fetched with `navigator.language`.
301
+ If you don't have translations, hard-code this to the language code you support.
302
+
303
+ ##### bidirectional?
304
+
305
+ ```ts
306
+ optional bidirectional: boolean;
307
+ ```
308
+
309
+ Specifies whether the conversation is using bidirectional Voice+ (if so, an additional command socket will be opened).
310
+
311
+ ---
312
+
313
+ ### ConversationHandler
314
+
315
+ A bundle of functions to interact with a conversation, created by [createConversation](#createconversation).
316
+
317
+ #### Properties
318
+
319
+ ##### sendText()
320
+
321
+ ```ts
322
+ sendText: (text, context?) => void;
323
+ ```
324
+
325
+ Send user's message
326
+
327
+ ###### Parameters
328
+
329
+ ###### text
330
+
331
+ `string`
332
+
333
+ the user's message
334
+
335
+ ###### context?
336
+
337
+ [`Context`](#context)
338
+
339
+ [Context](https://docs.nlx.ai/platform/nlx-platform-guide/build-with-nlx/flows/context-variables#what-are-context-variables) for usage later in the flow.
340
+
341
+ ###### Returns
342
+
343
+ `void`
344
+
345
+ ##### sendSlots()
346
+
347
+ ```ts
348
+ sendSlots: (slots, context?) => void;
349
+ ```
350
+
351
+ Send [slots](https://docs.nlx.ai/platform/nlx-platform-guide/build-with-nlx/flows/slots-custom#slot-settings) to the application.
352
+
353
+ ###### Parameters
354
+
355
+ ###### slots
356
+
357
+ [`SlotsRecordOrArray`](#slotsrecordorarray)
358
+
359
+ The slots to populate
360
+
361
+ ###### context?
362
+
363
+ [`Context`](#context)
364
+
365
+ [Context](https://docs.nlx.ai/platform/nlx-platform-guide/build-with-nlx/flows/context-variables#what-are-context-variables) for usage later in the flow.
366
+
367
+ ###### Returns
368
+
369
+ `void`
370
+
371
+ ##### sendChoice()
372
+
373
+ ```ts
374
+ sendChoice: (choiceId, context?, metadata?) => void;
375
+ ```
376
+
377
+ Respond to [a choice](https://docs.studio.nlx.ai/intentflows/documentation-flows/flows-build-mode/nodes#user-choice) from the application.
378
+
379
+ ###### Parameters
380
+
381
+ ###### choiceId
382
+
383
+ `string`
384
+
385
+ The `choiceId` is in the [ApplicationResponse](#applicationresponse)'s `.payload.messages[].choices[].choiceId` fields
386
+
387
+ ###### context?
388
+
389
+ [`Context`](#context)
390
+
391
+ [Context](https://docs.nlx.ai/platform/nlx-platform-guide/build-with-nlx/flows/context-variables#what-are-context-variables) for usage later in the flow.
392
+
393
+ ###### metadata?
394
+
395
+ [`ChoiceRequestMetadata`](#choicerequestmetadata)
396
+
397
+ links the choice to the specific message and node in the conversation.
398
+
399
+ ###### Returns
400
+
401
+ `void`
402
+
403
+ ##### sendWelcomeFlow()
404
+
405
+ ```ts
406
+ sendWelcomeFlow: (context?) => void;
407
+ ```
408
+
409
+ Trigger the welcome flow. This should be done when the user starts interacting with the conversation.
410
+
411
+ ###### Parameters
412
+
413
+ ###### context?
414
+
415
+ [`Context`](#context)
416
+
417
+ [Context](https://docs.nlx.ai/platform/nlx-platform-guide/build-with-nlx/flows/context-variables#what-are-context-variables) for usage later in the flow.
418
+
419
+ ###### Returns
420
+
421
+ `void`
422
+
423
+ ##### sendFlow()
424
+
425
+ ```ts
426
+ sendFlow: (flowId, context?) => void;
427
+ ```
428
+
429
+ Trigger a specific flow.
430
+
431
+ ###### Parameters
432
+
433
+ ###### flowId
434
+
435
+ `string`
436
+
437
+ the flow to trigger. The id is the name under the application's _Intents_.
438
+
439
+ ###### context?
440
+
441
+ [`Context`](#context)
442
+
443
+ [Context](https://docs.nlx.ai/platform/nlx-platform-guide/build-with-nlx/flows/context-variables#what-are-context-variables) for usage later in the intent.
444
+
445
+ ###### Returns
446
+
447
+ `void`
448
+
449
+ ##### sendContext()
450
+
451
+ ```ts
452
+ sendContext: (context) => Promise<void>;
453
+ ```
454
+
455
+ Send context without sending a message
456
+
457
+ ###### Parameters
458
+
459
+ ###### context
460
+
461
+ [`Context`](#context)
462
+
463
+ [Context](https://docs.nlx.ai/platform/nlx-platform-guide/build-with-nlx/flows/context-variables#what-are-context-variables) for usage later in the intent.
464
+
465
+ ###### Returns
466
+
467
+ `Promise`\<`void`\>
468
+
469
+ ##### appendMessageToTranscript()
470
+
471
+ ```ts
472
+ appendMessageToTranscript: (response) => void;
473
+ ```
474
+
475
+ Append messages manually to the transcript. This is an advanced feature that allows routing and aggregation of different chat message
476
+ sources.
477
+
478
+ ###### Parameters
479
+
480
+ ###### response
481
+
482
+ the response with optional timestamps.
483
+
484
+ `Omit`\<[`ApplicationResponse`](#applicationresponse), `"receivedAt"`\> & `object` | `Omit`\<[`UserResponse`](#userresponse), `"receivedAt"`\> & `object` | `Omit`\<[`FailureMessage`](#failuremessage-1), `"receivedAt"`\> & `object`
485
+
486
+ ###### Returns
487
+
488
+ `void`
489
+
490
+ ##### sendStructured()
491
+
492
+ ```ts
493
+ sendStructured: (request, context?) => void;
494
+ ```
495
+
496
+ Send a combination of choice, slots, and intent in one request.
497
+
498
+ ###### Parameters
499
+
500
+ ###### request
501
+
502
+ [`StructuredRequest`](#structuredrequest)
503
+
504
+ ###### context?
505
+
506
+ [`Context`](#context)
507
+
508
+ [Context](https://docs.studio.nlx.ai/workspacesettings/documentation-settings/settings-context-attributes) for usage later in the intent.
509
+
510
+ ###### Returns
511
+
512
+ `void`
513
+
514
+ ##### submitFeedback()
515
+
516
+ ```ts
517
+ submitFeedback: (url, feedback) => Promise<void>;
518
+ ```
519
+
520
+ Submit feedback about a response.
521
+
522
+ ###### Parameters
523
+
524
+ ###### url
525
+
526
+ `string`
527
+
528
+ The URL comming from the Application response `metadata.feedbackURL` field.
529
+
530
+ ###### feedback
531
+
532
+ Either a numerical rating or a textual comment.
533
+
534
+ ###### rating?
535
+
536
+ `number`
537
+
538
+ ###### comment?
539
+
540
+ `string`
541
+
542
+ ###### Returns
543
+
544
+ `Promise`\<`void`\>
545
+
546
+ ##### subscribe()
547
+
548
+ ```ts
549
+ subscribe: (subscriber) => () => void;
550
+ ```
551
+
552
+ Subscribe a callback to the conversation. On subscribe, the subscriber will receive all of the Responses that the conversation has already received.
553
+
554
+ ###### Parameters
555
+
556
+ ###### subscriber
557
+
558
+ [`Subscriber`](#subscriber)
559
+
560
+ The callback to subscribe
561
+
562
+ ###### Returns
563
+
564
+ A function to unsubscribe the callback.
565
+
566
+ ```ts
567
+ (): void;
568
+ ```
569
+
570
+ ###### Returns
571
+
572
+ `void`
573
+
574
+ ##### unsubscribe()
575
+
576
+ ```ts
577
+ unsubscribe: (subscriber) => void;
578
+ ```
579
+
580
+ Unsubscribe a callback from the conversation.
581
+
582
+ ###### Parameters
583
+
584
+ ###### subscriber
585
+
586
+ [`Subscriber`](#subscriber)
587
+
588
+ The callback to unsubscribe
589
+
590
+ ###### Returns
591
+
592
+ `void`
593
+
594
+ ##### unsubscribeAll()
595
+
596
+ ```ts
597
+ unsubscribeAll: () => void;
598
+ ```
599
+
600
+ Unsubscribe all callback from the conversation.
601
+
602
+ ###### Returns
603
+
604
+ `void`
605
+
606
+ ##### currentConversationId()
607
+
608
+ ```ts
609
+ currentConversationId: () => string | undefined;
610
+ ```
611
+
612
+ Get the current conversation ID if it's set, or undefined if there is no conversation.
613
+
614
+ ###### Returns
615
+
616
+ `string` \| `undefined`
617
+
618
+ ##### currentLanguageCode()
619
+
620
+ ```ts
621
+ currentLanguageCode: () => string;
622
+ ```
623
+
624
+ Get the current language code
625
+
626
+ ###### Returns
627
+
628
+ `string`
629
+
630
+ ##### setLanguageCode()
631
+
632
+ ```ts
633
+ setLanguageCode: (languageCode) => void;
634
+ ```
635
+
636
+ Set the language code
637
+
638
+ ###### Parameters
639
+
640
+ ###### languageCode
641
+
642
+ `string`
643
+
644
+ ###### Returns
645
+
646
+ `void`
647
+
648
+ ##### reset()
649
+
650
+ ```ts
651
+ reset: (options?) => void;
652
+ ```
653
+
654
+ Forces a new conversation. If `clearResponses` is set to true, will also clear historical responses passed to subscribers.
655
+ Retains all existing subscribers.
656
+
657
+ ###### Parameters
658
+
659
+ ###### options?
660
+
661
+ ###### clearResponses?
662
+
663
+ `boolean`
664
+
665
+ If set to true, will clear historical responses passed to subscribers.
666
+
667
+ ###### Returns
668
+
669
+ `void`
670
+
671
+ ##### destroy()
672
+
673
+ ```ts
674
+ destroy: () => void;
675
+ ```
676
+
677
+ Removes all subscribers and, if using websockets, closes the connection.
678
+
679
+ ###### Returns
680
+
681
+ `void`
682
+
683
+ ##### setRequestOverride()
684
+
685
+ ```ts
686
+ setRequestOverride: (override) => void;
687
+ ```
688
+
689
+ Optional [RequestOverride](#requestoverride) function used to bypass the application request and handle them in a custom fashion
690
+
691
+ ###### Parameters
692
+
693
+ ###### override
694
+
695
+ [`RequestOverride`](#requestoverride) | `undefined`
696
+
697
+ ###### Returns
698
+
699
+ `void`
700
+
701
+ ##### addEventListener()
702
+
703
+ ```ts
704
+ addEventListener: (event, handler) => void;
705
+ ```
706
+
707
+ Add a listener to one of the handler's custom events
708
+
709
+ ###### Parameters
710
+
711
+ ###### event
712
+
713
+ [`ConversationHandlerEvent`](#conversationhandlerevent)
714
+
715
+ ###### handler
716
+
717
+ [`VoicePlusCommandListener`](#voicepluscommandlistener) | [`InterimMessageListener`](#interimmessagelistener)
718
+
719
+ ###### Returns
720
+
721
+ `void`
722
+
723
+ ##### removeEventListener()
724
+
725
+ ```ts
726
+ removeEventListener: (event, handler) => void;
727
+ ```
728
+
729
+ Remove a listener to one of the handler's custom events
730
+
731
+ ###### Parameters
732
+
733
+ ###### event
734
+
735
+ [`ConversationHandlerEvent`](#conversationhandlerevent)
736
+
737
+ ###### handler
738
+
739
+ [`VoicePlusCommandListener`](#voicepluscommandlistener) | [`InterimMessageListener`](#interimmessagelistener)
740
+
741
+ ###### Returns
742
+
743
+ `void`
744
+
745
+ ---
746
+
747
+ ### SlotValue
748
+
749
+ Values to fill an intent's [attached slots](https://docs.studio.nlx.ai/intents/documentation-intents/intents-attached-slots).
750
+
751
+ An array of `SlotValue` objects is equivalent to a [SlotsRecord](#slotsrecord).
752
+
753
+ #### Properties
754
+
755
+ ##### slotId
756
+
757
+ ```ts
758
+ slotId: string;
759
+ ```
760
+
761
+ The attached slot's name
762
+
763
+ ##### value
764
+
765
+ ```ts
766
+ value: any;
767
+ ```
768
+
769
+ Usually this will be a discrete value matching the slots's [type](https://docs.studio.nlx.ai/slots/documentation-slots/slots-values#system-slots).
770
+ for custom slots, this can optionally be the value's ID.
771
+
772
+ ---
773
+
774
+ ### ApplicationResponse
775
+
776
+ A message from the application
777
+
778
+ See also:
779
+
780
+ - [UserResponse](#userresponse)
781
+ - [FailureMessage](#failuremessage-1)
782
+ - [Response](#response)
783
+
784
+ #### Properties
785
+
786
+ ##### type
787
+
788
+ ```ts
789
+ type: Application;
790
+ ```
791
+
792
+ The application response type
793
+
794
+ ##### receivedAt
795
+
796
+ ```ts
797
+ receivedAt: number;
798
+ ```
799
+
800
+ When the response was received
801
+
802
+ ##### payload
803
+
804
+ ```ts
805
+ payload: ApplicationResponsePayload;
806
+ ```
807
+
808
+ The payload of the response
809
+
810
+ ---
811
+
812
+ ### ApplicationResponsePayload
813
+
814
+ The payload of the application response
815
+
816
+ #### Properties
817
+
818
+ ##### expirationTimestamp?
819
+
820
+ ```ts
821
+ optional expirationTimestamp: number;
822
+ ```
823
+
824
+ If there isn't some interaction by this time, the conversation will expire.
825
+
826
+ ##### conversationId?
827
+
828
+ ```ts
829
+ optional conversationId: string;
830
+ ```
831
+
832
+ The active conversation ID. If not set, a new conversation will be started.
833
+
834
+ ##### messages
835
+
836
+ ```ts
837
+ messages: ApplicationMessage[];
838
+ ```
839
+
840
+ Any messages from the application.
841
+
842
+ ##### metadata?
843
+
844
+ ```ts
845
+ optional metadata: ApplicationResponseMetadata;
846
+ ```
847
+
848
+ Global state about the current conversation
849
+ as well as whether the client should poll for more application responses.
850
+
851
+ ##### payload?
852
+
853
+ ```ts
854
+ optional payload: string;
855
+ ```
856
+
857
+ If configured, the [node's payload.](See: https://docs.studio.nlx.ai/intentflows/documentation-flows/flows-build-mode/advanced-messaging-+-functionality#add-functionality)
858
+
859
+ ##### modalities?
860
+
861
+ ```ts
862
+ optional modalities: ModalityPayloads;
863
+ ```
864
+
865
+ If configured, the node's modalities and their payloads.
866
+
867
+ ##### context?
868
+
869
+ ```ts
870
+ optional context: Context;
871
+ ```
872
+
873
+ If the node is set to send context, the whole context associated with the conversation.
874
+
875
+ ---
876
+
877
+ ### ApplicationResponseMetadata
878
+
879
+ Global state about the current conversation
880
+ as well as whether the client should poll for more application responses.
881
+
882
+ #### Properties
883
+
884
+ ##### intentId?
885
+
886
+ ```ts
887
+ optional intentId: string;
888
+ ```
889
+
890
+ The conversation's intent
891
+
892
+ ##### escalation?
893
+
894
+ ```ts
895
+ optional escalation: boolean;
896
+ ```
897
+
898
+ Whether the current conversation has been marked as incomprehension.
899
+
900
+ ##### frustration?
901
+
902
+ ```ts
903
+ optional frustration: boolean;
904
+ ```
905
+
906
+ Whether the current conversation has been marked frustrated
907
+
908
+ ##### incomprehension?
909
+
910
+ ```ts
911
+ optional incomprehension: boolean;
912
+ ```
913
+
914
+ Whether the current conversation has been marked as incomprehension.
915
+
916
+ ##### uploadUrls
917
+
918
+ ```ts
919
+ uploadUrls: UploadUrl[];
920
+ ```
921
+
922
+ Upload URL's
923
+
924
+ ##### hasPendingDataRequest?
925
+
926
+ ```ts
927
+ optional hasPendingDataRequest: boolean;
928
+ ```
929
+
930
+ Whether the client should poll for more application responses.
931
+
932
+ ##### sources?
933
+
934
+ ```ts
935
+ optional sources: KnowledgeBaseResponseSource[];
936
+ ```
937
+
938
+ Knowledge base sources
939
+
940
+ ##### feedbackUrl?
941
+
942
+ ```ts
943
+ optional feedbackUrl: string;
944
+ ```
945
+
946
+ URL to use for submitting feedback about this response. See `feedbackConfig` for what the expected feedback type is.
947
+
948
+ You can pass this as the first argument to `submitFeedback`.
949
+
950
+ ##### feedbackConfig?
951
+
952
+ ```ts
953
+ optional feedbackConfig: FeedbackConfiguration;
954
+ ```
955
+
956
+ If present, the application would like to collect feedback from the user.
957
+
958
+ ---
959
+
960
+ ### KnowledgeBaseResponseSource
961
+
962
+ Response for knowlege base sources
963
+
964
+ #### Properties
965
+
966
+ ##### fileName?
967
+
968
+ ```ts
969
+ optional fileName: string;
970
+ ```
971
+
972
+ File name
973
+
974
+ ##### pageNumber?
975
+
976
+ ```ts
977
+ optional pageNumber: number;
978
+ ```
979
+
980
+ Page number
981
+
982
+ ##### content?
983
+
984
+ ```ts
985
+ optional content: string;
986
+ ```
987
+
988
+ Content
989
+
990
+ ##### metadata?
991
+
992
+ ```ts
993
+ optional metadata: Record<string, unknown>;
994
+ ```
995
+
996
+ Metadata
997
+
998
+ ##### presignedUrl?
999
+
1000
+ ```ts
1001
+ optional presignedUrl: string;
1002
+ ```
1003
+
1004
+ Presigned URL for direct retrieval
1005
+
1006
+ ---
1007
+
1008
+ ### ApplicationMessageMetadata
1009
+
1010
+ Metadata for the individual application message
1011
+ as well as whether the client should poll for more application responses.
1012
+
1013
+ #### Properties
1014
+
1015
+ ##### intentId?
1016
+
1017
+ ```ts
1018
+ optional intentId: string;
1019
+ ```
1020
+
1021
+ The message node's intent
1022
+
1023
+ ---
1024
+
1025
+ ### ApplicationMessage
1026
+
1027
+ A message from the application, as well as any choices the user can make.
1028
+
1029
+ #### Properties
1030
+
1031
+ ##### messageId?
1032
+
1033
+ ```ts
1034
+ optional messageId: string;
1035
+ ```
1036
+
1037
+ A unique identifier for the message.
1038
+
1039
+ ##### nodeId?
1040
+
1041
+ ```ts
1042
+ optional nodeId: string;
1043
+ ```
1044
+
1045
+ The node id that this message is associated with.
1046
+ This is must be sent with a choice when the user is changing a previously sent choice.
1047
+
1048
+ ##### text
1049
+
1050
+ ```ts
1051
+ text: string;
1052
+ ```
1053
+
1054
+ The body of the message. Show this to the user.
1055
+
1056
+ ##### choices
1057
+
1058
+ ```ts
1059
+ choices: Choice[];
1060
+ ```
1061
+
1062
+ A selection of choices to show to the user. They may choose one of them.
1063
+
1064
+ ##### metadata?
1065
+
1066
+ ```ts
1067
+ optional metadata: ApplicationMessageMetadata;
1068
+ ```
1069
+
1070
+ Metadata
1071
+
1072
+ ##### selectedChoiceId?
1073
+
1074
+ ```ts
1075
+ optional selectedChoiceId: string;
1076
+ ```
1077
+
1078
+ After a choice has been made by the user, this will be updated locally to the selected choice id.
1079
+ This field is set locally and does not come from the application.
1080
+
1081
+ ---
1082
+
1083
+ ### UploadUrl
1084
+
1085
+ The upload destination for handling conversing with files
1086
+
1087
+ #### Properties
1088
+
1089
+ ##### url
1090
+
1091
+ ```ts
1092
+ url: string;
1093
+ ```
1094
+
1095
+ The URL of the upload
1096
+
1097
+ ##### uploadId
1098
+
1099
+ ```ts
1100
+ uploadId: string;
1101
+ ```
1102
+
1103
+ The ID of the upload
1104
+
1105
+ ---
1106
+
1107
+ ### Choice
1108
+
1109
+ A choices to show to the user.
1110
+
1111
+ #### Properties
1112
+
1113
+ ##### choiceId
1114
+
1115
+ ```ts
1116
+ choiceId: string;
1117
+ ```
1118
+
1119
+ `choiceId` is used by `sendChoice` to let the user choose this choice.
1120
+
1121
+ ##### choiceText
1122
+
1123
+ ```ts
1124
+ choiceText: string;
1125
+ ```
1126
+
1127
+ The text of the choice
1128
+
1129
+ ##### choicePayload?
1130
+
1131
+ ```ts
1132
+ optional choicePayload: any;
1133
+ ```
1134
+
1135
+ An optional, schemaless payload for the choice.
1136
+
1137
+ ---
1138
+
1139
+ ### UserResponse
1140
+
1141
+ A message from the user
1142
+
1143
+ See also:
1144
+
1145
+ - [ApplicationResponse](#applicationresponse)
1146
+ - [FailureMessage](#failuremessage-1)
1147
+ - [Response](#response)
1148
+
1149
+ #### Properties
1150
+
1151
+ ##### type
1152
+
1153
+ ```ts
1154
+ type: User;
1155
+ ```
1156
+
1157
+ The user response type
1158
+
1159
+ ##### receivedAt
1160
+
1161
+ ```ts
1162
+ receivedAt: number;
1163
+ ```
1164
+
1165
+ When the response was received
1166
+
1167
+ ##### payload
1168
+
1169
+ ```ts
1170
+ payload: UserResponsePayload;
1171
+ ```
1172
+
1173
+ The payload of the response
1174
+
1175
+ ---
1176
+
1177
+ ### FailureMessage
1178
+
1179
+ A failure message is received when the NLX api is unreachable, or sends an unparsable response.
1180
+
1181
+ #### Properties
1182
+
1183
+ ##### type
1184
+
1185
+ ```ts
1186
+ type: Failure;
1187
+ ```
1188
+
1189
+ The failure response type
1190
+
1191
+ ##### payload
1192
+
1193
+ ```ts
1194
+ payload: object;
1195
+ ```
1196
+
1197
+ The payload only includes an error message.
1198
+
1199
+ ###### text
1200
+
1201
+ ```ts
1202
+ text: string;
1203
+ ```
1204
+
1205
+ The error message is either the default, or the `failureMessage` set in the [Config](#config).
1206
+
1207
+ ##### receivedAt
1208
+
1209
+ ```ts
1210
+ receivedAt: number;
1211
+ ```
1212
+
1213
+ When the failure occurred.
1214
+
1215
+ ---
1216
+
1217
+ ### FeedbackConfiguration
1218
+
1219
+ Configuration for feedback collection. You can use this to render an appropriate feedback widget in your application.
1220
+
1221
+ #### Properties
1222
+
1223
+ ##### feedbackId
1224
+
1225
+ ```ts
1226
+ feedbackId: string;
1227
+ ```
1228
+
1229
+ Unique identifier for the feedback collection.
1230
+
1231
+ ##### feedbackName
1232
+
1233
+ ```ts
1234
+ feedbackName: string;
1235
+ ```
1236
+
1237
+ Human readable name of this feedback collection.
1238
+
1239
+ ##### feedbackType
1240
+
1241
+ ```ts
1242
+ feedbackType: object;
1243
+ ```
1244
+
1245
+ Type of feedback being collected.
1246
+ At the moment only binary feedback is supported, but we plan to introduce more types in the future.
1247
+ Hence your code should make sure to check the `type` attribute to make sure the expected feedback type is handled.
1248
+
1249
+ ###### type
1250
+
1251
+ ```ts
1252
+ type: "binary";
1253
+ ```
1254
+
1255
+ A binary feedback type is a thumbs up/down sort of choice.
1256
+
1257
+ ###### config
1258
+
1259
+ ```ts
1260
+ config: object;
1261
+ ```
1262
+
1263
+ Configuration specific to binary feedback.
1264
+
1265
+ ###### config.positiveValue
1266
+
1267
+ ```ts
1268
+ positiveValue: number;
1269
+ ```
1270
+
1271
+ Value to send for positive feedback. Default `1`.
1272
+
1273
+ ###### config.negativeValue
1274
+
1275
+ ```ts
1276
+ negativeValue: number;
1277
+ ```
1278
+
1279
+ Value to send for negative feedback. Default `-1`.
1280
+
1281
+ ##### commentsEnabled
1282
+
1283
+ ```ts
1284
+ commentsEnabled: boolean;
1285
+ ```
1286
+
1287
+ Whether comments are enabled for this feedback collection.
1288
+
1289
+ ##### question?
1290
+
1291
+ ```ts
1292
+ optional question: string;
1293
+ ```
1294
+
1295
+ Optional question to show to the user when collecting feedback.
1296
+
1297
+ ##### labels
1298
+
1299
+ ```ts
1300
+ labels: object;
1301
+ ```
1302
+
1303
+ Labels for individual feedback UI elements as customised by the builder.
1304
+
1305
+ ###### positive?
1306
+
1307
+ ```ts
1308
+ optional positive: string;
1309
+ ```
1310
+
1311
+ Label for positive feedback
1312
+
1313
+ ###### negative?
1314
+
1315
+ ```ts
1316
+ optional negative: string;
1317
+ ```
1318
+
1319
+ Label for negative feedback
1320
+
1321
+ ###### comment?
1322
+
1323
+ ```ts
1324
+ optional comment: string;
1325
+ ```
1326
+
1327
+ Label for comment
1328
+
1329
+ ---
1330
+
1331
+ ### StructuredRequest
1332
+
1333
+ The body of `sendStructured`
1334
+ Includes a combination of choice, slots, and intent in one request.
1335
+
1336
+ #### Properties
1337
+
1338
+ ##### choiceId?
1339
+
1340
+ ```ts
1341
+ optional choiceId: string;
1342
+ ```
1343
+
1344
+ The `choiceId` is in the [ApplicationResponse](#applicationresponse)'s `.payload.messages[].choices[].choiceId` fields
1345
+
1346
+ ##### nodeId?
1347
+
1348
+ ```ts
1349
+ optional nodeId: string;
1350
+ ```
1351
+
1352
+ Required if you want to change a choice that's already been sent.
1353
+ The `nodeId` can be found in the corresponding [ApplicationMessage](#applicationmessage).
1354
+
1355
+ ##### ~~intentId?~~
1356
+
1357
+ ```ts
1358
+ optional intentId: string;
1359
+ ```
1360
+
1361
+ The intent to trigger. The `intentId` is the name under the application's _Intents_.
1362
+
1363
+ ###### Deprecated
1364
+
1365
+ use `flowId` instead.
1366
+
1367
+ ##### flowId?
1368
+
1369
+ ```ts
1370
+ optional flowId: string;
1371
+ ```
1372
+
1373
+ The flow to trigger. The `flowId` is the name under the application's _Flows_.
1374
+
1375
+ ##### slots?
1376
+
1377
+ ```ts
1378
+ optional slots: SlotsRecordOrArray;
1379
+ ```
1380
+
1381
+ The slots to populate
1382
+
1383
+ ##### uploadIds?
1384
+
1385
+ ```ts
1386
+ optional uploadIds: string[];
1387
+ ```
1388
+
1389
+ Upload ID
1390
+
1391
+ ##### utterance?
1392
+
1393
+ ```ts
1394
+ optional utterance: string;
1395
+ ```
1396
+
1397
+ Upload utterance
1398
+
1399
+ ---
1400
+
1401
+ ### ApplicationRequest
1402
+
1403
+ The request data actually sent to the application, slightly different from [UserResponsePayload](#userresponsepayload-1), which includes some UI-specific information
1404
+
1405
+ #### Properties
1406
+
1407
+ ##### conversationId?
1408
+
1409
+ ```ts
1410
+ optional conversationId: string;
1411
+ ```
1412
+
1413
+ The current conversation ID
1414
+
1415
+ ##### userId?
1416
+
1417
+ ```ts
1418
+ optional userId: string;
1419
+ ```
1420
+
1421
+ The current user ID
1422
+
1423
+ ##### context?
1424
+
1425
+ ```ts
1426
+ optional context: Context;
1427
+ ```
1428
+
1429
+ Request context, if applicable
1430
+
1431
+ ##### request
1432
+
1433
+ ```ts
1434
+ request: object;
1435
+ ```
1436
+
1437
+ Main request
1438
+
1439
+ ###### unstructured?
1440
+
1441
+ ```ts
1442
+ optional unstructured: object;
1443
+ ```
1444
+
1445
+ Unstructured request
1446
+
1447
+ ###### unstructured.text
1448
+
1449
+ ```ts
1450
+ text: string;
1451
+ ```
1452
+
1453
+ Request body text
1454
+
1455
+ ###### structured?
1456
+
1457
+ ```ts
1458
+ optional structured: StructuredRequest & object;
1459
+ ```
1460
+
1461
+ Structured request
1462
+
1463
+ ###### Type Declaration
1464
+
1465
+ ###### slots?
1466
+
1467
+ ```ts
1468
+ optional slots: SlotValue[];
1469
+ ```
1470
+
1471
+ Only array-form slots are allowed for the purposes of sending to the backend
1472
+
1473
+ ---
1474
+
1475
+ ### VoiceCredentials
1476
+
1477
+ Credentials to connect to a Voice channel
1478
+
1479
+ #### Properties
1480
+
1481
+ ##### url
1482
+
1483
+ ```ts
1484
+ url: string;
1485
+ ```
1486
+
1487
+ Voice Connection URL
1488
+
1489
+ ##### roomName
1490
+
1491
+ ```ts
1492
+ roomName: string;
1493
+ ```
1494
+
1495
+ Voice room name
1496
+
1497
+ ##### token
1498
+
1499
+ ```ts
1500
+ token: string;
1501
+ ```
1502
+
1503
+ Voice token
1504
+
1505
+ ##### participantName
1506
+
1507
+ ```ts
1508
+ participantName: string;
1509
+ ```
1510
+
1511
+ Voice participant name
1512
+
1513
+ ---
1514
+
1515
+ ### ChoiceRequestMetadata
1516
+
1517
+ Helps link the choice to the specific message in the conversation.
1518
+
1519
+ #### Properties
1520
+
1521
+ ##### responseIndex?
1522
+
1523
+ ```ts
1524
+ optional responseIndex: number;
1525
+ ```
1526
+
1527
+ The index of the [Response](#response) associated with this choice.
1528
+ Setting this ensures that local state's `selectedChoiceId` on the corresponding [ApplicationResponse](#applicationresponse) is set.
1529
+ It is not sent to the application.
1530
+
1531
+ ##### messageIndex?
1532
+
1533
+ ```ts
1534
+ optional messageIndex: number;
1535
+ ```
1536
+
1537
+ The index of the [ApplicationMessage](#applicationmessage) associated with this choice.
1538
+ Setting this ensures that local state's `selectedChoiceId` on the corresponding [ApplicationResponse](#applicationresponse) is set.
1539
+ It is not sent to the application.
1540
+
1541
+ ##### nodeId?
1542
+
1543
+ ```ts
1544
+ optional nodeId: string;
1545
+ ```
1546
+
1547
+ Required if you want to change a choice that's already been sent.
1548
+ The `nodeId` can be found in the corresponding [ApplicationMessage](#applicationmessage).
1549
+
1550
+ ##### intentId?
1551
+
1552
+ ```ts
1553
+ optional intentId: string;
1554
+ ```
1555
+
1556
+ Intent ID, used for sending to the NLU to allow it to double-check
1557
+
1558
+ ---
1559
+
1560
+ ### VoicePlusMessage
1561
+
1562
+ Messages sent to the Voice+ socket
1563
+
1564
+ #### Properties
1565
+
1566
+ ##### context
1567
+
1568
+ ```ts
1569
+ context: any;
1570
+ ```
1571
+
1572
+ Voice+ context
1573
+
1574
+ ---
1575
+
1576
+ ### EventHandlers
1577
+
1578
+ Dictionary of handler methods per event
1579
+
1580
+ #### Properties
1581
+
1582
+ ##### voicePlusCommand
1583
+
1584
+ ```ts
1585
+ voicePlusCommand: VoicePlusCommandListener;
1586
+ ```
1587
+
1588
+ Voice+ command event handler
1589
+
1590
+ ##### interimMessage
1591
+
1592
+ ```ts
1593
+ interimMessage: InterimMessageListener;
1594
+ ```
1595
+
1596
+ Interim message event handler
1597
+
1598
+ ## Enumerations
1599
+
1600
+ ### ResponseType
1601
+
1602
+ Response type
1603
+
1604
+ #### Enumeration Members
1605
+
1606
+ ##### Application
1607
+
1608
+ ```ts
1609
+ Application: "bot";
1610
+ ```
1611
+
1612
+ Response from the application
1613
+
1614
+ ##### User
1615
+
1616
+ ```ts
1617
+ User: "user";
1618
+ ```
1619
+
1620
+ Response from the user
1621
+
1622
+ ##### Failure
1623
+
1624
+ ```ts
1625
+ Failure: "failure";
1626
+ ```
1627
+
1628
+ Generic failure (cannot be attributed to the application)
1629
+
1630
+ ## Events
1631
+
1632
+ ### ConversationHandlerEvent
1633
+
1634
+ ```ts
1635
+ type ConversationHandlerEvent = "voicePlusCommand" | "interimMessage";
1636
+ ```
1637
+
1638
+ Handler events
1639
+ voicePlusCommand
1640
+
1641
+ ## Type Aliases
1642
+
1643
+ ### Context
1644
+
1645
+ ```ts
1646
+ type Context = Record<string, any>;
1647
+ ```
1648
+
1649
+ [Context](https://docs.studio.nlx.ai/workspacesettings/documentation-settings/settings-context-attributes) for usage later in the intent.
1650
+
1651
+ ---
1652
+
1653
+ ### SlotsRecord
1654
+
1655
+ ```ts
1656
+ type SlotsRecord = Record<string, any>;
1657
+ ```
1658
+
1659
+ Values to fill an intent's [attached slots](https://docs.studio.nlx.ai/intents/documentation-intents/intents-attached-slots).
1660
+
1661
+ `SlotRecord` Keys are the attached slot's name
1662
+
1663
+ `SlotRecord` Values are usually a discrete value matching the slots's [type](https://docs.studio.nlx.ai/slots/documentation-slots/slots-values#system-slots).
1664
+ for custom slots, this can optionally be the value's ID.
1665
+
1666
+ A `SlotsRecord` is equivalent to an array of [SlotValue](#slotvalue) objects.
1667
+
1668
+ ---
1669
+
1670
+ ### SlotsRecordOrArray
1671
+
1672
+ ```ts
1673
+ type SlotsRecordOrArray = SlotsRecord | SlotValue[];
1674
+ ```
1675
+
1676
+ Values to fill an intent's [attached slots](https://docs.studio.nlx.ai/intents/documentation-intents/intents-attached-slots).
1677
+
1678
+ Supports either a [SlotsRecord](#slotsrecord) or an array of [SlotValue](#slotvalue) objects
1679
+
1680
+ ---
1681
+
1682
+ ### ModalityPayloads
1683
+
1684
+ ```ts
1685
+ type ModalityPayloads = Record<string, any>;
1686
+ ```
1687
+
1688
+ Payloads for modalities as a key-value pair by modality name
1689
+
1690
+ ---
1691
+
1692
+ ### UserResponsePayload
1693
+
1694
+ ```ts
1695
+ type UserResponsePayload =
1696
+ | {
1697
+ type: "text";
1698
+ text: string;
1699
+ context?: Context;
1700
+ }
1701
+ | {
1702
+ type: "choice";
1703
+ choiceId: string;
1704
+ context?: Context;
1705
+ }
1706
+ | (object & StructuredRequest);
1707
+ ```
1708
+
1709
+ The payload of the user response
1710
+
1711
+ #### Type Declaration
1712
+
1713
+ ```ts
1714
+ {
1715
+ type: "text";
1716
+ text: string;
1717
+ context?: Context;
1718
+ }
1719
+ ```
1720
+
1721
+ ##### type
1722
+
1723
+ ```ts
1724
+ type: "text";
1725
+ ```
1726
+
1727
+ Set when `sendText` is called.
1728
+
1729
+ ##### text
1730
+
1731
+ ```ts
1732
+ text: string;
1733
+ ```
1734
+
1735
+ The user's message
1736
+
1737
+ ##### context?
1738
+
1739
+ ```ts
1740
+ optional context: Context;
1741
+ ```
1742
+
1743
+ [Context](https://docs.studio.nlx.ai/workspacesettings/documentation-settings/settings-context-attributes) for usage later in the intent.
1744
+
1745
+ ```ts
1746
+ {
1747
+ type: "choice";
1748
+ choiceId: string;
1749
+ context?: Context;
1750
+ }
1751
+ ```
1752
+
1753
+ ##### type
1754
+
1755
+ ```ts
1756
+ type: "choice";
1757
+ ```
1758
+
1759
+ Set when `sendChoice` is called.
1760
+
1761
+ ##### choiceId
1762
+
1763
+ ```ts
1764
+ choiceId: string;
1765
+ ```
1766
+
1767
+ The `choiceId` passed to `sendChoice`
1768
+ Correlates to a `choiceId` in the [ApplicationResponse](#applicationresponse)'s `.payload.messages[].choices[].choiceId` fields
1769
+
1770
+ ##### context?
1771
+
1772
+ ```ts
1773
+ optional context: Context;
1774
+ ```
1775
+
1776
+ [Context](https://docs.studio.nlx.ai/workspacesettings/documentation-settings/settings-context-attributes) for usage later in the intent.
1777
+
1778
+ `object` & [`StructuredRequest`](#structuredrequest)
1779
+
1780
+ ---
1781
+
1782
+ ### Response
1783
+
1784
+ ```ts
1785
+ type Response = ApplicationResponse | UserResponse | FailureMessage;
1786
+ ```
1787
+
1788
+ A response from the application or the user.
1789
+
1790
+ ---
1791
+
1792
+ ### Time
1793
+
1794
+ ```ts
1795
+ type Time = number;
1796
+ ```
1797
+
1798
+ The time value in milliseconds since midnight, January 1, 1970 UTC.
1799
+
1800
+ ---
1801
+
1802
+ ### NormalizedStructuredRequest
1803
+
1804
+ ```ts
1805
+ type NormalizedStructuredRequest = StructuredRequest & object;
1806
+ ```
1807
+
1808
+ Normalized structured request with a single way to represent slots
1809
+
1810
+ #### Type Declaration
1811
+
1812
+ ##### slots?
1813
+
1814
+ ```ts
1815
+ optional slots: SlotValue[];
1816
+ ```
1817
+
1818
+ Only array-form slots are allowed for the purposes of sending to the backend
1819
+
1820
+ ---
1821
+
1822
+ ### LanguageCode
1823
+
1824
+ ```ts
1825
+ type LanguageCode = string;
1826
+ ```
1827
+
1828
+ Language code named for clarity, may restrict it to a finite list
1829
+
1830
+ ---
1831
+
1832
+ ### RequestOverride()
1833
+
1834
+ ```ts
1835
+ type RequestOverride = (applicationRequest, appendResponse) => void;
1836
+ ```
1837
+
1838
+ Instead of sending a request to the application, handle it in a custom fashion
1839
+
1840
+ #### Parameters
1841
+
1842
+ ##### applicationRequest
1843
+
1844
+ [`ApplicationRequest`](#applicationrequest)
1845
+
1846
+ The [ApplicationRequest](#applicationrequest) that is being overridden
1847
+
1848
+ ##### appendResponse
1849
+
1850
+ (`res`) => `void`
1851
+
1852
+ A method to append the [ApplicationResponsePayload](#applicationresponsepayload-1) to the message history
1853
+
1854
+ #### Returns
1855
+
1856
+ `void`
1857
+
1858
+ ---
1859
+
1860
+ ### VoicePlusContext
1861
+
1862
+ ```ts
1863
+ type VoicePlusContext = any;
1864
+ ```
1865
+
1866
+ Voice+ context, type to be defined
1867
+
1868
+ ---
1869
+
1870
+ ### VoicePlusCommandListener()
1871
+
1872
+ ```ts
1873
+ type VoicePlusCommandListener = (payload) => void;
1874
+ ```
1875
+
1876
+ Voice+ command listener
1877
+
1878
+ #### Parameters
1879
+
1880
+ ##### payload
1881
+
1882
+ `any`
1883
+
1884
+ #### Returns
1885
+
1886
+ `void`
1887
+
1888
+ ---
1889
+
1890
+ ### InterimMessageListener()
1891
+
1892
+ ```ts
1893
+ type InterimMessageListener = (message?) => void;
1894
+ ```
1895
+
1896
+ Interim message listener
1897
+
1898
+ #### Parameters
1899
+
1900
+ ##### message?
1901
+
1902
+ `string`
1903
+
1904
+ #### Returns
1905
+
1906
+ `void`
1907
+
1908
+ ---
1909
+
1910
+ ### Subscriber()
1911
+
1912
+ ```ts
1913
+ type Subscriber = (response, newResponse?) => void;
1914
+ ```
1915
+
1916
+ The callback function for listening to all responses.
1917
+
1918
+ #### Parameters
1919
+
1920
+ ##### response
1921
+
1922
+ [`Response`](#response)[]
1923
+
1924
+ ##### newResponse?
1925
+
1926
+ [`Response`](#response)
1927
+
1928
+ #### Returns
1929
+
1930
+ `void`