I would like avoid asking a users name if it has already been entered earlier in the conversation. How do I set a condition to check if context variable 'sys-person' is empty/null?
Watson Conversation has Context variables to you save what you need in your Dialog flow.
The dialog is stateless, meaning that it does not retain information
from one interchange with the user to the next. Your application is
responsible for maintaining any continuing information that it needs.
However, the application can pass information to the dialog, and the
dialog can update this information and pass it back to the
application. It does so by using context variables.
A context variable is a variable that you define in a node, and
optionally specify a default value for. Other nodes or application
logic can subsequently set or change the value of the context
variable (like: context.variableName = "Jon").
You can condition against context variable values by referencing a
context variable from a dialog node condition to determine whether to
execute a node. And you can reference a context variable from dialog
node response conditions to show different reponses depending on a
value provided by an external service or by the user.
So, you can simple save the name in one context variable, like:
{
"context": {
"nameHere": "<? #sys-person ?>"
},
"output": {
"text": {
"values": [
"Your name is $nameHere."
],
"selection_policy": "sequential"
}
}
}
And you can access this context variable using $nameHere. In my JSON example [Advanced JSON] I show one form to you check it.
See the Official Documentation about Context variables here.
As suggested by Sayuri, create a context variable for user name and check for this context variable in dialog,
In dialog you can use,
if $nameHere:
then:
your response
If this is mandatory variable then using slots would also be choice, which can check and ask for user name in single node
Related
I'm trying out the slots feature in IBM Watson Conversations and have hit an issue which I'm not sure how to work around.
I have a use case that is collecting a number of pieces of information from a user so using the Slots feature makes sense. Unfortunately when I add a Slot with #sys-number the system will not accept 0 as a valid input. This slot is in fact required but 0 is a valid value.
Anyone have an idea of how to have a required Slot of type #sys-number that accepts 0 as a value?
The condition #sys-number is in fact a short hand syntax for condition entities['sys-number'].value. When 0 is sent the condition is evaluated to false as 0 is treated as a false by the expression language evaluator in Watson Conversation Service. Now this is not a desired behavior in this case. To prevent this for happening one can use entities['sys-number'] in the condition that will return true every time #sys-number entity is recognized in the input.
When using this in slot one might want to edit what gets stored in the context variable as changing the condition will also change what is stored in the variable. This can be done by a JSON editor - click configure slot gear next to the slot specification and in the window that opens click three dots, open JSON editor and there change what gets actually stored inside the context variable that gets updated by the slot.
Here is a link to system entity section in Watson Conversation Service documentation.
I had a similar problem with recognising zero values in slots and the system entity documentation did not explain it well enough (for me at least).
Further elaborating on Michal's answer above:
Click the "Edit Slot" option (gear icon)
Set the "Check For" attribute on a slot condition as entities['sys-number']
Click the edit slot modal menu options (three bubbles in corner)
Open the JSON editor
Change the context variable value to "<?entities['sys-number'].value ?>"
Result:
Can I use the context variables in the conditions for the nodes in the dialog flow in the Watson Conversation?
In the case I try it:
if condition: context.variable !== 'undefined' the conversation will flow, else, the conversation will show some text.
How do it?
I try it:
See
And the conversation does not flow... and the intent flow to intent.confidence < 0.3 i've created
Obs.: My context.variablee just get some Data with regex, if user dont type correct, the conversation flow will display another message.
The main issue may be with your regex. You have a dangling * at the end. It should be:
"context": {
"xxx": "<? input.text.extract('^[^\d].*?[\d]{11}.*?$',0) ?>"
},
Before the variable is check you can use the following condition.
input.text.matches('^[^\\d].*?\\d{11}.*?')
When checking to see if the variable is set, you only need to have a condition as follows:
$xxx
Sample conversation script: http://pastebin.com/HuCJckry
I'm trying to create a custom rule (using the Rules module) so that every time the cron runs, this rule checks a date field in a custom content type I created. If that date has passed then I want to set a list widget from active to ended.
This is how far I get when trying to create this rule:
Set React on event to Cron maintenance tasks are performed
Add Condition > Set Select the condition to add to Data comparison > Continue
Here is the issue: Data selectors only has site and no access to field data.
Any ideas where I'm going wrong here?
The problem with Rules condition "Cron maintenance tasks are performed" is that at that point, there is no access to the node object so any checks/manipulations on the node are not possible. As a solution, instead of Event = Cron maintenance tasks are performed, use Event = Node: Content is viewed. You can leave it open for any content type so that when someone visits the website and opens at least one page, some action will be triggered.
You need to create a rules component first:
Go to Rules > Components (admin/config/workflow/rules/components)
Then create a new component and select 'Rule' from select list
Set a name for this component and in the table below select:
Data type: Text Token
Label: A name that you want
Machine name: Use the same name of the label but set here only lower case and underscore
Usage: Parameter
In the component add the condition 'Data comparison' and select node:type
Add other conditions that you want
Set the actions that you want and save
Now go to Rules (admin/config/workflow/rules) and create the rule with action on cron maintenance (as you have already done)
Jump the conditions section and in the actions:
New action: Add a variable
Value: Text
Then write the value of this variable just like the machine name of content type that you want to cycle on (if you want you can change the name and machine name of this variable in the section below)
Now add another action 'Fetch entity by property'
Entity type value: Node
Property value: Type
Data selector: the variable created at the point 8
Now add a loop in parameter list use the variable provided by 'Fetch entity by property'
Add an action in the loop (click on the link to the right of loop row) and select the component created in the point 2 and pass the variable provided by loop
I state: I do not know if it works but at least it should direct you towards the right path
Sorry for my english, I hope you understand everything :)
Yes you should be able to get this to work using the Rules module to implement what you're looking for, but I recommend you to also combine that with the Views Rules module. Some details about this module (from its project page):
Provides Views directly as Rules actions and loops to seamlessly use view result data.
The previous quote may seem a bit cryptic (it may make you think like "so what, how can this help me?"). Therefor some more details about how to move forward using these modules:
Create a view (using Views) so that you have 1 Views result (row) with all the nodes you want to be processed (related to your custom content type and if possible filter somehow using your date field). Whereas that view has fields (columns) for whatever is needed in subsequent steps, e.g the node ID, the date field, and possibly other fields as well. You'll need these View fields later on as values to be processed by your rule, "to set a list widget from active to ended*" (as in your question). Important: use a Views display type of "Rules".
Remove that "add condition" (in the custom rule you started) and, instead, use the Views Rules module to iterate over each of these Views results in a Rules action, using the Rules technique known as a "Rules Loop".
For each iteration step in your Rules loop, perform a Rules Action to "do your thing" (= to set a list widget from active to ended). At that point you'll have all data from each column of your Views results available as so called Rules Parameters. So at that point it's a piece of cake to adapt the value of that list widget for the node you're processing in that loop.
Optionally, you may also want to add whatever extra Rules Condition(s), also up to your own imagination. Typically the things you cannot, or have not yet, expressed as a Views filter. However, if you have a choice between using a Views filter and an extra Rules Condition, I recommend to go for the Views filter, because that will reduce the number of your iterations in your Rules loop (performance!).
Easy, no?
I have a form which has an initial element, I am running a check using the confidence feature to check for other phrases that might match the user's input. If there are then i am going to a menu, from here i am asking the user to input a dtmf value to say whether one of these values where correct. If the user selects an option, i want it to fill that field of which it checked, with that interpretation or possibly go to another form which does the same thing, if i choose to do it using the other form, can u access filled fields from another form?
regards
According to the VoiceXML Specification the scope for that type of variable would only be accessible in the form. But you can assign the values to another variable before leaving the form that has document scope (i.e. defined just below the vxml tag). Or even give it global scope by defining the variable in the root document, which makes it accessible to the whole application.
I have a form where a user can enter a location address as well as the utility companies that provide service to that address. The Utility data is associated to the building:
Location hasMany Utility
Solely within the context of the utility, the name field is required so there's validation indicating as much. Within the context of a location, though, any utility information is optional. The user can choose not to enter that data when entering a location which would simply indicate that they don't want to associate the location with any or all of the utility companies we track.
Using the FormHelper, though, the validation is detected and the field gets marked as required. I want to retain that validation for the instances where utility data is being entered independently, but remove the required indicator on the location form.
I know I can hack this in any number of ways (e.g. removing the required class via javascript, etc.), but I'm wondering if there's a clean way to do this using the Cake API. I haven't seen anything obvious, so I'm hoping someone else has been here and found a clean, simple solution.
Thanks.
You can either ask the user how many utilities they want to add before creating the form, or you can add the Utility record inputs dynamically using js (the later is more work to do, and not as error-proof as the former).
An example of the view (if you want to do it in 1 view):
if (empty($this->data){
// a form to ask how many utility records the users want to create.
}else{
// generate the form based on user input.
}
I assume you know what to do in the controller.
I would add a class to the form element that are optionnal, and use that class to override the "required" indicator.
In fact there is a Cake solution, use the error param
$this->Form->input('Model.field', array('error' => false));
To disable error message output set the error key to false.