@nlxai/core 1.2.4-alpha.8 → 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
@@ -13,7 +13,10 @@ import { createConversation } from "@nlxai/core";
13
13
 
14
14
  // Create some configuration
15
15
  const config = {
16
- applicationUrl: "", // obtain from NLX deployments page
16
+ protocol: "httpsWithStreaming", // "httpsWithStreaming", "https" or "websocket"
17
+ host: "", // obtain from NLX deployments page
18
+ deploymentKey: "", // obtain from NLX deployments page
19
+ channelKey: "", // obtain from NLX deployments page
17
20
  headers: {
18
21
  "nlx-api-key": "", // obtain from NLX deployments page
19
22
  },
@@ -559,26 +562,60 @@ The configuration necessary to create a conversation.
559
562
  optional applicationUrl: string;
560
563
  ```
561
564
 
562
- The URL at which your conversational application is running.
563
- 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:
564
567
 
565
- ##### 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?
566
573
 
567
574
  ```ts
568
- headers: Record<string, string> & object;
575
+ optional protocol: Protocol;
569
576
  ```
570
577
 
571
- Headers to forward to the NLX API.
578
+ Specify the protocol (http, websocket or httpWithStreaming)
572
579
 
573
- ###### 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
+ ```
574
609
 
575
- ###### nlx-api-key
610
+ API key.
611
+
612
+ ##### headers?
576
613
 
577
614
  ```ts
578
- nlx-api-key: string;
615
+ optional headers: Record<string, string>;
579
616
  ```
580
617
 
581
- The `nlx-api-key` is required. Fetch this from the application's API channel tab.
618
+ Headers to forward to the NLX API.
582
619
 
583
620
  ##### conversationId?
584
621
 
@@ -695,7 +732,7 @@ The slots to populate
695
732
  sendChoice: (choiceId, context?, metadata?) => void;
696
733
  ```
697
734
 
698
- 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.
699
736
 
700
737
  ###### Parameters
701
738
 
@@ -755,13 +792,13 @@ Trigger a specific flow.
755
792
 
756
793
  `string`
757
794
 
758
- 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_.
759
796
 
760
797
  ###### context?
761
798
 
762
799
  [`Context`](#context)
763
800
 
764
- [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.
765
802
 
766
803
  ###### Returns
767
804
 
@@ -781,7 +818,7 @@ Send context without sending a message
781
818
 
782
819
  [`Context`](#context)
783
820
 
784
- [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.
785
822
 
786
823
  ###### Returns
787
824
 
@@ -814,7 +851,7 @@ the response with optional timestamps.
814
851
  sendStructured: (request, context?) => void;
815
852
  ```
816
853
 
817
- Send a combination of choice, slots, and intent in one request.
854
+ Send a combination of choice, slots, and flow in one request.
818
855
 
819
856
  ###### Parameters
820
857
 
@@ -826,7 +863,7 @@ Send a combination of choice, slots, and intent in one request.
826
863
 
827
864
  [`Context`](#context)
828
865
 
829
- [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.
830
867
 
831
868
  ###### Returns
832
869
 
@@ -1067,7 +1104,7 @@ Remove a listener to one of the handler's custom events
1067
1104
 
1068
1105
  ### SlotValue
1069
1106
 
1070
- 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).
1071
1108
 
1072
1109
  An array of `SlotValue` objects is equivalent to a [SlotsRecord](#slotsrecord).
1073
1110
 
@@ -1087,7 +1124,7 @@ The attached slot's name
1087
1124
  value: any;
1088
1125
  ```
1089
1126
 
1090
- 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).
1091
1128
  for custom slots, this can optionally be the value's ID.
1092
1129
 
1093
1130
  ---
@@ -1175,7 +1212,7 @@ as well as whether the client should poll for more application responses.
1175
1212
  optional payload: string;
1176
1213
  ```
1177
1214
 
1178
- 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).
1179
1216
 
1180
1217
  ##### modalities?
1181
1218
 
@@ -1208,7 +1245,7 @@ as well as whether the client should poll for more application responses.
1208
1245
  optional intentId: string;
1209
1246
  ```
1210
1247
 
1211
- The conversation's intent
1248
+ The conversation's flow ID (called `intentId` here for legacy reasons).
1212
1249
 
1213
1250
  ##### escalation?
1214
1251
 
@@ -1339,7 +1376,7 @@ as well as whether the client should poll for more application responses.
1339
1376
  optional intentId: string;
1340
1377
  ```
1341
1378
 
1342
- The message node's intent
1379
+ The message node's flow ID (called `intentId` here for legacy reasons).
1343
1380
 
1344
1381
  ---
1345
1382
 
@@ -1652,7 +1689,7 @@ Label for comment
1652
1689
  ### StructuredRequest
1653
1690
 
1654
1691
  The body of `sendStructured`
1655
- Includes a combination of choice, slots, and intent in one request.
1692
+ Includes a combination of choice, slots, and flow in one request.
1656
1693
 
1657
1694
  #### Properties
1658
1695
 
@@ -1868,13 +1905,25 @@ optional nodeId: string;
1868
1905
  Required if you want to change a choice that's already been sent.
1869
1906
  The `nodeId` can be found in the corresponding [ApplicationMessage](#applicationmessage).
1870
1907
 
1871
- ##### intentId?
1908
+ ##### ~~intentId?~~
1872
1909
 
1873
1910
  ```ts
1874
1911
  optional intentId: string;
1875
1912
  ```
1876
1913
 
1877
- 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.
1878
1927
 
1879
1928
  ---
1880
1929
 
@@ -1918,6 +1967,38 @@ Interim message event handler
1918
1967
 
1919
1968
  ## Enumerations
1920
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
+
1921
2002
  ### ResponseType
1922
2003
 
1923
2004
  Response type
@@ -1967,7 +2048,7 @@ voicePlusCommand
1967
2048
  type Context = Record<string, any>;
1968
2049
  ```
1969
2050
 
1970
- [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.
1971
2052
 
1972
2053
  ---
1973
2054
 
@@ -1977,11 +2058,11 @@ type Context = Record<string, any>;
1977
2058
  type SlotsRecord = Record<string, any>;
1978
2059
  ```
1979
2060
 
1980
- 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).
1981
2062
 
1982
2063
  `SlotRecord` Keys are the attached slot's name
1983
2064
 
1984
- `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).
1985
2066
  for custom slots, this can optionally be the value's ID.
1986
2067
 
1987
2068
  A `SlotsRecord` is equivalent to an array of [SlotValue](#slotvalue) objects.
@@ -1994,7 +2075,7 @@ A `SlotsRecord` is equivalent to an array of [SlotValue](#slotvalue) objects.
1994
2075
  type SlotsRecordOrArray = SlotsRecord | SlotValue[];
1995
2076
  ```
1996
2077
 
1997
- 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).
1998
2079
 
1999
2080
  Supports either a [SlotsRecord](#slotsrecord) or an array of [SlotValue](#slotvalue) objects
2000
2081
 
@@ -2061,7 +2142,7 @@ The user's message
2061
2142
  optional context: Context;
2062
2143
  ```
2063
2144
 
2064
- [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.
2065
2146
 
2066
2147
  ```ts
2067
2148
  {
@@ -2094,7 +2175,7 @@ Correlates to a `choiceId` in the [ApplicationResponse](#applicationresponse)'s
2094
2175
  optional context: Context;
2095
2176
  ```
2096
2177
 
2097
- [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.
2098
2179
 
2099
2180
  `object` & [`StructuredRequest`](#structuredrequest)
2100
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