I'm newbie in coding and Watson Conversation and I'm trying to do a chatbot that schedule appointments from Monday to Saturday. I used @sys-date entity and it worked fine, but I don't know how to exclude sunday.For exemple:
watson: What is the best date for you?
user: sunday
watson: On this day the establishment is closed
I tried in the workspace: (condition) if: action=='sunday' like this: workspace
And coded like this in nodejs
// Send the input to the conversation service
conversation.message(payload, function (err, data) {
if (err) {
return res.status(err.code || 500).json(err)
}else if(data.output.action==='sunday'){
var date = new Date();
if(!(date.getDay() % 6)){
return res.json(payload,data.output.text["On this day the establishment is closed"]);
}}else{
return res.json(updateMessage(payload, data));
}});});
And it still gives me the sunday date(ex. 23/04/2017). I know that everything is wrong, but I really tried.. can somebody help me, please? I'd appreciate if you could put the code to help me..
In this case, yes... You can use the parameter data
to send message with Watson and with user. And, you cant exclude "Sunday" from System entities. This entitie is only for help us with special Conditions.
In your case, use:
data.output.text[0] = "On this day the establishment is closed";
Because data.output.text
send Watson message to Conversation.
But, one best practicie for a good chatbot is create Intents
and Entities
to pass Intelligence for your bot and retain as much intelligence as possible in your chatbot. And your app will only check.
For example, create one Entitie @days with values Sunday, monday, etc.
intent
with examples how to ask "schedule appointments"Entitie
@days
with values Sunday, monday, etc. And in your Advance JSON, add one context variable with day value like this:
{
"context": {
"day": "<? @days ?>"
},
"output": {
"text": {
"values": [
"Sorry. On $day the establishment is closed"
],
"selection_policy": "sequential"
}
}
}
Check the flow:
Check the flow works fine:
If not sunday:
Download the workspace to help you more here.