@nlxai/core 1.2.7-alpha.2 → 1.2.7-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,2247 @@
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
+ (`payload`) => `Promise`\<[`Response`](#response) \| `null`\>
190
+
191
+ #### Example
192
+
193
+ ```typescript
194
+ import { createConversation, promisify } from "@nlxai/core";
195
+
196
+ const convo = createConversation(config);
197
+
198
+ const sendTextWrapped = promisify(convo.sendText, convo);
199
+
200
+ sendTextWrapped("Hello").then((response) => {
201
+ console.log(response);
202
+ });
203
+ ```
204
+
205
+ ---
206
+
207
+ ### sendVoicePlusStep()
208
+
209
+ ```ts
210
+ function sendVoicePlusStep(configuration): Promise<void>;
211
+ ```
212
+
213
+ Use this function when using **Voice+ scripts** to advance the conversation to the step specified.
214
+
215
+ This functionality is orthogonal from other usage of the core SDK, as it may be used either using standard SDK communication channels or it can be used to provide a Voice+ script experience with for instance a telephony based channel.
216
+
217
+ #### Parameters
218
+
219
+ ##### configuration
220
+
221
+ Configuration for sending the step. Many of the values can be found on the deployment modal of the Voice+ script.
222
+
223
+ ###### apiKey
224
+
225
+ `string`
226
+
227
+ - the API key generated for the Voice+ script. Note that this value is different from the API key you would pass to [createConversation](#createconversation). You can control the API key on the Voice+ script settings page.
228
+
229
+ ###### scriptId?
230
+
231
+ `string`
232
+
233
+ The ID of the Voice+ script.
234
+
235
+ ###### workspaceId
236
+
237
+ `string`
238
+
239
+ Your workspace ID.
240
+
241
+ ###### conversationId
242
+
243
+ `string`
244
+
245
+ The active conversation ID, passed from the active NLX voice application. This is what ties the script exectution to the specific Voice application.
246
+
247
+ _Note: This must be dynamically set by the voice application._ Normally, when the voice application directs the user to the webpage running this code, it will include the conversation ID as a URL parameter which you can extract and pass here.
248
+
249
+ **Example**
250
+
251
+ ```typescript
252
+ const conversationId = new URLSearchParams(window.location.search).get("cid");
253
+ ```
254
+
255
+ ###### languageCode
256
+
257
+ `string`
258
+
259
+ The user's language code, consistent with the language codes defined on the Voice+ script.
260
+
261
+ ###### step
262
+
263
+ [`StepInfo`](#stepinfo)
264
+
265
+ Which step to send.
266
+
267
+ ###### context
268
+
269
+ [`Context`](#context)
270
+
271
+ Any context.
272
+
273
+ ###### debug?
274
+
275
+ `boolean` = `false`
276
+
277
+ Set to `true` to help debug issues or errors. Defaults to `false`.
278
+
279
+ #### Returns
280
+
281
+ `Promise`\<`void`\>
282
+
283
+ #### Example
284
+
285
+ ```typescript
286
+ import { sendVoicePlusStep } from "@nlxai/core";
287
+
288
+ await sendVoicePlusStep({
289
+ // hard-coded params
290
+ apiKey: "REPLACE_WITH_API_KEY",
291
+ workspaceId: "REPLACE_WITH_WORKSPACE_ID",
292
+ scriptId: "REPLACE_WITH_SCRIPT_ID",
293
+ step: "REPLACE_WITH_STEP_ID",
294
+ // dynamic params
295
+ conversationId: "REPLACE_WITH_CONVERSATION_ID",
296
+ languageCode: "en-US",
297
+ });
298
+ ```
299
+
300
+ ## Variables
301
+
302
+ ### version
303
+
304
+ ```ts
305
+ const version: string = packageJson.version;
306
+ ```
307
+
308
+ Package version
309
+
310
+ ## Interfaces
311
+
312
+ ### Config
313
+
314
+ The configuration necessary to create a conversation.
315
+
316
+ #### Properties
317
+
318
+ ##### applicationUrl?
319
+
320
+ ```ts
321
+ optional applicationUrl?: string;
322
+ ```
323
+
324
+ The URL at which your conversational application is running. Fetch this from the application's API channel tab.
325
+ Currently, there are a few ways to specify the application URL:
326
+
327
+ - (recommended) leave out `applicationUrl` and specify `protocol`, `host`, `deploymentKey` and `channelKey`.
328
+ - specify the full `applicationUrl` as well as the `protocol`.
329
+ - (legacy) specify the `applicationUrl` generated either as an HTTP or websocket URL. Use `experimental.streamHttp` to control streaming.
330
+
331
+ ##### protocol?
332
+
333
+ ```ts
334
+ optional protocol?: Protocol;
335
+ ```
336
+
337
+ Specify the protocol (http, websocket or httpWithStreaming)
338
+
339
+ ##### host?
340
+
341
+ ```ts
342
+ optional host?: string;
343
+ ```
344
+
345
+ Hostname of the application deployment, without a leading `https://`.
346
+
347
+ ##### deploymentKey?
348
+
349
+ ```ts
350
+ optional deploymentKey?: string;
351
+ ```
352
+
353
+ Deployment key.
354
+
355
+ ##### channelKey?
356
+
357
+ ```ts
358
+ optional channelKey?: string;
359
+ ```
360
+
361
+ Channel key.
362
+
363
+ ##### apiKey?
364
+
365
+ ```ts
366
+ optional apiKey?: string;
367
+ ```
368
+
369
+ API key.
370
+
371
+ ##### headers?
372
+
373
+ ```ts
374
+ optional headers?: Record<string, string>;
375
+ ```
376
+
377
+ Headers to forward to the NLX API.
378
+
379
+ ##### conversationId?
380
+
381
+ ```ts
382
+ optional conversationId?: string;
383
+ ```
384
+
385
+ Set `conversationId` to continue an existing conversation. If not set, a new conversation will be started (and a new conversationId will be generated internally).
386
+
387
+ ##### userId?
388
+
389
+ ```ts
390
+ optional userId?: string;
391
+ ```
392
+
393
+ Setting the `userID` allows it to be searchable in application history, as well as usable via `{System.userId}` in the flow.
394
+
395
+ ##### responses?
396
+
397
+ ```ts
398
+ optional responses?: Response[];
399
+ ```
400
+
401
+ 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.
402
+
403
+ ##### failureMessage?
404
+
405
+ ```ts
406
+ optional failureMessage?: string;
407
+ ```
408
+
409
+ When set, this overrides the default failure message ("We encountered an issue. Please try again soon.").
410
+
411
+ ##### languageCode
412
+
413
+ ```ts
414
+ languageCode: string;
415
+ ```
416
+
417
+ The language code to use for the application. In the browser this can be fetched with `navigator.language`.
418
+ If you don't have translations, hard-code this to the language code you support.
419
+
420
+ ##### bidirectional?
421
+
422
+ ```ts
423
+ optional bidirectional?: boolean;
424
+ ```
425
+
426
+ Specifies whether the conversation is using bidirectional Voice+ (if so, an additional command socket will be opened).
427
+
428
+ ---
429
+
430
+ ### ConversationHandler
431
+
432
+ A bundle of functions to interact with a conversation, created by [createConversation](#createconversation).
433
+
434
+ #### Properties
435
+
436
+ ##### sendText
437
+
438
+ ```ts
439
+ sendText: (text, context?) => void;
440
+ ```
441
+
442
+ Send user's message
443
+
444
+ ###### Parameters
445
+
446
+ ###### text
447
+
448
+ `string`
449
+
450
+ the user's message
451
+
452
+ ###### context?
453
+
454
+ [`Context`](#context)
455
+
456
+ [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.
457
+
458
+ ###### Returns
459
+
460
+ `void`
461
+
462
+ ##### sendSlots
463
+
464
+ ```ts
465
+ sendSlots: (slots, context?) => void;
466
+ ```
467
+
468
+ Send [slots](https://docs.nlx.ai/platform/nlx-platform-guide/build-with-nlx/flows/slots-custom#slot-settings) to the application.
469
+
470
+ ###### Parameters
471
+
472
+ ###### slots
473
+
474
+ [`SlotsRecordOrArray`](#slotsrecordorarray)
475
+
476
+ The slots to populate
477
+
478
+ ###### context?
479
+
480
+ [`Context`](#context)
481
+
482
+ [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.
483
+
484
+ ###### Returns
485
+
486
+ `void`
487
+
488
+ ##### sendChoice
489
+
490
+ ```ts
491
+ sendChoice: (choiceId, context?, metadata?) => void;
492
+ ```
493
+
494
+ Respond to [a choice](https://docs.nlx.ai/platform/nlx-platform-guide/flows-and-building-blocks/overview/nodes#user-choice) from the application.
495
+
496
+ ###### Parameters
497
+
498
+ ###### choiceId
499
+
500
+ `string`
501
+
502
+ The `choiceId` is in the [ApplicationResponse](#applicationresponse)'s `.payload.messages[].choices[].choiceId` fields
503
+
504
+ ###### context?
505
+
506
+ [`Context`](#context)
507
+
508
+ [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.
509
+
510
+ ###### metadata?
511
+
512
+ [`ChoiceRequestMetadata`](#choicerequestmetadata)
513
+
514
+ links the choice to the specific message and node in the conversation.
515
+
516
+ ###### Returns
517
+
518
+ `void`
519
+
520
+ ##### sendWelcomeFlow
521
+
522
+ ```ts
523
+ sendWelcomeFlow: (context?) => void;
524
+ ```
525
+
526
+ Trigger the welcome flow. This should be done when the user starts interacting with the conversation.
527
+
528
+ ###### Parameters
529
+
530
+ ###### context?
531
+
532
+ [`Context`](#context)
533
+
534
+ [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.
535
+
536
+ ###### Returns
537
+
538
+ `void`
539
+
540
+ ##### sendFlow
541
+
542
+ ```ts
543
+ sendFlow: (flowId, context?) => void;
544
+ ```
545
+
546
+ Trigger a specific flow.
547
+
548
+ ###### Parameters
549
+
550
+ ###### flowId
551
+
552
+ `string`
553
+
554
+ the flow to trigger. The id is the name under the application's _Flows_.
555
+
556
+ ###### context?
557
+
558
+ [`Context`](#context)
559
+
560
+ [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.
561
+
562
+ ###### Returns
563
+
564
+ `void`
565
+
566
+ ##### sendContext
567
+
568
+ ```ts
569
+ sendContext: (context) => Promise<void>;
570
+ ```
571
+
572
+ Send context without sending a message
573
+
574
+ ###### Parameters
575
+
576
+ ###### context
577
+
578
+ [`Context`](#context)
579
+
580
+ [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.
581
+
582
+ ###### Returns
583
+
584
+ `Promise`\<`void`\>
585
+
586
+ ##### appendMessageToTranscript
587
+
588
+ ```ts
589
+ appendMessageToTranscript: (response) => void;
590
+ ```
591
+
592
+ Append messages manually to the transcript. This is an advanced feature that allows routing and aggregation of different chat message
593
+ sources.
594
+
595
+ ###### Parameters
596
+
597
+ ###### response
598
+
599
+ \| `Omit`\<[`ApplicationResponse`](#applicationresponse), `"receivedAt"`\> & `object`
600
+ \| `Omit`\<[`UserResponse`](#userresponse), `"receivedAt"`\> & `object`
601
+ \| `Omit`\<[`FailureMessage`](#failuremessage-1), `"receivedAt"`\> & `object`
602
+ \| `Omit`\<[`NoticeResponse`](#noticeresponse), `"receivedAt"`\> & `object`
603
+
604
+ the response with optional timestamps.
605
+
606
+ ###### Returns
607
+
608
+ `void`
609
+
610
+ ##### sendStructured
611
+
612
+ ```ts
613
+ sendStructured: (request, context?) => void;
614
+ ```
615
+
616
+ Send a combination of choice, slots, and flow in one request.
617
+
618
+ ###### Parameters
619
+
620
+ ###### request
621
+
622
+ [`StructuredRequest`](#structuredrequest)
623
+
624
+ ###### context?
625
+
626
+ [`Context`](#context)
627
+
628
+ [Context](https://docs.nlx.ai/platform/nlx-platform-guide/flows-and-building-blocks/advanced/context-variables) for usage later in the flow.
629
+
630
+ ###### Returns
631
+
632
+ `void`
633
+
634
+ ##### submitFeedback
635
+
636
+ ```ts
637
+ submitFeedback: (url, feedback) => Promise<void>;
638
+ ```
639
+
640
+ Submit feedback about a response.
641
+
642
+ ###### Parameters
643
+
644
+ ###### url
645
+
646
+ `string`
647
+
648
+ The URL comming from the Application response `metadata.feedbackURL` field.
649
+
650
+ ###### feedback
651
+
652
+ Either a numerical rating or a textual comment.
653
+
654
+ ###### rating?
655
+
656
+ `number`
657
+
658
+ ###### comment?
659
+
660
+ `string`
661
+
662
+ ###### Returns
663
+
664
+ `Promise`\<`void`\>
665
+
666
+ ##### subscribe
667
+
668
+ ```ts
669
+ subscribe: (subscriber) => () => void;
670
+ ```
671
+
672
+ Subscribe a callback to the conversation. On subscribe, the subscriber will receive all of the Responses that the conversation has already received.
673
+
674
+ ###### Parameters
675
+
676
+ ###### subscriber
677
+
678
+ [`Subscriber`](#subscriber)
679
+
680
+ The callback to subscribe
681
+
682
+ ###### Returns
683
+
684
+ A function to unsubscribe the callback.
685
+
686
+ () => `void`
687
+
688
+ ##### unsubscribe
689
+
690
+ ```ts
691
+ unsubscribe: (subscriber) => void;
692
+ ```
693
+
694
+ Unsubscribe a callback from the conversation.
695
+
696
+ ###### Parameters
697
+
698
+ ###### subscriber
699
+
700
+ [`Subscriber`](#subscriber)
701
+
702
+ The callback to unsubscribe
703
+
704
+ ###### Returns
705
+
706
+ `void`
707
+
708
+ ##### unsubscribeAll
709
+
710
+ ```ts
711
+ unsubscribeAll: () => void;
712
+ ```
713
+
714
+ Unsubscribe all callback from the conversation.
715
+
716
+ ###### Returns
717
+
718
+ `void`
719
+
720
+ ##### currentConversationId
721
+
722
+ ```ts
723
+ currentConversationId: () => string | undefined;
724
+ ```
725
+
726
+ Get the current conversation ID if it's set, or undefined if there is no conversation.
727
+
728
+ ###### Returns
729
+
730
+ `string` \| `undefined`
731
+
732
+ ##### currentLanguageCode
733
+
734
+ ```ts
735
+ currentLanguageCode: () => string;
736
+ ```
737
+
738
+ Get the current language code
739
+
740
+ ###### Returns
741
+
742
+ `string`
743
+
744
+ ##### setLanguageCode
745
+
746
+ ```ts
747
+ setLanguageCode: (languageCode) => void;
748
+ ```
749
+
750
+ Set the language code
751
+
752
+ ###### Parameters
753
+
754
+ ###### languageCode
755
+
756
+ `string`
757
+
758
+ ###### Returns
759
+
760
+ `void`
761
+
762
+ ##### reset
763
+
764
+ ```ts
765
+ reset: (options?) => void;
766
+ ```
767
+
768
+ Forces a new conversation. If `clearResponses` is set to true, will also clear historical responses passed to subscribers.
769
+ Retains all existing subscribers.
770
+
771
+ ###### Parameters
772
+
773
+ ###### options?
774
+
775
+ ###### clearResponses?
776
+
777
+ `boolean`
778
+
779
+ If set to true, will clear historical responses passed to subscribers.
780
+
781
+ ###### Returns
782
+
783
+ `void`
784
+
785
+ ##### destroy
786
+
787
+ ```ts
788
+ destroy: () => void;
789
+ ```
790
+
791
+ Removes all subscribers and, if using websockets, closes the connection.
792
+
793
+ ###### Returns
794
+
795
+ `void`
796
+
797
+ ##### setRequestOverride
798
+
799
+ ```ts
800
+ setRequestOverride: (override) => void;
801
+ ```
802
+
803
+ Optional [RequestOverride](#requestoverride) function used to bypass the application request and handle them in a custom fashion
804
+
805
+ ###### Parameters
806
+
807
+ ###### override
808
+
809
+ [`RequestOverride`](#requestoverride) \| `undefined`
810
+
811
+ ###### Returns
812
+
813
+ `void`
814
+
815
+ ##### addEventListener
816
+
817
+ ```ts
818
+ addEventListener: (event, handler) => void;
819
+ ```
820
+
821
+ Add a listener to one of the handler's custom events
822
+
823
+ ###### Parameters
824
+
825
+ ###### event
826
+
827
+ [`ConversationHandlerEvent`](#conversationhandlerevent)
828
+
829
+ ###### handler
830
+
831
+ \| [`VoicePlusCommandListener`](#voicepluscommandlistener)
832
+ \| [`InterimMessageListener`](#interimmessagelistener)
833
+
834
+ ###### Returns
835
+
836
+ `void`
837
+
838
+ ##### removeEventListener
839
+
840
+ ```ts
841
+ removeEventListener: (event, handler) => void;
842
+ ```
843
+
844
+ Remove a listener to one of the handler's custom events
845
+
846
+ ###### Parameters
847
+
848
+ ###### event
849
+
850
+ [`ConversationHandlerEvent`](#conversationhandlerevent)
851
+
852
+ ###### handler
853
+
854
+ \| [`VoicePlusCommandListener`](#voicepluscommandlistener)
855
+ \| [`InterimMessageListener`](#interimmessagelistener)
856
+
857
+ ###### Returns
858
+
859
+ `void`
860
+
861
+ ##### setInterimMessage
862
+
863
+ ```ts
864
+ setInterimMessage: (message?) => void;
865
+ ```
866
+
867
+ Set interim message. Setting `undefined` clears the current interim message.
868
+
869
+ ###### Parameters
870
+
871
+ ###### message?
872
+
873
+ `string`
874
+
875
+ interim message.
876
+
877
+ ###### Returns
878
+
879
+ `void`
880
+
881
+ ---
882
+
883
+ ### SlotValue
884
+
885
+ Values to fill an flow's [attached slots](https://docs.nlx.ai/platform/nlx-platform-guide/flows-and-building-blocks/overview/setup#attached-slots).
886
+
887
+ An array of `SlotValue` objects is equivalent to a [SlotsRecord](#slotsrecord).
888
+
889
+ #### Properties
890
+
891
+ ##### slotId
892
+
893
+ ```ts
894
+ slotId: string;
895
+ ```
896
+
897
+ The attached slot's name
898
+
899
+ ##### value
900
+
901
+ ```ts
902
+ value: any;
903
+ ```
904
+
905
+ Usually this will be a discrete value matching the slots's [type](https://docs.nlx.ai/platform/nlx-platform-guide/flows-and-building-blocks/overview/setup#custom-vs-built-in-slots).
906
+ for custom slots, this can optionally be the value's ID.
907
+
908
+ ---
909
+
910
+ ### ApplicationResponse
911
+
912
+ A message from the application
913
+
914
+ See also:
915
+
916
+ - [UserResponse](#userresponse)
917
+ - [FailureMessage](#failuremessage-1)
918
+ - [FailureMessage](#failuremessage-1)
919
+ - [Response](#response)
920
+
921
+ #### Properties
922
+
923
+ ##### type
924
+
925
+ ```ts
926
+ type: Application;
927
+ ```
928
+
929
+ The application response type
930
+
931
+ ##### receivedAt
932
+
933
+ ```ts
934
+ receivedAt: number;
935
+ ```
936
+
937
+ When the response was received
938
+
939
+ ##### payload
940
+
941
+ ```ts
942
+ payload: ApplicationResponsePayload;
943
+ ```
944
+
945
+ The payload of the response
946
+
947
+ ---
948
+
949
+ ### ApplicationResponsePayload
950
+
951
+ The payload of the application response
952
+
953
+ #### Properties
954
+
955
+ ##### expirationTimestamp?
956
+
957
+ ```ts
958
+ optional expirationTimestamp?: number;
959
+ ```
960
+
961
+ If there isn't some interaction by this time, the conversation will expire.
962
+
963
+ ##### conversationId?
964
+
965
+ ```ts
966
+ optional conversationId?: string;
967
+ ```
968
+
969
+ The active conversation ID. If not set, a new conversation will be started.
970
+
971
+ ##### messages
972
+
973
+ ```ts
974
+ messages: ApplicationMessage[];
975
+ ```
976
+
977
+ Any messages from the application.
978
+
979
+ ##### metadata?
980
+
981
+ ```ts
982
+ optional metadata?: ApplicationResponseMetadata;
983
+ ```
984
+
985
+ Global state about the current conversation
986
+ as well as whether the client should poll for more application responses.
987
+
988
+ ##### payload?
989
+
990
+ ```ts
991
+ optional payload?: string;
992
+ ```
993
+
994
+ If configured, the [node's payload](https://docs.nlx.ai/platform/nlx-platform-guide/flows-and-building-blocks/overview/nodes#node-payload).
995
+
996
+ ##### modalities?
997
+
998
+ ```ts
999
+ optional modalities?: ModalityPayloads;
1000
+ ```
1001
+
1002
+ If configured, the node's modalities and their payloads.
1003
+
1004
+ ##### context?
1005
+
1006
+ ```ts
1007
+ optional context?: Context;
1008
+ ```
1009
+
1010
+ If the node is set to send context, the whole context associated with the conversation.
1011
+
1012
+ ---
1013
+
1014
+ ### ApplicationResponseMetadata
1015
+
1016
+ Global state about the current conversation
1017
+ as well as whether the client should poll for more application responses.
1018
+
1019
+ #### Properties
1020
+
1021
+ ##### intentId?
1022
+
1023
+ ```ts
1024
+ optional intentId?: string;
1025
+ ```
1026
+
1027
+ The conversation's flow ID (called `intentId` here for legacy reasons).
1028
+
1029
+ ##### escalation?
1030
+
1031
+ ```ts
1032
+ optional escalation?: boolean;
1033
+ ```
1034
+
1035
+ Whether the current conversation has been marked as incomprehension.
1036
+
1037
+ ##### frustration?
1038
+
1039
+ ```ts
1040
+ optional frustration?: boolean;
1041
+ ```
1042
+
1043
+ Whether the current conversation has been marked frustrated
1044
+
1045
+ ##### incomprehension?
1046
+
1047
+ ```ts
1048
+ optional incomprehension?: boolean;
1049
+ ```
1050
+
1051
+ Whether the current conversation has been marked as incomprehension.
1052
+
1053
+ ##### uploadUrls
1054
+
1055
+ ```ts
1056
+ uploadUrls: UploadUrl[];
1057
+ ```
1058
+
1059
+ Upload URL's
1060
+
1061
+ ##### hasPendingDataRequest?
1062
+
1063
+ ```ts
1064
+ optional hasPendingDataRequest?: boolean;
1065
+ ```
1066
+
1067
+ Whether the client should poll for more application responses.
1068
+
1069
+ ##### sources?
1070
+
1071
+ ```ts
1072
+ optional sources?: KnowledgeBaseResponseSource[];
1073
+ ```
1074
+
1075
+ Knowledge base sources
1076
+
1077
+ ##### feedbackUrl?
1078
+
1079
+ ```ts
1080
+ optional feedbackUrl?: string;
1081
+ ```
1082
+
1083
+ URL to use for submitting feedback about this response. See `feedbackConfig` for what the expected feedback type is.
1084
+
1085
+ You can pass this as the first argument to `submitFeedback`.
1086
+
1087
+ ##### feedbackConfig?
1088
+
1089
+ ```ts
1090
+ optional feedbackConfig?: FeedbackConfiguration;
1091
+ ```
1092
+
1093
+ If present, the application would like to collect feedback from the user.
1094
+
1095
+ ---
1096
+
1097
+ ### KnowledgeBaseResponseSource
1098
+
1099
+ Response for knowlege base sources
1100
+
1101
+ #### Properties
1102
+
1103
+ ##### fileName?
1104
+
1105
+ ```ts
1106
+ optional fileName?: string;
1107
+ ```
1108
+
1109
+ File name
1110
+
1111
+ ##### pageNumber?
1112
+
1113
+ ```ts
1114
+ optional pageNumber?: number;
1115
+ ```
1116
+
1117
+ Page number
1118
+
1119
+ ##### content?
1120
+
1121
+ ```ts
1122
+ optional content?: string;
1123
+ ```
1124
+
1125
+ Content
1126
+
1127
+ ##### metadata?
1128
+
1129
+ ```ts
1130
+ optional metadata?: Record<string, unknown>;
1131
+ ```
1132
+
1133
+ Metadata
1134
+
1135
+ ##### presignedUrl?
1136
+
1137
+ ```ts
1138
+ optional presignedUrl?: string;
1139
+ ```
1140
+
1141
+ Presigned URL for direct retrieval
1142
+
1143
+ ---
1144
+
1145
+ ### ApplicationMessageMetadata
1146
+
1147
+ Metadata for the individual application message
1148
+ as well as whether the client should poll for more application responses.
1149
+
1150
+ #### Properties
1151
+
1152
+ ##### intentId?
1153
+
1154
+ ```ts
1155
+ optional intentId?: string;
1156
+ ```
1157
+
1158
+ The message node's flow ID (called `intentId` here for legacy reasons).
1159
+
1160
+ ---
1161
+
1162
+ ### ApplicationMessage
1163
+
1164
+ A message from the application, as well as any choices the user can make.
1165
+
1166
+ #### Properties
1167
+
1168
+ ##### messageId?
1169
+
1170
+ ```ts
1171
+ optional messageId?: string;
1172
+ ```
1173
+
1174
+ A unique identifier for the message.
1175
+
1176
+ ##### nodeId?
1177
+
1178
+ ```ts
1179
+ optional nodeId?: string;
1180
+ ```
1181
+
1182
+ The node id that this message is associated with.
1183
+ This is must be sent with a choice when the user is changing a previously sent choice.
1184
+
1185
+ ##### text
1186
+
1187
+ ```ts
1188
+ text: string;
1189
+ ```
1190
+
1191
+ The body of the message. Show this to the user.
1192
+
1193
+ ##### choices
1194
+
1195
+ ```ts
1196
+ choices: Choice[];
1197
+ ```
1198
+
1199
+ A selection of choices to show to the user. They may choose one of them.
1200
+
1201
+ ##### metadata?
1202
+
1203
+ ```ts
1204
+ optional metadata?: ApplicationMessageMetadata;
1205
+ ```
1206
+
1207
+ Metadata
1208
+
1209
+ ##### selectedChoiceId?
1210
+
1211
+ ```ts
1212
+ optional selectedChoiceId?: string;
1213
+ ```
1214
+
1215
+ After a choice has been made by the user, this will be updated locally to the selected choice id.
1216
+ This field is set locally and does not come from the application.
1217
+
1218
+ ---
1219
+
1220
+ ### UploadUrl
1221
+
1222
+ The upload destination for handling conversing with files
1223
+
1224
+ #### Properties
1225
+
1226
+ ##### url
1227
+
1228
+ ```ts
1229
+ url: string;
1230
+ ```
1231
+
1232
+ The URL of the upload
1233
+
1234
+ ##### uploadId
1235
+
1236
+ ```ts
1237
+ uploadId: string;
1238
+ ```
1239
+
1240
+ The ID of the upload
1241
+
1242
+ ---
1243
+
1244
+ ### Choice
1245
+
1246
+ A choices to show to the user.
1247
+
1248
+ #### Properties
1249
+
1250
+ ##### choiceId
1251
+
1252
+ ```ts
1253
+ choiceId: string;
1254
+ ```
1255
+
1256
+ `choiceId` is used by `sendChoice` to let the user choose this choice.
1257
+
1258
+ ##### choiceText
1259
+
1260
+ ```ts
1261
+ choiceText: string;
1262
+ ```
1263
+
1264
+ The text of the choice
1265
+
1266
+ ##### choicePayload?
1267
+
1268
+ ```ts
1269
+ optional choicePayload?: any;
1270
+ ```
1271
+
1272
+ An optional, schemaless payload for the choice.
1273
+
1274
+ ---
1275
+
1276
+ ### UserResponse
1277
+
1278
+ A message from the user
1279
+
1280
+ See also:
1281
+
1282
+ - [ApplicationResponse](#applicationresponse)
1283
+ - [NoticeResponse](#noticeresponse)
1284
+ - [FailureMessage](#failuremessage-1)
1285
+ - [Response](#response)
1286
+
1287
+ #### Properties
1288
+
1289
+ ##### type
1290
+
1291
+ ```ts
1292
+ type: User;
1293
+ ```
1294
+
1295
+ The user response type
1296
+
1297
+ ##### receivedAt
1298
+
1299
+ ```ts
1300
+ receivedAt: number;
1301
+ ```
1302
+
1303
+ When the response was received
1304
+
1305
+ ##### payload
1306
+
1307
+ ```ts
1308
+ payload: UserResponsePayload;
1309
+ ```
1310
+
1311
+ The payload of the response
1312
+
1313
+ ---
1314
+
1315
+ ### FailureMessage
1316
+
1317
+ A failure message is received when the NLX api is unreachable, or sends an unparsable response.
1318
+
1319
+ See also:
1320
+
1321
+ - [ApplicationResponse](#applicationresponse)
1322
+ - [NoticeResponse](#noticeresponse)
1323
+ - [UserResponse](#userresponse)
1324
+ - [Response](#response)
1325
+
1326
+ #### Properties
1327
+
1328
+ ##### type
1329
+
1330
+ ```ts
1331
+ type: Failure;
1332
+ ```
1333
+
1334
+ The failure response type
1335
+
1336
+ ##### payload
1337
+
1338
+ ```ts
1339
+ payload: object;
1340
+ ```
1341
+
1342
+ The payload only includes an error message.
1343
+
1344
+ ###### text
1345
+
1346
+ ```ts
1347
+ text: string;
1348
+ ```
1349
+
1350
+ The error message is either the default, or the `failureMessage` set in the [Config](#config).
1351
+
1352
+ ##### receivedAt
1353
+
1354
+ ```ts
1355
+ receivedAt: number;
1356
+ ```
1357
+
1358
+ When the failure occurred.
1359
+
1360
+ ---
1361
+
1362
+ ### NoticeResponse
1363
+
1364
+ A message from the user
1365
+
1366
+ See also:
1367
+
1368
+ - [ApplicationResponse](#applicationresponse)
1369
+ - [FailureMessage](#failuremessage-1)
1370
+ - [Response](#response)
1371
+
1372
+ #### Properties
1373
+
1374
+ ##### type
1375
+
1376
+ ```ts
1377
+ type: Notice;
1378
+ ```
1379
+
1380
+ The notice response type
1381
+
1382
+ ##### receivedAt
1383
+
1384
+ ```ts
1385
+ receivedAt: number;
1386
+ ```
1387
+
1388
+ When the response was received
1389
+
1390
+ ##### payload
1391
+
1392
+ ```ts
1393
+ payload: object;
1394
+ ```
1395
+
1396
+ The payload of the response
1397
+
1398
+ ###### text
1399
+
1400
+ ```ts
1401
+ text: string;
1402
+ ```
1403
+
1404
+ The error message is either the default, or the `failureMessage` set in the [Config](#config).
1405
+
1406
+ ---
1407
+
1408
+ ### FeedbackConfiguration
1409
+
1410
+ Configuration for feedback collection. You can use this to render an appropriate feedback widget in your application.
1411
+
1412
+ #### Properties
1413
+
1414
+ ##### feedbackId
1415
+
1416
+ ```ts
1417
+ feedbackId: string;
1418
+ ```
1419
+
1420
+ Unique identifier for the feedback collection.
1421
+
1422
+ ##### feedbackName
1423
+
1424
+ ```ts
1425
+ feedbackName: string;
1426
+ ```
1427
+
1428
+ Human readable name of this feedback collection.
1429
+
1430
+ ##### feedbackType
1431
+
1432
+ ```ts
1433
+ feedbackType: object;
1434
+ ```
1435
+
1436
+ Type of feedback being collected.
1437
+ At the moment only binary feedback is supported, but we plan to introduce more types in the future.
1438
+ Hence your code should make sure to check the `type` attribute to make sure the expected feedback type is handled.
1439
+
1440
+ ###### type
1441
+
1442
+ ```ts
1443
+ type: "binary";
1444
+ ```
1445
+
1446
+ A binary feedback type is a thumbs up/down sort of choice.
1447
+
1448
+ ###### config
1449
+
1450
+ ```ts
1451
+ config: object;
1452
+ ```
1453
+
1454
+ Configuration specific to binary feedback.
1455
+
1456
+ ###### config.positiveValue
1457
+
1458
+ ```ts
1459
+ positiveValue: number;
1460
+ ```
1461
+
1462
+ Value to send for positive feedback. Default `1`.
1463
+
1464
+ ###### config.negativeValue
1465
+
1466
+ ```ts
1467
+ negativeValue: number;
1468
+ ```
1469
+
1470
+ Value to send for negative feedback. Default `-1`.
1471
+
1472
+ ##### commentsEnabled
1473
+
1474
+ ```ts
1475
+ commentsEnabled: boolean;
1476
+ ```
1477
+
1478
+ Whether comments are enabled for this feedback collection.
1479
+
1480
+ ##### question?
1481
+
1482
+ ```ts
1483
+ optional question?: string;
1484
+ ```
1485
+
1486
+ Optional question to show to the user when collecting feedback.
1487
+
1488
+ ##### labels
1489
+
1490
+ ```ts
1491
+ labels: object;
1492
+ ```
1493
+
1494
+ Labels for individual feedback UI elements as customised by the builder.
1495
+
1496
+ ###### positive?
1497
+
1498
+ ```ts
1499
+ optional positive?: string;
1500
+ ```
1501
+
1502
+ Label for positive feedback
1503
+
1504
+ ###### negative?
1505
+
1506
+ ```ts
1507
+ optional negative?: string;
1508
+ ```
1509
+
1510
+ Label for negative feedback
1511
+
1512
+ ###### comment?
1513
+
1514
+ ```ts
1515
+ optional comment?: string;
1516
+ ```
1517
+
1518
+ Label for comment
1519
+
1520
+ ---
1521
+
1522
+ ### StructuredRequest
1523
+
1524
+ The body of `sendStructured`
1525
+ Includes a combination of choice, slots, and flow in one request.
1526
+
1527
+ #### Properties
1528
+
1529
+ ##### choiceId?
1530
+
1531
+ ```ts
1532
+ optional choiceId?: string;
1533
+ ```
1534
+
1535
+ The `choiceId` is in the [ApplicationResponse](#applicationresponse)'s `.payload.messages[].choices[].choiceId` fields
1536
+
1537
+ ##### nodeId?
1538
+
1539
+ ```ts
1540
+ optional nodeId?: string;
1541
+ ```
1542
+
1543
+ Required if you want to change a choice that's already been sent.
1544
+ The `nodeId` can be found in the corresponding [ApplicationMessage](#applicationmessage).
1545
+
1546
+ ##### ~~intentId?~~
1547
+
1548
+ ```ts
1549
+ optional intentId?: string;
1550
+ ```
1551
+
1552
+ The intent to trigger. The `intentId` is the name under the application's _Intents_.
1553
+
1554
+ ###### Deprecated
1555
+
1556
+ use `flowId` instead.
1557
+
1558
+ ##### flowId?
1559
+
1560
+ ```ts
1561
+ optional flowId?: string;
1562
+ ```
1563
+
1564
+ The flow to trigger. The `flowId` is the name under the application's _Flows_.
1565
+
1566
+ ##### slots?
1567
+
1568
+ ```ts
1569
+ optional slots?: SlotsRecordOrArray;
1570
+ ```
1571
+
1572
+ The slots to populate
1573
+
1574
+ ##### uploadIds?
1575
+
1576
+ ```ts
1577
+ optional uploadIds?: string[];
1578
+ ```
1579
+
1580
+ Upload ID
1581
+
1582
+ ##### utterance?
1583
+
1584
+ ```ts
1585
+ optional utterance?: string;
1586
+ ```
1587
+
1588
+ Upload utterance
1589
+
1590
+ ---
1591
+
1592
+ ### ApplicationRequest
1593
+
1594
+ The request data actually sent to the application, slightly different from [UserResponsePayload](#userresponsepayload-1), which includes some UI-specific information
1595
+
1596
+ #### Properties
1597
+
1598
+ ##### conversationId?
1599
+
1600
+ ```ts
1601
+ optional conversationId?: string;
1602
+ ```
1603
+
1604
+ The current conversation ID
1605
+
1606
+ ##### userId?
1607
+
1608
+ ```ts
1609
+ optional userId?: string;
1610
+ ```
1611
+
1612
+ The current user ID
1613
+
1614
+ ##### context?
1615
+
1616
+ ```ts
1617
+ optional context?: Context;
1618
+ ```
1619
+
1620
+ Request context, if applicable
1621
+
1622
+ ##### request
1623
+
1624
+ ```ts
1625
+ request: object;
1626
+ ```
1627
+
1628
+ Main request
1629
+
1630
+ ###### unstructured?
1631
+
1632
+ ```ts
1633
+ optional unstructured?: object;
1634
+ ```
1635
+
1636
+ Unstructured request
1637
+
1638
+ ###### unstructured.text
1639
+
1640
+ ```ts
1641
+ text: string;
1642
+ ```
1643
+
1644
+ Request body text
1645
+
1646
+ ###### structured?
1647
+
1648
+ ```ts
1649
+ optional structured?: StructuredRequest & object;
1650
+ ```
1651
+
1652
+ Structured request
1653
+
1654
+ ###### Type Declaration
1655
+
1656
+ ###### slots?
1657
+
1658
+ ```ts
1659
+ optional slots?: SlotValue[];
1660
+ ```
1661
+
1662
+ Only array-form slots are allowed for the purposes of sending to the backend
1663
+
1664
+ ---
1665
+
1666
+ ### VoiceCredentials
1667
+
1668
+ Credentials to connect to a Voice channel
1669
+
1670
+ #### Properties
1671
+
1672
+ ##### url
1673
+
1674
+ ```ts
1675
+ url: string;
1676
+ ```
1677
+
1678
+ Voice Connection URL
1679
+
1680
+ ##### roomName
1681
+
1682
+ ```ts
1683
+ roomName: string;
1684
+ ```
1685
+
1686
+ Voice room name
1687
+
1688
+ ##### token
1689
+
1690
+ ```ts
1691
+ token: string;
1692
+ ```
1693
+
1694
+ Voice token
1695
+
1696
+ ##### participantName
1697
+
1698
+ ```ts
1699
+ participantName: string;
1700
+ ```
1701
+
1702
+ Voice participant name
1703
+
1704
+ ---
1705
+
1706
+ ### ChoiceRequestMetadata
1707
+
1708
+ Helps link the choice to the specific message in the conversation.
1709
+
1710
+ #### Properties
1711
+
1712
+ ##### responseIndex?
1713
+
1714
+ ```ts
1715
+ optional responseIndex?: number;
1716
+ ```
1717
+
1718
+ The index of the [Response](#response) associated with this choice.
1719
+ Setting this ensures that local state's `selectedChoiceId` on the corresponding [ApplicationResponse](#applicationresponse) is set.
1720
+ It is not sent to the application.
1721
+
1722
+ ##### messageIndex?
1723
+
1724
+ ```ts
1725
+ optional messageIndex?: number;
1726
+ ```
1727
+
1728
+ The index of the [ApplicationMessage](#applicationmessage) associated with this choice.
1729
+ Setting this ensures that local state's `selectedChoiceId` on the corresponding [ApplicationResponse](#applicationresponse) is set.
1730
+ It is not sent to the application.
1731
+
1732
+ ##### nodeId?
1733
+
1734
+ ```ts
1735
+ optional nodeId?: string;
1736
+ ```
1737
+
1738
+ Required if you want to change a choice that's already been sent.
1739
+ The `nodeId` can be found in the corresponding [ApplicationMessage](#applicationmessage).
1740
+
1741
+ ##### ~~intentId?~~
1742
+
1743
+ ```ts
1744
+ optional intentId?: string;
1745
+ ```
1746
+
1747
+ Intent ID, used for sending to the NLU to allow it to double-check.
1748
+
1749
+ ###### Deprecated
1750
+
1751
+ use `flowId` instead.
1752
+
1753
+ ##### flowId?
1754
+
1755
+ ```ts
1756
+ optional flowId?: string;
1757
+ ```
1758
+
1759
+ Flow ID, used for sending to the NLU to allow it to double-check.
1760
+
1761
+ ---
1762
+
1763
+ ### VoicePlusMessage
1764
+
1765
+ Messages sent to the Voice+ socket
1766
+
1767
+ #### Properties
1768
+
1769
+ ##### context
1770
+
1771
+ ```ts
1772
+ context: any;
1773
+ ```
1774
+
1775
+ Voice+ context
1776
+
1777
+ ---
1778
+
1779
+ ### EventHandlers
1780
+
1781
+ Dictionary of handler methods per event
1782
+
1783
+ #### Properties
1784
+
1785
+ ##### voicePlusCommand
1786
+
1787
+ ```ts
1788
+ voicePlusCommand: VoicePlusCommandListener;
1789
+ ```
1790
+
1791
+ Voice+ command event handler
1792
+
1793
+ ##### interimMessage
1794
+
1795
+ ```ts
1796
+ interimMessage: InterimMessageListener;
1797
+ ```
1798
+
1799
+ Interim message event handler
1800
+
1801
+ ## Enumerations
1802
+
1803
+ ### Protocol
1804
+
1805
+ The protocol used to communicate with the application
1806
+
1807
+ #### Enumeration Members
1808
+
1809
+ ##### Http
1810
+
1811
+ ```ts
1812
+ Http: "http";
1813
+ ```
1814
+
1815
+ Supported for development purposes only
1816
+
1817
+ ##### HttpWithStreaming
1818
+
1819
+ ```ts
1820
+ HttpWithStreaming: "httpWithStreaming";
1821
+ ```
1822
+
1823
+ Supported for development purposes only
1824
+
1825
+ ##### Https
1826
+
1827
+ ```ts
1828
+ Https: "https";
1829
+ ```
1830
+
1831
+ Regular encrypted HTTPS, without support for post-escalation message handling, interim messages and other streaming features.
1832
+
1833
+ ##### HttpsWithStreaming
1834
+
1835
+ ```ts
1836
+ HttpsWithStreaming: "httpsWithStreaming";
1837
+ ```
1838
+
1839
+ Encrypted HTTPS with streaming enabled. This is the default setting and supports interim messages. Does not support post-escalation message handling.
1840
+
1841
+ ##### Websocket
1842
+
1843
+ ```ts
1844
+ Websocket: "websocket";
1845
+ ```
1846
+
1847
+ Websocket, with support for post-escalation message handling.
1848
+
1849
+ ---
1850
+
1851
+ ### ResponseType
1852
+
1853
+ Response type
1854
+
1855
+ #### Enumeration Members
1856
+
1857
+ ##### Application
1858
+
1859
+ ```ts
1860
+ Application: "bot";
1861
+ ```
1862
+
1863
+ Response from the application
1864
+
1865
+ ##### User
1866
+
1867
+ ```ts
1868
+ User: "user";
1869
+ ```
1870
+
1871
+ Response from the user
1872
+
1873
+ ##### Failure
1874
+
1875
+ ```ts
1876
+ Failure: "failure";
1877
+ ```
1878
+
1879
+ Generic failure (cannot be attributed to the application)
1880
+
1881
+ ##### Notice
1882
+
1883
+ ```ts
1884
+ Notice: "notice";
1885
+ ```
1886
+
1887
+ Notices for important conversation events like agent joined
1888
+
1889
+ ## Events
1890
+
1891
+ ### ConversationHandlerEvent
1892
+
1893
+ ```ts
1894
+ type ConversationHandlerEvent = "voicePlusCommand" | "interimMessage";
1895
+ ```
1896
+
1897
+ Handler events
1898
+ voicePlusCommand
1899
+
1900
+ ## Type Aliases
1901
+
1902
+ ### Context
1903
+
1904
+ ```ts
1905
+ type Context = Record<string, any>;
1906
+ ```
1907
+
1908
+ [Context](https://docs.nlx.ai/platform/nlx-platform-guide/flows-and-building-blocks/advanced/context-variables) for usage later in the flow.
1909
+
1910
+ ---
1911
+
1912
+ ### SlotsRecord
1913
+
1914
+ ```ts
1915
+ type SlotsRecord = Record<string, any>;
1916
+ ```
1917
+
1918
+ Values to fill an flow's [attached slots](https://docs.nlx.ai/platform/nlx-platform-guide/flows-and-building-blocks/overview/setup#attached-slots).
1919
+
1920
+ `SlotRecord` Keys are the attached slot's name
1921
+
1922
+ `SlotRecord` Values are usually a discrete value matching the slots's [type](https://docs.nlx.ai/platform/nlx-platform-guide/flows-and-building-blocks/overview/setup#custom-vs-built-in-slots).
1923
+ for custom slots, this can optionally be the value's ID.
1924
+
1925
+ A `SlotsRecord` is equivalent to an array of [SlotValue](#slotvalue) objects.
1926
+
1927
+ ---
1928
+
1929
+ ### SlotsRecordOrArray
1930
+
1931
+ ```ts
1932
+ type SlotsRecordOrArray = SlotsRecord | SlotValue[];
1933
+ ```
1934
+
1935
+ Values to fill an flow's [attached slots](https://docs.nlx.ai/platform/nlx-platform-guide/flows-and-building-blocks/overview/setup#attached-slots).
1936
+
1937
+ Supports either a [SlotsRecord](#slotsrecord) or an array of [SlotValue](#slotvalue) objects
1938
+
1939
+ ---
1940
+
1941
+ ### ModalityPayloads
1942
+
1943
+ ```ts
1944
+ type ModalityPayloads = Record<string, any>;
1945
+ ```
1946
+
1947
+ Payloads for modalities as a key-value pair by modality name
1948
+
1949
+ ---
1950
+
1951
+ ### UserResponsePayload
1952
+
1953
+ ```ts
1954
+ type UserResponsePayload =
1955
+ | {
1956
+ type: "text";
1957
+ text: string;
1958
+ context?: Context;
1959
+ }
1960
+ | {
1961
+ type: "choice";
1962
+ choiceId: string;
1963
+ context?: Context;
1964
+ }
1965
+ | (object & StructuredRequest);
1966
+ ```
1967
+
1968
+ The payload of the user response
1969
+
1970
+ #### Union Members
1971
+
1972
+ ##### Type Literal
1973
+
1974
+ ```ts
1975
+ {
1976
+ type: "text";
1977
+ text: string;
1978
+ context?: Context;
1979
+ }
1980
+ ```
1981
+
1982
+ ###### type
1983
+
1984
+ ```ts
1985
+ type: "text";
1986
+ ```
1987
+
1988
+ Set when `sendText` is called.
1989
+
1990
+ ###### text
1991
+
1992
+ ```ts
1993
+ text: string;
1994
+ ```
1995
+
1996
+ The user's message
1997
+
1998
+ ###### context?
1999
+
2000
+ ```ts
2001
+ optional context?: Context;
2002
+ ```
2003
+
2004
+ [Context](https://docs.nlx.ai/platform/nlx-platform-guide/flows-and-building-blocks/advanced/context-variables) for usage later in the flow.
2005
+
2006
+ ---
2007
+
2008
+ ##### Type Literal
2009
+
2010
+ ```ts
2011
+ {
2012
+ type: "choice";
2013
+ choiceId: string;
2014
+ context?: Context;
2015
+ }
2016
+ ```
2017
+
2018
+ ###### type
2019
+
2020
+ ```ts
2021
+ type: "choice";
2022
+ ```
2023
+
2024
+ Set when `sendChoice` is called.
2025
+
2026
+ ###### choiceId
2027
+
2028
+ ```ts
2029
+ choiceId: string;
2030
+ ```
2031
+
2032
+ The `choiceId` passed to `sendChoice`
2033
+ Correlates to a `choiceId` in the [ApplicationResponse](#applicationresponse)'s `.payload.messages[].choices[].choiceId` fields
2034
+
2035
+ ###### context?
2036
+
2037
+ ```ts
2038
+ optional context?: Context;
2039
+ ```
2040
+
2041
+ [Context](https://docs.nlx.ai/platform/nlx-platform-guide/flows-and-building-blocks/advanced/context-variables) for usage later in the flow.
2042
+
2043
+ ---
2044
+
2045
+ `object` & [`StructuredRequest`](#structuredrequest)
2046
+
2047
+ ---
2048
+
2049
+ ### Response
2050
+
2051
+ ```ts
2052
+ type Response =
2053
+ | ApplicationResponse
2054
+ | UserResponse
2055
+ | NoticeResponse
2056
+ | FailureMessage;
2057
+ ```
2058
+
2059
+ A response from the application or the user.
2060
+
2061
+ ---
2062
+
2063
+ ### Time
2064
+
2065
+ ```ts
2066
+ type Time = number;
2067
+ ```
2068
+
2069
+ The time value in milliseconds since midnight, January 1, 1970 UTC.
2070
+
2071
+ ---
2072
+
2073
+ ### NormalizedStructuredRequest
2074
+
2075
+ ```ts
2076
+ type NormalizedStructuredRequest = StructuredRequest & object;
2077
+ ```
2078
+
2079
+ Normalized structured request with a single way to represent slots
2080
+
2081
+ #### Type Declaration
2082
+
2083
+ ##### slots?
2084
+
2085
+ ```ts
2086
+ optional slots?: SlotValue[];
2087
+ ```
2088
+
2089
+ Only array-form slots are allowed for the purposes of sending to the backend
2090
+
2091
+ ---
2092
+
2093
+ ### LanguageCode
2094
+
2095
+ ```ts
2096
+ type LanguageCode = string;
2097
+ ```
2098
+
2099
+ Language code named for clarity, may restrict it to a finite list
2100
+
2101
+ ---
2102
+
2103
+ ### RequestOverride
2104
+
2105
+ ```ts
2106
+ type RequestOverride = (applicationRequest, appendResponse) => void;
2107
+ ```
2108
+
2109
+ Instead of sending a request to the application, handle it in a custom fashion
2110
+
2111
+ #### Parameters
2112
+
2113
+ ##### applicationRequest
2114
+
2115
+ [`ApplicationRequest`](#applicationrequest)
2116
+
2117
+ The [ApplicationRequest](#applicationrequest) that is being overridden
2118
+
2119
+ ##### appendResponse
2120
+
2121
+ (`res`) => `void`
2122
+
2123
+ A method to append the [ApplicationResponsePayload](#applicationresponsepayload-1) to the message history
2124
+
2125
+ #### Returns
2126
+
2127
+ `void`
2128
+
2129
+ ---
2130
+
2131
+ ### VoicePlusContext
2132
+
2133
+ ```ts
2134
+ type VoicePlusContext = any;
2135
+ ```
2136
+
2137
+ Voice+ context, type to be defined
2138
+
2139
+ ---
2140
+
2141
+ ### VoicePlusCommandListener
2142
+
2143
+ ```ts
2144
+ type VoicePlusCommandListener = (payload) => void;
2145
+ ```
2146
+
2147
+ Voice+ command listener
2148
+
2149
+ #### Parameters
2150
+
2151
+ ##### payload
2152
+
2153
+ `any`
2154
+
2155
+ #### Returns
2156
+
2157
+ `void`
2158
+
2159
+ ---
2160
+
2161
+ ### InterimMessageListener
2162
+
2163
+ ```ts
2164
+ type InterimMessageListener = (message?) => void;
2165
+ ```
2166
+
2167
+ Interim message listener
2168
+
2169
+ #### Parameters
2170
+
2171
+ ##### message?
2172
+
2173
+ `string`
2174
+
2175
+ #### Returns
2176
+
2177
+ `void`
2178
+
2179
+ ---
2180
+
2181
+ ### Subscriber
2182
+
2183
+ ```ts
2184
+ type Subscriber = (response, newResponse?) => void;
2185
+ ```
2186
+
2187
+ The callback function for listening to all responses.
2188
+
2189
+ #### Parameters
2190
+
2191
+ ##### response
2192
+
2193
+ [`Response`](#response)[]
2194
+
2195
+ ##### newResponse?
2196
+
2197
+ [`Response`](#response)
2198
+
2199
+ #### Returns
2200
+
2201
+ `void`
2202
+
2203
+ ---
2204
+
2205
+ ### StepInfo
2206
+
2207
+ ```ts
2208
+ type StepInfo =
2209
+ | string
2210
+ | {
2211
+ stepId: string;
2212
+ stepTriggerDescription?: string;
2213
+ };
2214
+ ```
2215
+
2216
+ Step information, either a step ID as a single string or an object
2217
+
2218
+ #### Union Members
2219
+
2220
+ `string`
2221
+
2222
+ ---
2223
+
2224
+ ##### Type Literal
2225
+
2226
+ ```ts
2227
+ {
2228
+ stepId: string;
2229
+ stepTriggerDescription?: string;
2230
+ }
2231
+ ```
2232
+
2233
+ ###### stepId
2234
+
2235
+ ```ts
2236
+ stepId: string;
2237
+ ```
2238
+
2239
+ Step ID
2240
+
2241
+ ###### stepTriggerDescription?
2242
+
2243
+ ```ts
2244
+ optional stepTriggerDescription?: string;
2245
+ ```
2246
+
2247
+ Step trigger description