@nlxai/core 1.2.4-alpha.9 → 1.2.4

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/README.md CHANGED
@@ -562,26 +562,60 @@ The configuration necessary to create a conversation.
562
562
  optional applicationUrl: string;
563
563
  ```
564
564
 
565
- The URL at which your conversational application is running.
566
- Fetch this from the application's API channel tab.
565
+ The URL at which your conversational application is running. Fetch this from the application's API channel tab.
566
+ Currently, there are a few ways to specify the application URL:
567
567
 
568
- ##### headers
568
+ - (recommended) leave out `applicationUrl` and specify `protocol`, `host`, `deploymentKey` and `channelKey`.
569
+ - specify the full `applicationUrl` as well as the `protocol`.
570
+ - (legacy) specify the `applicationUrl` generated either as an HTTP or websocket URL. Use `experimental.streamHttp` to control streaming.
571
+
572
+ ##### protocol?
569
573
 
570
574
  ```ts
571
- headers: Record<string, string> & object;
575
+ optional protocol: Protocol;
572
576
  ```
573
577
 
574
- Headers to forward to the NLX API.
578
+ Specify the protocol (http, websocket or httpWithStreaming)
575
579
 
576
- ###### Type Declaration
580
+ ##### host?
581
+
582
+ ```ts
583
+ optional host: string;
584
+ ```
585
+
586
+ Hostname of the application deployment, without a leading `https://`.
587
+
588
+ ##### deploymentKey?
589
+
590
+ ```ts
591
+ optional deploymentKey: string;
592
+ ```
593
+
594
+ Deployment key.
595
+
596
+ ##### channelKey?
597
+
598
+ ```ts
599
+ optional channelKey: string;
600
+ ```
601
+
602
+ Channel key.
603
+
604
+ ##### apiKey?
605
+
606
+ ```ts
607
+ optional apiKey: string;
608
+ ```
577
609
 
578
- ###### nlx-api-key
610
+ API key.
611
+
612
+ ##### headers?
579
613
 
580
614
  ```ts
581
- nlx-api-key: string;
615
+ optional headers: Record<string, string>;
582
616
  ```
583
617
 
584
- The `nlx-api-key` is required. Fetch this from the application's API channel tab.
618
+ Headers to forward to the NLX API.
585
619
 
586
620
  ##### conversationId?
587
621
 
@@ -698,7 +732,7 @@ The slots to populate
698
732
  sendChoice: (choiceId, context?, metadata?) => void;
699
733
  ```
700
734
 
701
- Respond to [a choice](https://docs.studio.nlx.ai/intentflows/documentation-flows/flows-build-mode/nodes#user-choice) from the application.
735
+ Respond to [a choice](https://docs.nlx.ai/platform/nlx-platform-guide/flows-and-building-blocks/overview/nodes#user-choice) from the application.
702
736
 
703
737
  ###### Parameters
704
738
 
@@ -758,13 +792,13 @@ Trigger a specific flow.
758
792
 
759
793
  `string`
760
794
 
761
- the flow to trigger. The id is the name under the application's _Intents_.
795
+ the flow to trigger. The id is the name under the application's _Flows_.
762
796
 
763
797
  ###### context?
764
798
 
765
799
  [`Context`](#context)
766
800
 
767
- [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.
801
+ [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.
768
802
 
769
803
  ###### Returns
770
804
 
@@ -784,7 +818,7 @@ Send context without sending a message
784
818
 
785
819
  [`Context`](#context)
786
820
 
787
- [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.
821
+ [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.
788
822
 
789
823
  ###### Returns
790
824
 
@@ -817,7 +851,7 @@ the response with optional timestamps.
817
851
  sendStructured: (request, context?) => void;
818
852
  ```
819
853
 
820
- Send a combination of choice, slots, and intent in one request.
854
+ Send a combination of choice, slots, and flow in one request.
821
855
 
822
856
  ###### Parameters
823
857
 
@@ -829,7 +863,7 @@ Send a combination of choice, slots, and intent in one request.
829
863
 
830
864
  [`Context`](#context)
831
865
 
832
- [Context](https://docs.studio.nlx.ai/workspacesettings/documentation-settings/settings-context-attributes) for usage later in the intent.
866
+ [Context](https://docs.nlx.ai/platform/nlx-platform-guide/flows-and-building-blocks/advanced/context-variables) for usage later in the flow.
833
867
 
834
868
  ###### Returns
835
869
 
@@ -1070,7 +1104,7 @@ Remove a listener to one of the handler's custom events
1070
1104
 
1071
1105
  ### SlotValue
1072
1106
 
1073
- Values to fill an intent's [attached slots](https://docs.studio.nlx.ai/intents/documentation-intents/intents-attached-slots).
1107
+ Values to fill an flow's [attached slots](https://docs.nlx.ai/platform/nlx-platform-guide/flows-and-building-blocks/overview/setup#attached-slots).
1074
1108
 
1075
1109
  An array of `SlotValue` objects is equivalent to a [SlotsRecord](#slotsrecord).
1076
1110
 
@@ -1090,7 +1124,7 @@ The attached slot's name
1090
1124
  value: any;
1091
1125
  ```
1092
1126
 
1093
- Usually this will be a discrete value matching the slots's [type](https://docs.studio.nlx.ai/slots/documentation-slots/slots-values#system-slots).
1127
+ 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).
1094
1128
  for custom slots, this can optionally be the value's ID.
1095
1129
 
1096
1130
  ---
@@ -1178,7 +1212,7 @@ as well as whether the client should poll for more application responses.
1178
1212
  optional payload: string;
1179
1213
  ```
1180
1214
 
1181
- If configured, the [node's payload.](See: https://docs.studio.nlx.ai/intentflows/documentation-flows/flows-build-mode/advanced-messaging-+-functionality#add-functionality)
1215
+ If configured, the [node's payload](https://docs.nlx.ai/platform/nlx-platform-guide/flows-and-building-blocks/overview/nodes#node-payload).
1182
1216
 
1183
1217
  ##### modalities?
1184
1218
 
@@ -1211,7 +1245,7 @@ as well as whether the client should poll for more application responses.
1211
1245
  optional intentId: string;
1212
1246
  ```
1213
1247
 
1214
- The conversation's intent
1248
+ The conversation's flow ID (called `intentId` here for legacy reasons).
1215
1249
 
1216
1250
  ##### escalation?
1217
1251
 
@@ -1342,7 +1376,7 @@ as well as whether the client should poll for more application responses.
1342
1376
  optional intentId: string;
1343
1377
  ```
1344
1378
 
1345
- The message node's intent
1379
+ The message node's flow ID (called `intentId` here for legacy reasons).
1346
1380
 
1347
1381
  ---
1348
1382
 
@@ -1655,7 +1689,7 @@ Label for comment
1655
1689
  ### StructuredRequest
1656
1690
 
1657
1691
  The body of `sendStructured`
1658
- Includes a combination of choice, slots, and intent in one request.
1692
+ Includes a combination of choice, slots, and flow in one request.
1659
1693
 
1660
1694
  #### Properties
1661
1695
 
@@ -1871,13 +1905,25 @@ optional nodeId: string;
1871
1905
  Required if you want to change a choice that's already been sent.
1872
1906
  The `nodeId` can be found in the corresponding [ApplicationMessage](#applicationmessage).
1873
1907
 
1874
- ##### intentId?
1908
+ ##### ~~intentId?~~
1875
1909
 
1876
1910
  ```ts
1877
1911
  optional intentId: string;
1878
1912
  ```
1879
1913
 
1880
- Intent ID, used for sending to the NLU to allow it to double-check
1914
+ Intent ID, used for sending to the NLU to allow it to double-check.
1915
+
1916
+ ###### Deprecated
1917
+
1918
+ use `flowId` instead.
1919
+
1920
+ ##### flowId?
1921
+
1922
+ ```ts
1923
+ optional flowId: string;
1924
+ ```
1925
+
1926
+ Flow ID, used for sending to the NLU to allow it to double-check.
1881
1927
 
1882
1928
  ---
1883
1929
 
@@ -1921,6 +1967,38 @@ Interim message event handler
1921
1967
 
1922
1968
  ## Enumerations
1923
1969
 
1970
+ ### Protocol
1971
+
1972
+ The protocol used to communicate with the application
1973
+
1974
+ #### Enumeration Members
1975
+
1976
+ ##### Https
1977
+
1978
+ ```ts
1979
+ Https: "https";
1980
+ ```
1981
+
1982
+ Regular encrypted HTTPS, without support for post-escalation message handling, interim messages and other streaming features.
1983
+
1984
+ ##### HttpsWithStreaming
1985
+
1986
+ ```ts
1987
+ HttpsWithStreaming: "httpsWithStreaming";
1988
+ ```
1989
+
1990
+ Encrypted HTTPS with streaming enabled. This is the default setting and supports interim messages. Does not support post-escalation message handling.
1991
+
1992
+ ##### Websocket
1993
+
1994
+ ```ts
1995
+ Websocket: "websocket";
1996
+ ```
1997
+
1998
+ Websocket, with support for post-escalation message handling.
1999
+
2000
+ ---
2001
+
1924
2002
  ### ResponseType
1925
2003
 
1926
2004
  Response type
@@ -1970,7 +2048,7 @@ voicePlusCommand
1970
2048
  type Context = Record<string, any>;
1971
2049
  ```
1972
2050
 
1973
- [Context](https://docs.studio.nlx.ai/workspacesettings/documentation-settings/settings-context-attributes) for usage later in the intent.
2051
+ [Context](https://docs.nlx.ai/platform/nlx-platform-guide/flows-and-building-blocks/advanced/context-variables) for usage later in the flow.
1974
2052
 
1975
2053
  ---
1976
2054
 
@@ -1980,11 +2058,11 @@ type Context = Record<string, any>;
1980
2058
  type SlotsRecord = Record<string, any>;
1981
2059
  ```
1982
2060
 
1983
- Values to fill an intent's [attached slots](https://docs.studio.nlx.ai/intents/documentation-intents/intents-attached-slots).
2061
+ Values to fill an flow's [attached slots](https://docs.nlx.ai/platform/nlx-platform-guide/flows-and-building-blocks/overview/setup#attached-slots).
1984
2062
 
1985
2063
  `SlotRecord` Keys are the attached slot's name
1986
2064
 
1987
- `SlotRecord` Values are usually a discrete value matching the slots's [type](https://docs.studio.nlx.ai/slots/documentation-slots/slots-values#system-slots).
2065
+ `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).
1988
2066
  for custom slots, this can optionally be the value's ID.
1989
2067
 
1990
2068
  A `SlotsRecord` is equivalent to an array of [SlotValue](#slotvalue) objects.
@@ -1997,7 +2075,7 @@ A `SlotsRecord` is equivalent to an array of [SlotValue](#slotvalue) objects.
1997
2075
  type SlotsRecordOrArray = SlotsRecord | SlotValue[];
1998
2076
  ```
1999
2077
 
2000
- Values to fill an intent's [attached slots](https://docs.studio.nlx.ai/intents/documentation-intents/intents-attached-slots).
2078
+ Values to fill an intent's [attached slots](https://docs.nlx.ai/platform/nlx-platform-guide/flows-and-building-blocks/overview/setup#attached-slots).
2001
2079
 
2002
2080
  Supports either a [SlotsRecord](#slotsrecord) or an array of [SlotValue](#slotvalue) objects
2003
2081
 
@@ -2064,7 +2142,7 @@ The user's message
2064
2142
  optional context: Context;
2065
2143
  ```
2066
2144
 
2067
- [Context](https://docs.studio.nlx.ai/workspacesettings/documentation-settings/settings-context-attributes) for usage later in the intent.
2145
+ [Context](https://docs.nlx.ai/platform/nlx-platform-guide/flows-and-building-blocks/advanced/context-variables) for usage later in the flow.
2068
2146
 
2069
2147
  ```ts
2070
2148
  {
@@ -2097,7 +2175,7 @@ Correlates to a `choiceId` in the [ApplicationResponse](#applicationresponse)'s
2097
2175
  optional context: Context;
2098
2176
  ```
2099
2177
 
2100
- [Context](https://docs.studio.nlx.ai/workspacesettings/documentation-settings/settings-context-attributes) for usage later in the intent.
2178
+ [Context](https://docs.nlx.ai/platform/nlx-platform-guide/flows-and-building-blocks/advanced/context-variables) for usage later in the flow.
2101
2179
 
2102
2180
  `object` & [`StructuredRequest`](#structuredrequest)
2103
2181
 
package/docs/README.md CHANGED
@@ -214,6 +214,101 @@ sendTextWrapped("Hello").then((response) => {
214
214
  });
215
215
  ```
216
216
 
217
+ ---
218
+
219
+ ### sendVoicePlusStep()
220
+
221
+ ```ts
222
+ function sendVoicePlusStep(configuration): Promise<void>;
223
+ ```
224
+
225
+ Use this function when using **Voice+ scripts** to advance the conversation to the step specified.
226
+
227
+ 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.
228
+
229
+ #### Parameters
230
+
231
+ ##### configuration
232
+
233
+ Configuration for sending the step. Many of the values can be found on the deployment modal of the Voice+ script.
234
+
235
+ ###### apiKey
236
+
237
+ `string`
238
+
239
+ - 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.
240
+
241
+ ###### scriptId?
242
+
243
+ `string`
244
+
245
+ The ID of the Voice+ script.
246
+
247
+ ###### workspaceId
248
+
249
+ `string`
250
+
251
+ Your workspace ID.
252
+
253
+ ###### conversationId
254
+
255
+ `string`
256
+
257
+ The active conversation ID, passed from the active NLX voice application. This is what ties the script exectution to the specific Voice application.
258
+
259
+ _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.
260
+
261
+ **Example**
262
+
263
+ ```typescript
264
+ const conversationId = new URLSearchParams(window.location.search).get("cid");
265
+ ```
266
+
267
+ ###### languageCode
268
+
269
+ `string`
270
+
271
+ The user's language code, consistent with the language codes defined on the Voice+ script.
272
+
273
+ ###### step
274
+
275
+ [`StepInfo`](#stepinfo)
276
+
277
+ Which step to send.
278
+
279
+ ###### context
280
+
281
+ [`Context`](#context)
282
+
283
+ Any context.
284
+
285
+ ###### debug?
286
+
287
+ `boolean` = `false`
288
+
289
+ Set to `true` to help debug issues or errors. Defaults to `false`.
290
+
291
+ #### Returns
292
+
293
+ `Promise`\<`void`\>
294
+
295
+ #### Example
296
+
297
+ ```typescript
298
+ import { sendVoicePlusStep } from "@nlxai/core";
299
+
300
+ await sendVoicePlusStep({
301
+ // hard-coded params
302
+ apiKey: "REPLACE_WITH_API_KEY",
303
+ workspaceId: "REPLACE_WITH_WORKSPACE_ID",
304
+ scriptId: "REPLACE_WITH_SCRIPT_ID",
305
+ step: "REPLACE_WITH_STEP_ID",
306
+ // dynamic params
307
+ conversationId: "REPLACE_WITH_CONVERSATION_ID",
308
+ languageCode: "en-US",
309
+ });
310
+ ```
311
+
217
312
  ## Variables
218
313
 
219
314
  ### version
@@ -238,26 +333,60 @@ The configuration necessary to create a conversation.
238
333
  optional applicationUrl: string;
239
334
  ```
240
335
 
241
- The URL at which your conversational application is running.
242
- Fetch this from the application's API channel tab.
336
+ The URL at which your conversational application is running. Fetch this from the application's API channel tab.
337
+ Currently, there are a few ways to specify the application URL:
338
+
339
+ - (recommended) leave out `applicationUrl` and specify `protocol`, `host`, `deploymentKey` and `channelKey`.
340
+ - specify the full `applicationUrl` as well as the `protocol`.
341
+ - (legacy) specify the `applicationUrl` generated either as an HTTP or websocket URL. Use `experimental.streamHttp` to control streaming.
243
342
 
244
- ##### headers
343
+ ##### protocol?
245
344
 
246
345
  ```ts
247
- headers: Record<string, string> & object;
346
+ optional protocol: Protocol;
248
347
  ```
249
348
 
250
- Headers to forward to the NLX API.
349
+ Specify the protocol (http, websocket or httpWithStreaming)
251
350
 
252
- ###### Type Declaration
351
+ ##### host?
352
+
353
+ ```ts
354
+ optional host: string;
355
+ ```
356
+
357
+ Hostname of the application deployment, without a leading `https://`.
253
358
 
254
- ###### nlx-api-key
359
+ ##### deploymentKey?
255
360
 
256
361
  ```ts
257
- nlx-api-key: string;
362
+ optional deploymentKey: string;
258
363
  ```
259
364
 
260
- The `nlx-api-key` is required. Fetch this from the application's API channel tab.
365
+ Deployment key.
366
+
367
+ ##### channelKey?
368
+
369
+ ```ts
370
+ optional channelKey: string;
371
+ ```
372
+
373
+ Channel key.
374
+
375
+ ##### apiKey?
376
+
377
+ ```ts
378
+ optional apiKey: string;
379
+ ```
380
+
381
+ API key.
382
+
383
+ ##### headers?
384
+
385
+ ```ts
386
+ optional headers: Record<string, string>;
387
+ ```
388
+
389
+ Headers to forward to the NLX API.
261
390
 
262
391
  ##### conversationId?
263
392
 
@@ -1597,6 +1726,38 @@ Interim message event handler
1597
1726
 
1598
1727
  ## Enumerations
1599
1728
 
1729
+ ### Protocol
1730
+
1731
+ The protocol used to communicate with the application
1732
+
1733
+ #### Enumeration Members
1734
+
1735
+ ##### Https
1736
+
1737
+ ```ts
1738
+ Https: "https";
1739
+ ```
1740
+
1741
+ Regular encrypted HTTPS, without support for post-escalation message handling, interim messages and other streaming features.
1742
+
1743
+ ##### HttpsWithStreaming
1744
+
1745
+ ```ts
1746
+ HttpsWithStreaming: "httpsWithStreaming";
1747
+ ```
1748
+
1749
+ Encrypted HTTPS with streaming enabled. This is the default setting and supports interim messages. Does not support post-escalation message handling.
1750
+
1751
+ ##### Websocket
1752
+
1753
+ ```ts
1754
+ Websocket: "websocket";
1755
+ ```
1756
+
1757
+ Websocket, with support for post-escalation message handling.
1758
+
1759
+ ---
1760
+
1600
1761
  ### ResponseType
1601
1762
 
1602
1763
  Response type
@@ -1928,3 +2089,45 @@ The callback function for listening to all responses.
1928
2089
  #### Returns
1929
2090
 
1930
2091
  `void`
2092
+
2093
+ ---
2094
+
2095
+ ### StepInfo
2096
+
2097
+ ```ts
2098
+ type StepInfo =
2099
+ | string
2100
+ | {
2101
+ stepId: string;
2102
+ stepTriggerDescription?: string;
2103
+ };
2104
+ ```
2105
+
2106
+ Step information, either a step ID as a single string or an object
2107
+
2108
+ #### Type Declaration
2109
+
2110
+ `string`
2111
+
2112
+ ```ts
2113
+ {
2114
+ stepId: string;
2115
+ stepTriggerDescription?: string;
2116
+ }
2117
+ ```
2118
+
2119
+ ##### stepId
2120
+
2121
+ ```ts
2122
+ stepId: string;
2123
+ ```
2124
+
2125
+ Step ID
2126
+
2127
+ ##### stepTriggerDescription?
2128
+
2129
+ ```ts
2130
+ optional stepTriggerDescription: string;
2131
+ ```
2132
+
2133
+ Step trigger description