vania-janet/multiturn-rag-retrieval-data huggingface dataset:
"prefixText": "%s."
}
}
}
}
Show more

First the value specified in the title attribute is displayed to the user. Then, the text specified in each label attribute. For example, Which of these items do you want to insure? 1.Boat 2.Car 3.House

To configure what the assistant shows before each option, edit the prefixText parameter. Use %s to represent the number corresponding to the option; it is replaced with the actual number at run time.

"smsAction": {
"command": "smsActSetOptionsConfig",
"parameters": {
"prefixText": "Enter %s for "
}
}

For example, Which of these items do you want to insure? Enter 1 for Boat Enter 2 for Car Enter 3 for House





 Disambiguation list 

When the dialog is confident that more than one dialog node might be the right one to process in response to a customer query, disambiguation is triggered. Disambiguation asks the customer to clarify which path they want to follow to get an answer. For more information, see [Disambiguation](https://cloud.ibm.com/docs/assistant?topic=assistant-dialog-runtimedialog-runtime-disambiguation).

You can customize how the disambiguation list choices are displayed and how a customer can select a disambiguation choice by adding the smsActSetDisambiguationConfig action command.

You might want to define the customization in the welcome node or another node that is triggered early in the conversation so it is applied any time disambiguation is triggered.

{
"output": {
"generic": [
]
},
"context": {
"smsAction": {
"command": "smsActSetDisambiguationConfig",
"parameters": {
"prefixText": "%s."
}
}
}
}
}

Change it to look like this:

{
"context": {
"guests": "@sys-number"
}
}
5. Save your changes.

You must edit the context variable value in the JSON editor. Do not edit the value in the slot's Check for field. The Check for field must remain set to @sys-number >= 0. { :important}

When you edit the value in the JSON editor, you are effectively changing only what to save in the context variable. However, you do not want to change what to look for in the input. These two values will be different. That is how you want it to be.
6. Test the node again. Open the "Try it out" pane, and click Clear to delete the slot context variable values that you specified when you tested the node with slots earlier. To see the impact of the changes you made, use the following script:



Script details

 Speaker Utterance 

 You i want to make a reservation 
 Watson I can make a reservation for you. Just tell me the day and time of the reservation, and how many people it is for. 
 You We want to dine May 23 at 8pm. There will be 0 guests. 



This time Watson responds with, OK. I am making you a reservation for 0 on Wednesday, May 23 at 8:00 PM.



You have successfully formatted the number slot so that it treats zeros properly. Of course, you might not want the node to accept a zero as a valid number of guests. You will learn how to validate values that are specified by users in the next step.





 Step 4: Validate user input 

So far, we have assumed that the user will provide the appropriate value types for the slots. That is not always the case in reality. You can account for times when users might provide an invalid value by adding conditional responses to slots. In this step, you will use conditional slot responses to perform the following tasks:



* Ensure that the date requested is not in the past.
* Check whether a requested reservation time falls within the seating time window.
"conditions": "no",
"output":{
"text": {
"values": [
"Let's try this again. Tell me what size pizza
you want and the time..."
]
}
},
"context":{
"size": null,
"time": null,
"confirmation": null
}
}
Show more





 Collecting summary information from the customer 

You might want to prompt a user to supply free form text in a dialog node with slots that you can save and refer to later. To do so, follow these steps:



1. In the Check for field, add the following special property: slot_in_focus.
2. Optionally, change the context variable name for the slot in the Save it as field. For example, you might want to change it to something like summary.
3. In the If not present, ask field, ask the user to provide open-ended information. For example, Can you summarize the problem?
4. To store the input in the customer's exact words, edit what is saved by using the JSON editor.
5. Open the slot to edit it by clicking the Customize slot![Customize slot](https://cloud.ibm.com/docs-content/v1/content/417db917d18067d9dcc4cf2612564a9a87c3ddc8/assistant/images/edit-slot.png) icon. From the Options![More icon](https://cloud.ibm.com/docs-content/v1/content/417db917d18067d9dcc4cf2612564a9a87c3ddc8/assistant/images/kebab.png) menu, open the JSON editor.
6. Change the context variable value.

The value will look like this:

{
"context": {
"summary": "slot_in_focus"
}
}
(https://cloud.ibm.com/docs-content/v1/content/a2b18c153837bce00a5b4de496e4b4ca64bbf56e/assistant-data/images/contextvar-json-slot-multi-response.png)
* To add a context variable that is set or updated after a slot condition is met, complete the following steps:



1. Click the Edit slot icon ![Edit response](https://cloud.ibm.com/docs-content/v1/content/a2b18c153837bce00a5b4de496e4b4ca64bbf56e/assistant-data/images/edit-slot.png).
2. From the Options![Advanced response](https://cloud.ibm.com/docs-content/v1/content/a2b18c153837bce00a5b4de496e4b4ca64bbf56e/assistant-data/images/kabob.png) menu in the Configure slot view header, click Open JSON editor.
3. Add the variable name and value pair in JSON format.

{
"time_of_day": "morning"
}



There is currently no way to use the context editor to define context variables that are set during this phase of dialog node evaluation. You must use the JSON editor instead. For more information about using the JSON editor, see [Context variables in the JSON editor](https://cloud.ibm.com/docs/assistant-data?topic=assistant-data-dialog-runtime-contextdialog-runtime-context-var-json).

![Shows how to access the JSON editor associated with a slot condition.](https://cloud.ibm.com/docs-content/v1/content/a2b18c153837bce00a5b4de496e4b4ca64bbf56e/assistant-data/images/contextvar-json-slot-condition.png)
From the Customize pane where you enabled the Slots feature, select the Prompt for everything checkbox to enable the intial prompt. This setting adds the If no slots are pre-filled, ask this first field to the node, where you can specify the text that prompts the user for everything.





 Capturing multiple values 

You can ask for a list of items and save them in one slot.

For example, you might want to ask users whether they want toppings on their pizza. To do so define an entity (@toppings), and the accepted values for it (pepperoni, cheese, mushroom, and so on). Add a slot that asks the user about toppings. Use the values property of the entity type to capture multiple values, if provided.



Multiple value slot

 Check for Save it as Prompt Follow-up if found Follow-up if not found 

 @toppings.values $toppings Any toppings on that? Great addition. What toppings would you like? We offer ... 



To reference the user-specified toppings later, use the <? $entity-name.join(',') ?> syntax to list each item in the toppings array and separate the values with a comma. For example, I am ordering you a $size pizza with <? $toppings.join(',') ?> for delivery by $time.





 Reformatting values 

Because you are asking for information from the user and need to reference their input in responses, consider reformatting the values so you can display them in a friendlier format.

For example, time values are saved in the hh:mm:ss format. You can use the JSON editor for the slot to reformat the time value as you save it so it uses the hour:minutes AM/PM format instead:

{
"context":{
"time": "<? @sys-time.reformatDateTime('h:mm a') ?>"
}
}

See [Expression language methods](https://cloud.ibm.com/docs/assistant?topic=assistant-dialog-methods) for other reformatting ideas.





 Dealing with zeros
[More icon](https://cloud.ibm.com/docs-content/v1/content/a2b18c153837bce00a5b4de496e4b4ca64bbf56e/assistant-data/images/kabob.png) menu, open the JSON editor.
3. Change the context variable value.

The value will look like this:

{
"context": {
"number": "@sys-number >= 0"
}
}

Change it to look like this:

{
"context": {
"number": "@sys-number"
}
}
4. Save your changes.



The change you made to the context variable value is not reflected in the Check for field, which is appropriate. Do not edit the value of the Check for field or even click in the field. If you do, the change you made to the JSON will be lost.

If you do not want to accept a zero as the number value, then you can add a conditional response for the slot to check for zero, and tell the user that they must provide a number greater than zero. But, it is important for the slot condition to be able to recognize a zero when it is provided as input.





 Getting confirmation 

Add a slot after the others that asks the user to confirm that the information you have collected is accurate and complete. The slot can look for responses that match the #yes or #no intent.



Confirmation slot

 Check for Save as Prompt Follow-up if found Follow-up if not found 

 #yes || #no $confirmation I'm going to order you a `$size` pizza for delivery at `$time`. Should I go ahead? Your pizza is on its way! see *Complex response* 



Complex response Because users might include affirmative or negative statements at other times during the dialog (Oh yes, we want the pizza delivered at 5pm) or (no guests tonight, let's make it a small), use the slot_in_focus property to make it clear in the slot condition that you are looking for a Yes or No response to the prompt for this slot only.
(https://cloud.ibm.com/docs-content/v1/content/417db917d18067d9dcc4cf2612564a9a87c3ddc8/assistant/images/contextvar-json-slot-multi-response.png)
* To add a context variable that is set or updated after a slot condition is met, complete the following steps:



1. Click the Edit slot icon ![Edit response](https://cloud.ibm.com/docs-content/v1/content/417db917d18067d9dcc4cf2612564a9a87c3ddc8/assistant/images/edit-slot.png).
2. From the Options![Advanced response](https://cloud.ibm.com/docs-content/v1/content/417db917d18067d9dcc4cf2612564a9a87c3ddc8/assistant/images/kebab.png) menu in the Configure slot view header, click Open JSON editor.
3. Add the variable name and value pair in JSON format.

{
"time_of_day": "morning"
}



There is currently no way to use the context editor to define context variables that are set during this phase of dialog node evaluation. You must use the JSON editor instead. For more information about using the JSON editor, see [Context variables in the JSON editor](https://cloud.ibm.com/docs/assistant?topic=assistant-dialog-runtime-contextdialog-runtime-context-var-json).

![Shows how to access the JSON editor associated with a slot condition.](https://cloud.ibm.com/docs-content/v1/content/417db917d18067d9dcc4cf2612564a9a87c3ddc8/assistant/images/contextvar-json-slot-condition.png)











 Context variables in the JSON editor
It lets the user answer the question incorrectly 3 times before applying a size (medium) to the variable for the user. (You can include a confirmation slot where users can always correct the size when they are asked to confirm the order information.)

Check for: @size Save it as: $size Not found catchall condition:

{
"output": {
"text": {
"values": [
"What size did you want? We have small, medium, and large."
],
"selection_policy": "sequential"
}
},
"context": {
"counter": "<? context['counter'] + 1 ?>"
}
}

To respond differently after 3 attempts, add another Not found condition like this:

{
"conditions": "$counter > 1",
"output": {
"text": {
"values": [
"We will bring you a size medium pizza."
]
}
},
"context": {
"size": "medium"
}

This Not found condition is more precise than the Not found catchall condition, which defaults to true. Therefore, you must move this response so it comes before the original conditional response or it will never be triggered. Select the conditional response and use the up arrow to move it up.

 Preventing a Found response from displaying when it is not needed {: dialog-slots-stifle-found-responses}

If you specify Found responses for multiple slots, then if a user provides values for multiple slots at once, the Found response for at least one of the slots will be displayed. You probably want either the Found response for all of them or none of them to be returned.

To prevent Found responses from being displayed, you can do one of the following things to each Found response:

- Add a condition to the response that prevents it from being displayed if particular slots are filled. For example, you can add a condition, like !($size && $time), that prevents the response from being displayed if the $size and $time context variables are both provided.
You must move this response so it comes before the original conditional response or it will never be triggered. Click the response you just added, and use the up arrow to move it up, and then click Save.
13. Test your changes by using the following script.





 Speaker Utterance 

 You i want to make a reservation 
 Watson I can make a reservation for you. Just tell me the day and time of the reservation, and how many people it is for. 
 You tomorrow 
 Watson Friday, December 29 it is. What time do you want the reservation to be made for? 
 You orange 
 Watson Please specify the time that you want to eat. The restaurant seats people between 9AM and 9PM. 
 You pink 
 Watson Please specify the time that you want to eat. The restaurant seats people between 9AM and 9PM. 
 You purple 
 Watson You seem to be having trouble choosing a time. I will make the reservation at 8PM for you. How many people will be dining? 





 Summary 

In this tutorial you tested a node with slots and made changes that optimize how it interacts with real users. For more information about this subject, see [Gathering information with slots](https://cloud.ibm.com/docs/assistant-data?topic=assistant-data-dialog-slots).







 Next steps 

Deploy your dialog skill by first connecting it to an assistant, and then deploying the assistant. For more details, see [Deploying](https://cloud.ibm.com/docs/assistant-data?topic=assistant-data-deploy-custom-app).
"values": [
"Alright. Let's start over. I'll try to keep up this time."
]
}
},
"context":{
"date": null,
"time": null,
"guests": null
}
}
4. Click Back, and then click Save.
5. Click the Edit slot![Edit slot](https://cloud.ibm.com/docs-content/v1/content/a2b18c153837bce00a5b4de496e4b4ca64bbf56e/assistant-data/images/edit-slot.png) icon for the confirmation slot again. In the Not found prompt, clarify that you are expecting the user to provide a Yes or No answer. Add a response with the following values.



Not found response details

 Condition Response 

 `true` Respond with Yes to indicate that you want the reservation to be made as-is, or No to indicate that you do not. 



6. Click Save.
7. Now that you have confirmation responses for slot values, and you ask for everything at once, you might notice that the individual slot responses are displayed before the confirmation slot response is displayed, which can appear repetitive to users. Edit the slot found responses to prevent them from being displayed under certain conditions.
8. Replace the true condition that is specified in the JSON snippet for the last conditional response in the @sys-date slot with !($time && $guests). For example:



Slot 1 conditional response 2 details

 Condition Response Action 

 `!($time && $guests)` $date it is Move on 



9. Replace the true condition that is specified in the JSON snippet for the last conditional response in the @sys-time slot with !($date && $guests). For example:



Slot 2 conditional response 3 details

 Condition Response Action 

 `!($date && $guests)` Ok, the reservation is for $time. Move on 



10.
You We want to dine May 23 at 8pm. There will be 0 guests. 
 Watson How many people will be dining? 
 You 0 
 Watson How many people will be dining? 



You will be stuck in this loop until you specify a number other than 0.
2. To ensure that the slot treats zeros properly, change the slot condition from @sys-number to @sys-number >= 0.
3. Now, you will change the context variable that is stored for the number.

The slot condition is used both to check the user input for a number value, and to store that number in a context variable. Now that you have edited the condition in the Check for field, you will find mentions of the number zero.

However, you want to save only the number, and store it in the context variable. Therefore, open the slot to edit it by clicking the Edit slot![Edit slot](https://cloud.ibm.com/docs-content/v1/content/417db917d18067d9dcc4cf2612564a9a87c3ddc8/assistant/images/edit-slot.png) icon. From the Options![More icon](https://cloud.ibm.com/docs-content/v1/content/417db917d18067d9dcc4cf2612564a9a87c3ddc8/assistant/images/kebab.png) menu, open the JSON editor.
4. Change the context variable value.

The value will look like this:

{
"context": {
"guests": "@sys-number >= 0"
}
}

Change it to look like this:

{
"context": {
"guests": "@sys-number"
}
}
5. Save your changes.

You must edit the context variable value in the JSON editor. Do not edit the value in the slot's Check for field. The Check for field must remain set to @sys-number >= 0.
Do not set a value in the first context variable in the list and expect to be able to use it in the second variable in the list, because there is no guarantee that the first context variable will be executed before the second one. For example, do not use two context variables to implement logic that checks whether the user input contains the word Yes in it.



Using two context variables to check for a value in user input

 Variable Value 

 user_input <? input.text ?> 
 contains_yes <? $user_input.contains('Yes') ?> 



Instead, use a slightly more complex expression to avoid having to rely on the value of the first variable in your list (user_input) being evaluated before the second variable (contains_yes) is evaluated.



Using a single context variable

 Variable Value 

 contains_yes <? input.text.contains('Yes') ?> 







 Adding context variables to a node with slots 

For more information about slots, see [Gathering information with slots](https://cloud.ibm.com/docs/assistant?topic=assistant-dialog-slots).



1. Open the node with slots in the edit view.



* To add a context variable that is processed after a response condition for a slot is met, perform the following steps:



1. Click the Edit slot icon ![Edit response](https://cloud.ibm.com/docs-content/v1/content/417db917d18067d9dcc4cf2612564a9a87c3ddc8/assistant/images/edit-slot.png).
2. Click the Options icon ![Advanced response](https://cloud.ibm.com/docs-content/v1/content/417db917d18067d9dcc4cf2612564a9a87c3ddc8/assistant/images/kebab.png), and then select Enable conditional responses.
3. Click the Edit response icon !
For example, in a cURL request, you must set the servicekey header as follows:

-H "servicekey: <SERVICE_KEY>"





 Body parameters 

The following fields are body parameters that you can set in the API request:



 name (string) 

Specifies the name of the view.

The following table indicates when the name parameter is required:



Table 2. Required status per method

 Action Request Field required 

 Create a preset POST ![Check mark icon](https://cloud.ibm.com/docs-content/v1/content/6f3c07c34058f637b1c86044ca4f9b24214330a7/activity-tracker/images/checkmark-icon.svg) 
 Modify an existing preset PUT ![Check mark icon](https://cloud.ibm.com/docs-content/v1/content/6f3c07c34058f637b1c86044ca4f9b24214330a7/activity-tracker/images/checkmark-icon.svg) 
 Get preset information GET 
 Delete a preset DELETE 







 channels (array of objects) 

Specifies the notification channels configuration associated with the preset.

The following values can be specifed for all channels.



Channel configuration values for all preset types

 Value Description 

 integration The integration type. Valid values are: slack, email, webhook, pagerduty, pagerduty-auto-resolve, and sysdig. 
 immediate Specified if the alert is sent immediately after the line criteria is met ("immediate": true) or after the line and time criteria is met ("immediate": false). 
 triggerlimit The number of matching log lines to trigger the alert. 
 triggerinterval The amount of time to look for the number of matching log lines.
Optional: If the action you want to call uses a session variable, you can set the value of the session variable when the action is started.

In the Parameters section, add a key and value pair to pass with the call to the action.

Add the variable ID (that you copied to the clipboard earlier) to the Key field, and in the Value field, specify the value that you want to set the variable to.

For example, let's say the action has a session variable named given name. You can pass the current user's given name (which you asked for and saved to a $name context variable) to the action as follows:



Action call key and value pair example

 Key Value 

 given_name "$name" 



7. If you call actions from more than one dialog node, change the name of the return variable to make it unique across all of your dialog nodes. For example, you might already call an action and its return variable is called $action_result_1, so you can name the new one $action_result_2.

The return variable is a context variable that is automatically created. It stores any session variable values that are created or have their values changed while the called action is processed.
8. In the Assistant responds section, the condition for the first conditional response is populated automatically with the return variable from the action call.

The return variable is named $action_result_1 unless you change the name.

If any session variables are created or have their values changed by the called action, then they are returned and stored in the result variable as a JSON object.

For example, if the action changes the value of the given name and membership status session variables, the following JSON object is returned:

{"given_name":"Sally","membership_status":"true"}
9. If you don't send or change any session variables, you can delete the first conditional response. Otherwise, consider adding a response to show when a return variable is sent from the called action.

You might want to specify a custom response to show in case the exchange that took place when the action was processed resulted in a change to the value of the session variable that you passed to the action.