Reputation: 43
Hi I've created a watson service with the conversation api.
I've created a normal demo of the simple chat application. It is working as expected but i didn't understand how did they create the dynamic variable setting in the response of the network call.
This is the link of the car demo chat application
P.s the response has few variables set in the context. I didn't know how to do this.
I've searched for the documentation of them, but left with no help.
Upvotes: 1
Views: 637
Reputation: 5338
You can use context variables to get some data typed from user or get the exactly data with Regex.
In this case, for use, you have to create one flow inside conversation API, and, 1st, request the data, and in the next node, add the "context" with for extract all data user has typed.
You can use system entities too, and get data with @nameOfyourEntitie.
1st node:
{
"output": {
"text": {
"values": [
"Please, type your number."
],
"selection_policy": "sequential"
}
}
}
2nd node:
{
"context": {
"number": "<? input.text ?>"
},
"output": {
"text": {
"values": [
"The number is $number."
],
"selection_policy": "sequential"
}
}
}
For use this data inside conversation and confirm, for example, you can use $number, and you're have sure the context variable is definied for user in your application for what you want.
See one example inside conversation with regex:
Obs.: You can user regex inside condition or inside context variables for extract the data.
{
"context": {
"number": "<? input.text.extract('^([0-9]+)(.*)') ?>"
}
Upvotes: 2
Reputation: 330
Those are context variables.
The dialog is stateless, meaning that it does not retain information from one interchange to the next. Your application is responsible for maintaining any continuing information. However, the application can pass information to the dialog, and the dialog can update the context information and pass it back to the application.
The dialog context is the mechanism for passing information between the dialog and your application code.
You can read more about Context variables here https://www.ibm.com/watson/developercloud/doc/conversation/dialog-build.html#context-variables
Upvotes: 1