@nlxai/core 1.2.4-alpha.1 → 1.2.4-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.
package/docs/README.md ADDED
@@ -0,0 +1,1922 @@
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
+ ---
1322
+
1323
+ ### StructuredRequest
1324
+
1325
+ The body of `sendStructured`
1326
+ Includes a combination of choice, slots, and intent in one request.
1327
+
1328
+ #### Properties
1329
+
1330
+ ##### choiceId?
1331
+
1332
+ ```ts
1333
+ optional choiceId: string;
1334
+ ```
1335
+
1336
+ The `choiceId` is in the [ApplicationResponse](#applicationresponse)'s `.payload.messages[].choices[].choiceId` fields
1337
+
1338
+ ##### nodeId?
1339
+
1340
+ ```ts
1341
+ optional nodeId: string;
1342
+ ```
1343
+
1344
+ Required if you want to change a choice that's already been sent.
1345
+ The `nodeId` can be found in the corresponding [ApplicationMessage](#applicationmessage).
1346
+
1347
+ ##### ~~intentId?~~
1348
+
1349
+ ```ts
1350
+ optional intentId: string;
1351
+ ```
1352
+
1353
+ The intent to trigger. The `intentId` is the name under the application's _Intents_.
1354
+
1355
+ ###### Deprecated
1356
+
1357
+ use `flowId` instead.
1358
+
1359
+ ##### flowId?
1360
+
1361
+ ```ts
1362
+ optional flowId: string;
1363
+ ```
1364
+
1365
+ The flow to trigger. The `flowId` is the name under the application's _Flows_.
1366
+
1367
+ ##### slots?
1368
+
1369
+ ```ts
1370
+ optional slots: SlotsRecordOrArray;
1371
+ ```
1372
+
1373
+ The slots to populate
1374
+
1375
+ ##### uploadIds?
1376
+
1377
+ ```ts
1378
+ optional uploadIds: string[];
1379
+ ```
1380
+
1381
+ Upload ID
1382
+
1383
+ ##### utterance?
1384
+
1385
+ ```ts
1386
+ optional utterance: string;
1387
+ ```
1388
+
1389
+ Upload utterance
1390
+
1391
+ ---
1392
+
1393
+ ### ApplicationRequest
1394
+
1395
+ The request data actually sent to the application, slightly different from [UserResponsePayload](#userresponsepayload-1), which includes some UI-specific information
1396
+
1397
+ #### Properties
1398
+
1399
+ ##### conversationId?
1400
+
1401
+ ```ts
1402
+ optional conversationId: string;
1403
+ ```
1404
+
1405
+ The current conversation ID
1406
+
1407
+ ##### userId?
1408
+
1409
+ ```ts
1410
+ optional userId: string;
1411
+ ```
1412
+
1413
+ The current user ID
1414
+
1415
+ ##### context?
1416
+
1417
+ ```ts
1418
+ optional context: Context;
1419
+ ```
1420
+
1421
+ Request context, if applicable
1422
+
1423
+ ##### request
1424
+
1425
+ ```ts
1426
+ request: object;
1427
+ ```
1428
+
1429
+ Main request
1430
+
1431
+ ###### unstructured?
1432
+
1433
+ ```ts
1434
+ optional unstructured: object;
1435
+ ```
1436
+
1437
+ Unstructured request
1438
+
1439
+ ###### unstructured.text
1440
+
1441
+ ```ts
1442
+ text: string;
1443
+ ```
1444
+
1445
+ Request body text
1446
+
1447
+ ###### structured?
1448
+
1449
+ ```ts
1450
+ optional structured: StructuredRequest & object;
1451
+ ```
1452
+
1453
+ Structured request
1454
+
1455
+ ###### Type Declaration
1456
+
1457
+ ###### slots?
1458
+
1459
+ ```ts
1460
+ optional slots: SlotValue[];
1461
+ ```
1462
+
1463
+ Only array-form slots are allowed for the purposes of sending to the backend
1464
+
1465
+ ---
1466
+
1467
+ ### VoiceCredentials
1468
+
1469
+ Credentials to connect to a Voice channel
1470
+
1471
+ #### Properties
1472
+
1473
+ ##### url
1474
+
1475
+ ```ts
1476
+ url: string;
1477
+ ```
1478
+
1479
+ Voice Connection URL
1480
+
1481
+ ##### roomName
1482
+
1483
+ ```ts
1484
+ roomName: string;
1485
+ ```
1486
+
1487
+ Voice room name
1488
+
1489
+ ##### token
1490
+
1491
+ ```ts
1492
+ token: string;
1493
+ ```
1494
+
1495
+ Voice token
1496
+
1497
+ ##### participantName
1498
+
1499
+ ```ts
1500
+ participantName: string;
1501
+ ```
1502
+
1503
+ Voice participant name
1504
+
1505
+ ---
1506
+
1507
+ ### ChoiceRequestMetadata
1508
+
1509
+ Helps link the choice to the specific message in the conversation.
1510
+
1511
+ #### Properties
1512
+
1513
+ ##### responseIndex?
1514
+
1515
+ ```ts
1516
+ optional responseIndex: number;
1517
+ ```
1518
+
1519
+ The index of the [Response](#response) associated with this choice.
1520
+ Setting this ensures that local state's `selectedChoiceId` on the corresponding [ApplicationResponse](#applicationresponse) is set.
1521
+ It is not sent to the application.
1522
+
1523
+ ##### messageIndex?
1524
+
1525
+ ```ts
1526
+ optional messageIndex: number;
1527
+ ```
1528
+
1529
+ The index of the [ApplicationMessage](#applicationmessage) associated with this choice.
1530
+ Setting this ensures that local state's `selectedChoiceId` on the corresponding [ApplicationResponse](#applicationresponse) is set.
1531
+ It is not sent to the application.
1532
+
1533
+ ##### nodeId?
1534
+
1535
+ ```ts
1536
+ optional nodeId: string;
1537
+ ```
1538
+
1539
+ Required if you want to change a choice that's already been sent.
1540
+ The `nodeId` can be found in the corresponding [ApplicationMessage](#applicationmessage).
1541
+
1542
+ ##### intentId?
1543
+
1544
+ ```ts
1545
+ optional intentId: string;
1546
+ ```
1547
+
1548
+ Intent ID, used for sending to the NLU to allow it to double-check
1549
+
1550
+ ---
1551
+
1552
+ ### VoicePlusMessage
1553
+
1554
+ Messages sent to the Voice+ socket
1555
+
1556
+ #### Properties
1557
+
1558
+ ##### context
1559
+
1560
+ ```ts
1561
+ context: any;
1562
+ ```
1563
+
1564
+ Voice+ context
1565
+
1566
+ ---
1567
+
1568
+ ### EventHandlers
1569
+
1570
+ Dictionary of handler methods per event
1571
+
1572
+ #### Properties
1573
+
1574
+ ##### voicePlusCommand
1575
+
1576
+ ```ts
1577
+ voicePlusCommand: VoicePlusCommandListener;
1578
+ ```
1579
+
1580
+ Voice+ command event handler
1581
+
1582
+ ##### interimMessage
1583
+
1584
+ ```ts
1585
+ interimMessage: InterimMessageListener;
1586
+ ```
1587
+
1588
+ Interim message event handler
1589
+
1590
+ ## Enumerations
1591
+
1592
+ ### ResponseType
1593
+
1594
+ Response type
1595
+
1596
+ #### Enumeration Members
1597
+
1598
+ ##### Application
1599
+
1600
+ ```ts
1601
+ Application: "bot";
1602
+ ```
1603
+
1604
+ Response from the application
1605
+
1606
+ ##### User
1607
+
1608
+ ```ts
1609
+ User: "user";
1610
+ ```
1611
+
1612
+ Response from the user
1613
+
1614
+ ##### Failure
1615
+
1616
+ ```ts
1617
+ Failure: "failure";
1618
+ ```
1619
+
1620
+ Generic failure (cannot be attributed to the application)
1621
+
1622
+ ## Events
1623
+
1624
+ ### ConversationHandlerEvent
1625
+
1626
+ ```ts
1627
+ type ConversationHandlerEvent = "voicePlusCommand" | "interimMessage";
1628
+ ```
1629
+
1630
+ Handler events
1631
+ voicePlusCommand
1632
+
1633
+ ## Type Aliases
1634
+
1635
+ ### Context
1636
+
1637
+ ```ts
1638
+ type Context = Record<string, any>;
1639
+ ```
1640
+
1641
+ [Context](https://docs.studio.nlx.ai/workspacesettings/documentation-settings/settings-context-attributes) for usage later in the intent.
1642
+
1643
+ ---
1644
+
1645
+ ### SlotsRecord
1646
+
1647
+ ```ts
1648
+ type SlotsRecord = Record<string, any>;
1649
+ ```
1650
+
1651
+ Values to fill an intent's [attached slots](https://docs.studio.nlx.ai/intents/documentation-intents/intents-attached-slots).
1652
+
1653
+ `SlotRecord` Keys are the attached slot's name
1654
+
1655
+ `SlotRecord` Values are usually a discrete value matching the slots's [type](https://docs.studio.nlx.ai/slots/documentation-slots/slots-values#system-slots).
1656
+ for custom slots, this can optionally be the value's ID.
1657
+
1658
+ A `SlotsRecord` is equivalent to an array of [SlotValue](#slotvalue) objects.
1659
+
1660
+ ---
1661
+
1662
+ ### SlotsRecordOrArray
1663
+
1664
+ ```ts
1665
+ type SlotsRecordOrArray = SlotsRecord | SlotValue[];
1666
+ ```
1667
+
1668
+ Values to fill an intent's [attached slots](https://docs.studio.nlx.ai/intents/documentation-intents/intents-attached-slots).
1669
+
1670
+ Supports either a [SlotsRecord](#slotsrecord) or an array of [SlotValue](#slotvalue) objects
1671
+
1672
+ ---
1673
+
1674
+ ### ModalityPayloads
1675
+
1676
+ ```ts
1677
+ type ModalityPayloads = Record<string, any>;
1678
+ ```
1679
+
1680
+ Payloads for modalities as a key-value pair by modality name
1681
+
1682
+ ---
1683
+
1684
+ ### UserResponsePayload
1685
+
1686
+ ```ts
1687
+ type UserResponsePayload =
1688
+ | {
1689
+ type: "text";
1690
+ text: string;
1691
+ context?: Context;
1692
+ }
1693
+ | {
1694
+ type: "choice";
1695
+ choiceId: string;
1696
+ context?: Context;
1697
+ }
1698
+ | (object & StructuredRequest);
1699
+ ```
1700
+
1701
+ The payload of the user response
1702
+
1703
+ #### Type Declaration
1704
+
1705
+ ```ts
1706
+ {
1707
+ type: "text";
1708
+ text: string;
1709
+ context?: Context;
1710
+ }
1711
+ ```
1712
+
1713
+ ##### type
1714
+
1715
+ ```ts
1716
+ type: "text";
1717
+ ```
1718
+
1719
+ Set when `sendText` is called.
1720
+
1721
+ ##### text
1722
+
1723
+ ```ts
1724
+ text: string;
1725
+ ```
1726
+
1727
+ The user's message
1728
+
1729
+ ##### context?
1730
+
1731
+ ```ts
1732
+ optional context: Context;
1733
+ ```
1734
+
1735
+ [Context](https://docs.studio.nlx.ai/workspacesettings/documentation-settings/settings-context-attributes) for usage later in the intent.
1736
+
1737
+ ```ts
1738
+ {
1739
+ type: "choice";
1740
+ choiceId: string;
1741
+ context?: Context;
1742
+ }
1743
+ ```
1744
+
1745
+ ##### type
1746
+
1747
+ ```ts
1748
+ type: "choice";
1749
+ ```
1750
+
1751
+ Set when `sendChoice` is called.
1752
+
1753
+ ##### choiceId
1754
+
1755
+ ```ts
1756
+ choiceId: string;
1757
+ ```
1758
+
1759
+ The `choiceId` passed to `sendChoice`
1760
+ Correlates to a `choiceId` in the [ApplicationResponse](#applicationresponse)'s `.payload.messages[].choices[].choiceId` fields
1761
+
1762
+ ##### context?
1763
+
1764
+ ```ts
1765
+ optional context: Context;
1766
+ ```
1767
+
1768
+ [Context](https://docs.studio.nlx.ai/workspacesettings/documentation-settings/settings-context-attributes) for usage later in the intent.
1769
+
1770
+ `object` & [`StructuredRequest`](#structuredrequest)
1771
+
1772
+ ---
1773
+
1774
+ ### Response
1775
+
1776
+ ```ts
1777
+ type Response = ApplicationResponse | UserResponse | FailureMessage;
1778
+ ```
1779
+
1780
+ A response from the application or the user.
1781
+
1782
+ ---
1783
+
1784
+ ### Time
1785
+
1786
+ ```ts
1787
+ type Time = number;
1788
+ ```
1789
+
1790
+ The time value in milliseconds since midnight, January 1, 1970 UTC.
1791
+
1792
+ ---
1793
+
1794
+ ### NormalizedStructuredRequest
1795
+
1796
+ ```ts
1797
+ type NormalizedStructuredRequest = StructuredRequest & object;
1798
+ ```
1799
+
1800
+ Normalized structured request with a single way to represent slots
1801
+
1802
+ #### Type Declaration
1803
+
1804
+ ##### slots?
1805
+
1806
+ ```ts
1807
+ optional slots: SlotValue[];
1808
+ ```
1809
+
1810
+ Only array-form slots are allowed for the purposes of sending to the backend
1811
+
1812
+ ---
1813
+
1814
+ ### LanguageCode
1815
+
1816
+ ```ts
1817
+ type LanguageCode = string;
1818
+ ```
1819
+
1820
+ Language code named for clarity, may restrict it to a finite list
1821
+
1822
+ ---
1823
+
1824
+ ### RequestOverride()
1825
+
1826
+ ```ts
1827
+ type RequestOverride = (applicationRequest, appendResponse) => void;
1828
+ ```
1829
+
1830
+ Instead of sending a request to the application, handle it in a custom fashion
1831
+
1832
+ #### Parameters
1833
+
1834
+ ##### applicationRequest
1835
+
1836
+ [`ApplicationRequest`](#applicationrequest)
1837
+
1838
+ The [ApplicationRequest](#applicationrequest) that is being overridden
1839
+
1840
+ ##### appendResponse
1841
+
1842
+ (`res`) => `void`
1843
+
1844
+ A method to append the [ApplicationResponsePayload](#applicationresponsepayload-1) to the message history
1845
+
1846
+ #### Returns
1847
+
1848
+ `void`
1849
+
1850
+ ---
1851
+
1852
+ ### VoicePlusContext
1853
+
1854
+ ```ts
1855
+ type VoicePlusContext = any;
1856
+ ```
1857
+
1858
+ Voice+ context, type to be defined
1859
+
1860
+ ---
1861
+
1862
+ ### VoicePlusCommandListener()
1863
+
1864
+ ```ts
1865
+ type VoicePlusCommandListener = (payload) => void;
1866
+ ```
1867
+
1868
+ Voice+ command listener
1869
+
1870
+ #### Parameters
1871
+
1872
+ ##### payload
1873
+
1874
+ `any`
1875
+
1876
+ #### Returns
1877
+
1878
+ `void`
1879
+
1880
+ ---
1881
+
1882
+ ### InterimMessageListener()
1883
+
1884
+ ```ts
1885
+ type InterimMessageListener = (message?) => void;
1886
+ ```
1887
+
1888
+ Interim message listener
1889
+
1890
+ #### Parameters
1891
+
1892
+ ##### message?
1893
+
1894
+ `string`
1895
+
1896
+ #### Returns
1897
+
1898
+ `void`
1899
+
1900
+ ---
1901
+
1902
+ ### Subscriber()
1903
+
1904
+ ```ts
1905
+ type Subscriber = (response, newResponse?) => void;
1906
+ ```
1907
+
1908
+ The callback function for listening to all responses.
1909
+
1910
+ #### Parameters
1911
+
1912
+ ##### response
1913
+
1914
+ [`Response`](#response)[]
1915
+
1916
+ ##### newResponse?
1917
+
1918
+ [`Response`](#response)
1919
+
1920
+ #### Returns
1921
+
1922
+ `void`