vania-janet/multiturn-rag-retrieval-data huggingface dataset:
JSONArray.get(Integer) 

This method returns the input index from the JSONArray.

For this Dialog runtime context which is set by a previous node or external application:

{
"context": {
"name": "John",
"nested": {
"array": [! "one", "two" ]
}
}
}

Dialog node or response condition:

$nested.array.get(0).getAsString().contains('one')

Result: True because the nested array contains one as a value.

Response:

"output": {
"generic" : [
{
"values":
{
"text" : "The first item in the array is <?$nested.array.get(0)?>"
}
],
"response_type": "text",
"selection_policy": "sequential"
}
]
}





 JSONArray.getRandomItem() 

This method returns a random item from the input JSONArray.

For this Dialog runtime context:

{
"context": {
"toppings_array": ["onion", "olives", "ham"]
}
}

Dialog node output:

{
"output": {
"generic" : [!
{
"values":
{
"text": "<? $toppings_array.getRandomItem() ?> is a great choice"
}
],
"response_type": "text",
"selection_policy": "sequential"
}
]
}
}

Result: "ham is a great choice!" or "onion is a great choice!" or "olives is a great choice!"

Note: The resulting output text is randomly chosen.





 JSONArray.indexOf(value)
"response_type": "text",
"selection_policy": "sequential"
}
]
}
}
Show more

See the [java.lang.Math reference documentation](https://docs.oracle.com/javase/7/docs/api/java/lang/Math.html) for information about other methods.





 java.util.Random() 

Returns a random number. You can use one of the following syntax options:



* To return a random boolean value (true or false), use <?new Random().nextBoolean()?>.
* To return a random double number between 0 (included) and 1 (excluded), use <?new Random().nextDouble()?>
* To return a random integer between 0 (included) and a number you specify, use <?new Random().nextInt(n)?> where n is the top of the number range you want + 1. For example, if you want to return a random number between 0 and 10, specify <?new Random().nextInt(11)?>.
* To return a random integer from the full Integer value range (-2147483648 to 2147483648), use <?new Random().nextInt()?>.



For example, you might create a dialog node that is triggered by the #random_number intent. The first response condition might look like this:

Condition = @sys-number
{
"context": {
"answer": "<? new Random().nextInt(@sys-number.numeric_value + 1) ?>"
},
"output": {
"generic": [
{
"values":
{
"text": "Here's a random number between 0 and @sys-number.literal: $answer."
}
],
"response_type": "text",
"selection_policy": "sequential"
}
]
}
}
Show more
"response_type": "user_defined",
"user_defined": {
"field_1": "String value",
"array_1":
1,
2
],
"object_1": {
"property_1": "Another string value"
}
}
}
]
}
}
Show more









 Native JSON format 

In addition to the generic JSON format, the dialog node JSON also supports channel-specific responses written using the native JSON format for a specific channel (such as Slack or Facebook Messenger). You might want to use the native JSON format to specify a response type that is not currently supported by the generic JSON format. By checking the integration-specific context (context.integrations), a dialog node can determine the originating integration and then send appropriate native JSON responses.

You can specify native JSON for Slack or Facebook using the output.integrations object in the dialog node response. Each child of output.integrations represents output intended for a specific integration:



* output.integrations.slack: any JSON response you want to be included in the attachment field of a response intended for Slack. For more information about the Slack JSON format, see the Slack [documentation](https://api.slack.com/messaging/composing).
* output.integrations.facebook: any JSON you want included in the message field of a response intended for Facebook Messenger. For more information about the Facebook JSON format, see the Facebook [documentation](https://developers.facebook.com/docs/messenger-platform/send-messages/templates).
Data is stored in the nlclassifier-icp bucket. In Watson Assistant, MinIO is often referred to as COS, which stands for Cloud Object Storage. For more information, see [MinIO](https://cloud.ibm.com/docs/assistant-data?topic=assistant-data-architecturearchitecture-minio).





 Architecture changes 



* 1.5.0: The following changes to the architecture occurred with this release:



* The Analytics, Integrations, and Numeric system entities microservices were introduced.
* The Elastic search and Kafka data sources were introduced. The MongoDB data source was removed.



* 4.7.0: The following changes to the architecture occurred with this release:



* The Multicloud Object Gateway was introduced. The MinIO data source and SIREG microservice were removed.











 Training component 

Training a new model is one-time, short-running, resource-heavy activity. Models are trained in pods that are created on demand. The same pods are removed after the training is completed. Because of its transient nature, the training component is not considered to be one of the standard Watson Assistant microservices. The component, the training pods, only get used when a model needs to be trained. Training starts each time the intent user examples are added or changed in a dialog skill.

The CLU microservice notifies the Master microservice when a new machine learning model needs to be trained. The Master microservice dynamically creates training pods. It handles the training pod removal and retraining if a training run fails. It also is responsible for removing a model from MinIO if the model is deleted. The system determines whether a training run completed successfully based on a flag that is stored in MinIO storage. The Master microservice must have API access to the Docker registry where the training images are stored. The image metadata that is obtained from the registry is used to correctly start the training pods.

The training pods that are started by this component are sometimes referred to as SLAD pods.
(https://cloud.ibm.com/docs-content/v1/content/a2b18c153837bce00a5b4de496e4b4ca64bbf56e/assistant-data/images/gs-ass-add-pattern.png)
6. Add the following regular expression to the Pattern field: [A-Z]{2}d{5}

![Shows that one pattern has been specified for the @order_number entity.](https://cloud.ibm.com/docs-content/v1/content/a2b18c153837bce00a5b4de496e4b4ca64bbf56e/assistant-data/images/gs-ass-entity-added-pattern.png)
7. Click Add value.

![Shows that the pattern value was added.](https://cloud.ibm.com/docs-content/v1/content/a2b18c153837bce00a5b4de496e4b4ca64bbf56e/assistant-data/images/gs-ass-entity-value-added.png)
8. Click the Close![Close arrow](https://cloud.ibm.com/docs-content/v1/content/a2b18c153837bce00a5b4de496e4b4ca64bbf56e/assistant-data/images/close_arrow.png) icon to finish adding the @order_number entity.

![Shows that the @order_number entity was added.](https://cloud.ibm.com/docs-content/v1/content/a2b18c153837bce00a5b4de496e4b4ca64bbf56e/assistant-data/images/gs-ass-entity-added.png)







 Add a cancel order intent 



1. Click the Intents tab.
2. Click Create intent.
3. Enter cancel_order in the Intent name field, and then click Create intent.
[Shows the user choosing to add a pattern for the entity.](https://cloud.ibm.com/docs-content/v1/content/417db917d18067d9dcc4cf2612564a9a87c3ddc8/assistant/images/gs-ass-add-pattern.png)
6. Add the following regular expression to the Pattern field: [A-Z]{2}d{5}

![Shows that one pattern has been specified for the @order_number entity.](https://cloud.ibm.com/docs-content/v1/content/417db917d18067d9dcc4cf2612564a9a87c3ddc8/assistant/images/gs-ass-entity-added-pattern.png)
7. Click Add value.

![Shows that the pattern value was added.](https://cloud.ibm.com/docs-content/v1/content/417db917d18067d9dcc4cf2612564a9a87c3ddc8/assistant/images/gs-ass-entity-added-pattern.png)
8. Click the Close![Close arrow](https://cloud.ibm.com/docs-content/v1/content/417db917d18067d9dcc4cf2612564a9a87c3ddc8/assistant/images/close_arrow.png) icon to finish adding the @order_number entity.

![Shows that the @order_number entity was added.](https://cloud.ibm.com/docs-content/v1/content/417db917d18067d9dcc4cf2612564a9a87c3ddc8/assistant/images/gs-ass-entity-added.png)







 Add a cancel order intent 



1. Click the Intents tab.
2. Click Create intent.
3.
* Washington, DC (us-east) as of 14 June 2018
* Sydney, Australia (au-syd) as of 7 May 2018



IBM Cloud® is migrating to token-based Identity and Access Management (IAM) authentication.

For new service instances in the regions listed, you use IAM for authentication. You can pass either a bearer token or an API key. Tokens support authenticated requests without embedding service credentials in every call. API keys use basic authentication.

For all new and existing service instances in other regions, you continue to use service credentials ({username}:{password}) for authentication.

When you use any of the Watson SDKs, you can pass the API key and let the SDK manage the lifecycle of the tokens. For more information and examples, see [Authentication](https://cloud.ibm.com/apidocs/assistant/assistant-v2authentication) in the API reference.

If you are not sure which type of authentication to use, view the Watson Assistant credentials by clicking the service instance from the Services section of the [IBM Cloud Resource List](https://cloud.ibm.com).





 25 May 2018 

New sample workspace
: The sample workspace that is provided for you to explore or to use as a starting point for your own workspace has changed. The Car Dashboard sample was replaced by a Customer Service sample. The new sample showcases how to use content catalog intents and other newer features to build a bot. It can answer common questions, such as inquiries about store hours and locations, and illustrates how to use a node with slots to schedule in-store appointments.

HTML rendering was added to Try it out
: The "Try it out" pane now renders HTML formatting that is included in response text. Previously, if you included a hypertext link as an HTML anchor tag in a text response, you would see the HTML source in the "Try it out" pane during testing. It used to look like this:

Contact us at <a href="https://www.ibm.com">ibm.com</a>.

Now, the hypertext link is rendered as if on a web page.
(For more information, see [Model mesh](https://cloud.ibm.com/docs/assistant-data?topic=assistant-data-architecturearchitecture-model-mesh).) The ED-MM microservice is called by the TAS microservice to evaluate user input only if the dialog skill that is being processed has contextual entities in its training data. Contextual entities are bound to a context. The ED-MM microservice loads the models from MinIO. At run time, the models are used to look up the entities and validate the context. The ED-MM microservice also accesses the CLU Embedding service for word embeddings.
* Gateway: An adaption layer that interacts with IBM Cloud Pak for Data API and mimics the behavior of the public IBM Cloud. Its pods are named ${release-name}-addon-assistant-gw-deployment.

The ${release-name} is watson-assistant.

It serves the following functions:



* Registers the installation of Watson Assistant into IBM Cloud Pak for Data.
* For API requests, it adds authentication data that is required by the Store microservice.
* Notifies the Store microservice when a service instance is created or deleted.
* When a user requests instance details from the web UI, it mimics the IBM Cloud interface so the UI microservice can return the information.



When an API request comes in, it is processed by the IBM Cloud Pak for Data ingress nginx server first. The nginx server is configured to call the Gateway microservice to check authorization and obtain authentication data for the request. The nginx server adds a header to the original request, and then calls the Store microservice. However, the initial steps do not produce any logs. To see the first logs from an incoming API request, check the logs in the Store microservice.
* Integrations: Service that supports the built-in integrations, such as web chat and preview link. Introduced with the 1.5.0 release.
* Master: Controls the lifecycle of underlying intent and entity models.
v1 [cURL](https://cloud.ibm.com/apidocs/assistant/assistant-v1updateentity)[node](https://cloud.ibm.com/apidocs/assistant/assistant-v1?code=nodeupdateentity)[java](https://cloud.ibm.com/apidocs/assistant/assistant-v1?code=javaupdateentity)[python](https://cloud.ibm.com/apidocs/assistant/assistant-v1?code=pythonupdateentity) 
 Delete entity Delete an entity from a workspace, or disable a system entity. v1 [cURL](https://cloud.ibm.com/apidocs/assistant/assistant-v1deleteentity)[node](https://cloud.ibm.com/apidocs/assistant/assistant-v1?code=nodedeleteentity)[java](https://cloud.ibm.com/apidocs/assistant/assistant-v1?code=javadeleteentity)[python](https://cloud.ibm.com/apidocs/assistant/assistant-v1?code=pythondeleteentity) 
 List entity mentions List mentions for a contextual entity. An entity mention is an occurrence of a contextual entity in the context of an intent user input example. v1 [cURL](https://cloud.ibm.com/apidocs/assistant/assistant-v1listmentions)[node](https://cloud.ibm.com/apidocs/assistant/assistant-v1?code=nodelistmentions)[java](https://cloud.ibm.com/apidocs/assistant/assistant-v1?code=javalistmentions)[python](https://cloud.ibm.com/apidocs/assistant/assistant-v1?code=pythonlistmentions) 
 List entity values List the values for an entity.
// Client Creation.
var config = {
endpoint: COS_ENDPOINT,
apiKeyId: COS_API_KEY_ID,
ibmAuthEndpoint: COS_AUTH_ENDPOINT,
serviceInstanceId: COS_RESOURCE_INSTANCE_CRN,
signatureVersion: 'iam'
};

var cos = new ibm.S3(config);

// Create new bucket with objectlock enabled.
function createBucket(bucketName) {
console.log(Creating new bucket: ${bucketName});
return cos.createBucket({
Bucket: bucketName,
ObjectLockEnabledForBucket: true,
CreateBucketConfiguration: {
LocationConstraint: ''
},
}).promise()
.then((() => {
console.log(Bucket: ${bucketName} created!);
}))
.catch((e) => {
console.error(ERROR: ${e.code} - ${e.message}n);
});
}

// Create new text file and upload the object to COS bucket.
function createTextFile(bucketName, itemName, fileText) {
console.log(Creating new item: ${itemName});
return cos.putObject({
Bucket: bucketName,
Key: itemName,
Body: fileText
}).promise()
.then(() => {
console.log(Item: ${itemName} created!);
logDone();
})
.catch(logError);
}

function putObjectLockConfigurationonBucket(bucketName) {
console.log(Putting Objectlock Configuration on : ${bucketName});
// Putting objectlock configuration
var defaultRetention = {Mode: 'COMPLIANCE', Days: 1}
The gateway status appears as pending while the VPN gateway is being created, and the status becomes available when creation is complete. Creation can take a few minutes.

You can check the gateway's status with the following command:

curl -X GET "$vpc_api_endpoint/v1/vpn_gateways/$gwid2?version=$api_version&generation=2" -H "Authorization: $iam_token"

Save the public_ip.address of the second VPN gateway, for example:

export gwaddress2=<your_vpngateway_public_ip>





 Step 3. Create a VPN connection from the first VPN gateway to the second VPN gateway 

When you create the connection for the VPN gateway of VPC 1, set local_cidrs to the subnets on VPC 1 and set peer_cidrs to the subnets on VPC 2. Separate multiple CIDRs with commas. Remember to update the variable vpc_api_endpoint depending on the region the VPN gateway is in.

export Vpc1Subnets=<your_vpc1_subnets>
export Vpc2Subnets=<your_vpc2_subnets>

curl -X POST "$vpc_api_endpoint/v1/vpn_gateways/$gwid1/connections?version=$api_version&generation=2" -H "Authorization: $iam_token" -d '{
"name": "vpn-connection-to-vpn-gateway-2",
"peer_address": "'$gwaddress2'",
"psk": "VPNDemoPassword",
"local_cidrs": [ "'$Vpc1Subnets'" ],
"peer_cidrs": [ "'$Vpc2Subnets'" ]
}'

Sample output:

{
"id": "0738-a252d380-0784-45ff-8fc0-c2b58e446b4d",
create a random, base64-encoded, 32-byte key material
$ KEY_MATERIAL=$(openssl rand -base64 32)

 extract the public key that was created by the "kp import-token create" command
$ PUBLIC_KEY=$(ibmcloud kp import-token show | jq -r '.["payload"]')

 encrypt the key material using the public key
$ ibmcloud kp import-token key-encrypt -k $KEY_MATERIAL -p $PUBLIC_KEY

Encrypted Key
Ela33aTdDiKVUNryLeM/xwUEaKWvzY+u ...<redacted>... Asv7bZxvyZn9KNU=





 Required parameters 



* -i, --instance-id

The IBM Cloud instance ID that identifies your Key Protect instance.

You can set an environment variable instead of specifying -i with the following command: $ export KP_INSTANCE_ID=<INSTANCE_ID>.
* -k, --key

The base64-encoded key material that you store and manage in the service.

-p, --pubkey

The base64-encoded public encryption key that was distributed by Key Protect. To create new public key, use ibmcloud kp import-token create. To retrieve a public key, use ibmcloud kp import-token show.







 Optional parameters 



* -a, --hash

The hash algorithm used to wrap the key. SHA1 and SHA256 are supported. The default is SHA256. SHA1 is only supported by HPCS.

This option is used to generate an encrypted key that can only be used in a request with the HPCS API. Do not use this option to create Key Protect root keys.

Hyper Protect Crypto Services (HPCS) is a dedicated key management service and hardware security module (HSM). HPCS integrates with Key Protect to generate and encrypt keys. The Keep Your Own Key (KYOK) function is also enabled by HPCS.







 Notes
d - instance: my-kms-1
 e - key name: my-cos-key
 f - button: Create bucket

 capture the name of the COS bucket that was created
$ COS_BUCKET=my-cos-kms-bucket

 view the KP registration; it's a result of creating the COS bucket
$ ibmcloud kp registrations --output json

[
{
"keyId": "2cbea94c-6070-4a24-b0f8-7a56e4d7cb6f",
"resourceCrn": "crn:v1:bluemix:public:cloud-object-storage:global:a/ea998d3389c3473aa0987652b46fb146:4b636e74-f3ca-40bb-80b8-3bd21801ccb8:bucket:my-cos-kms-bucket",
"createdBy": "crn-crn:v1:bluemix:public:cloud-object-storage:global:a/ea998d3389c3473aa0987652b46fb146:4b636e74-f3ca-40bb-80b8-3bd21801ccb8::",
"creationDate": "2020-06-15T16:07:37Z",
"lastUpdated": "2020-06-15T16:07:37Z",
"keyVersion": { "id": "2cbea94c-6070-4a24-b0f8-7a56e4d7cb6f", "creationDate": "2020-06-15T16:05:53Z"
}
}
]

 list the bucket
$ ibmcloud cos list-buckets --ibm-service-instance-id $COS_INSTANCE_ID

OK
1 bucket found in your account:
Name Date Created
step_handler.create create a step handler 
 step_handler.delete delete a step handler 
 step_handler.update update a step handler 
 synonym.create creates a synonym for an entity value 
 synonym.delete deletes a synonym that is associated with an entity value 
 synonym.update edits a synonym that is associated with an entity value 
 userdata.delete deletes data that was created by a specified customer 
 value.create creates an entity value 
 value.delete deletes an entity value 
 value.update edits an entity value 
 workspace.create creates a workspace 
 workspace.delete deletes a workspace 
 workspace.update makes changes to a workspace 







 Additional information for update events 

Any of the update events include this additional information in a requestData.update object:



* Name changed
* Title changed
* Metadata changed
* Training data changed



This example from an assistant.update event shows a name change:

"update":[{"updateType":"Name changed","nameAttribute":"name","newValue”:”Banking Bot 2},{“updateType":"Metadata changed","attributesUpdated":"description","language"]}],"environment":"draft"},
Creating scopes with the API 

A scope is a runtime action in your application that can be taken by users who are granted the required permissions to complete them. Scopes are created when you register your application with App ID. If your app is already registered, you can edit it to include scopes.

The values of scope names must meet the following requirements:



* Be alphanumeric
* Be lowercase
* Not start with appid or openid
* Not contain special characters other than periods (.) or underscores (_)
* Be fewer than 50 characters.



To create a scope, you can use the App ID UI.



1. Create the scopes by making the following request to the /scopes endpoint.

curl -X PUT "https://<region>.appid.cloud.ibm.com/management/v4/<tenantID>/applications/<clientID>/scopes"
-H "accept: application/json"
-H "Content-Type: application/json"
-d "{ "scopes": [ <scopesObject>}" ]}"



 Variable Description 

 region The region in which your instance of App ID is provisioned. Learn more about the [available regions](https://cloud.ibm.com/docs/appid?topic=appid-regions-endpoints). 
 tenantID The unique identifier for your instance of App ID. You can find this value in the credentials for your app as they're listed in the Applications tab of the service dashboard. 
 clientID The unique identifier for your application. You can find this value in the credentials for your app as they're listed in your Applications in the service dashboard. 
 scopesObject A JSON object of all the scopes that you want to create for your application. 
 {: caption="Table 1. Required variables to call the /scopes endpoint" caption-side="top"} 



2. Optional: Confirm that the scopes were created.
By default the create VPC process defines three subnets. If you need to edit the properties that are defined for the subnet, click the pencil icon for the subnet that you want to edit. You can also remove a subnet that is pre-defined by clicking the minus icon. If you need to add a subnet, complete the following steps.
11. Click Add subnet and enter a name for the new subnet in your VPC, such as my-subnet.
12. Select a location for the subnet. The location consists of a region and a zone.

The region that you select is used as the region of the VPC. All additional resources that you create in this VPC are created in the selected region.
13. Select a resource group for the subnet.
14. Enter an IP range for the subnet in CIDR notation, for example: 10.240.0.0/24. In most cases, you can use the default IP range. If you want to specify a custom IP range, you can use the IP range calculator to select a different address prefix or change the number of addresses.

A subnet cannot be resized after it is created.
15. Attach a public gateway to the subnet if you want to allow all attached resources to communicate with the public internet.

You can also attach the public gateway after you create the subnet.
16. Click Create virtual private cloud.







 Step 2: Configuring the ACL 

You can configure the ACL to limit inbound and outbound traffic to the subnet. By default, all traffic is allowed.

Each subnet can be attached to only one ACL. However, each ACL can be attached to multiple subnets.

To configure the ACL:



1. In the navigation pane, click Network > Subnets.
2. Click the subnet that you created.
3. In the Subnet details area, click the name of the ACL.
4.