Watson Conversation - handling invalid inputs - ibm-watson

We are building an app using Watson Conversation but are having a problem handling invalid user responses. Our bot is designed to make hotel bookings and a simplified version of the dialog is:
Node 1: clear the context; ask “What date do you want to arrive?”
Node 2: Trigger #sys-date; update context for date; ask “how many
nights do you want to stay”
Node 3: Trigger #sys-number; update
context for number of nights; summarise the booking “So you are
arriving on [DATE] for [NUMBER OF NIGHTS]”
If the user provides sensible answers then all works but if their response to the check-in date is “blah” it fails so we added a new node (as a sibling of node 2) with an “anything_else” trigger and output “sorry we wanted a date, try again”.
Ideally we would want to loop back to our existing Node 2 so that the trigger #sys-date could catch the user’s revised response but that created an infinite loop so we a child node to “anything_else” that is a copy of Node 2 ie update the context for the date and asks “how many nights…” but now we want to catch the response to that question in node 3 so we can pick up the existing flow so added a jump to node 3. This fails as we end up exiting the dialog branch.
If we use "anything_else" to catch invalid user inputs how do we rejoin the existing dialog flow? At the moment the only solution we have is to duplicate nodes 2 and 3 but in the real dialog branch there are many more nodes so that approach is not practical.

You just need to Jump to the node (the small balloon with 3 dots in the left of the node 2). This way, if the user input a invalid date or number, it will return to catch the user valid input and it'll save in the context, like you wanted to do. You can Jump to any node of your workspace. Here is a json exemple. Hope I helped you!

Related

How can I rewrite drupal page metatags from within a Rules module action?

I am trying to detect when a content-type node is updated or saved for the first time and has attached audio.
If this is the case I want to re-write the Twitter Card meta tags to turn an image card into a media card and then include a link to the relevant audio field to complete the media card and player options.
I have a rule set that detects the creation / update of a node; I can screen for nodes of the correct "type", and my rule fires appropriately, but I am failing on my rule action to re-write the meta tags.
Rules tells me that $node is available to me, so I've been trying to do:
$node->metatags[LANGUAGE_NONE]['description']['value'] = 'Some description.';
$node->metatags[LANGUAGE_NONE]['title']['value'] = 'Some title | ZZZ';
This I have followed by an "entity save" action. My rationale is to write the changes before the recursion lock kicks in and stops the rule executing.
I've been going round the houses for a day trying to solve this. Can someone please point me in the right direction?
Many thanks.
Didn't fully understand your requirement. But you can easily update your node datas using hook_node_presave (https://api.drupal.org/api/drupal/modules%21node%21node.api.php/function/hook_node_presave/7.x) before node is being saved in to database.
Use hook_node_insert(https://api.drupal.org/api/drupal/modules%21node%21node.api.php/function/hook_node_insert/7.x) and hook_node_update(https://api.drupal.org/api/drupal/modules%21node%21node.api.php/function/hook_node_update/7.x) if you need to do the same thing after the node is saved in to database

Watson Assistant -- Prompting for required slot not working

I have this node on the dialog tree of my Watson Assistant
So this node should be triggered when an entity #courses with either the value course or math is found.
In case the value of the entity courses is course but not math then the slot still needs to be filled and should prompt the user with 'Which specific course are you referring to?' since the slot is required. The problem I'm having is that the prompt is not getting triggered as shown in this image
So the entity courses with the value course is correctly identified but the prompt is not triggered.w
Am I missing something?
Edit
So modifying the configuration of the slot to add conditional responses I added a conditional response if the value of #courses:math is not found. Notice that I'm checking for the value of #courses:math on the black marked area but then I check on the conditional response if it is not found (red area) and if the value #courses:course is found and then the response should be triggered. So the conditional response should be something like
if #courses:course exists and #courses:math doesn't exist then
print "What specific course are you referring to?"
else if (#courses:course exists and #courses:math exists) or #courses:math exists then
do something else
But this is still not triggering any response for me.
You will need to configure the slot further.
Click the cog out to the side (between required and the trash can). You should see a modal appear that looks similar to the screen shot below. Click the dot dot dot menu at the top and click "Enable Conditional Responses". This will change the modal a bit so you can check the value of the entity. In the screenshot you can see I tested it, and the behavior appears to be what you are looking for.

Edit node after submission on comparing already submitted data in node creation in Drupal 7

Actually i have created one page for registration in the event.
But some how a person is submitting the form mistakenly filled the data (so he/she has to correct those data)
So person need access to edit after filling the search field (validating the data such as (1)Registration ID, (2) Date of Birth and (3) Mobile number ....
if all three details are correct. a submitter will get access to the node edit. But a person does not require to register for doing this.
Kindly help me to create this type facility for my website.
Thanking you.

Add a related record in a modal form in CakePHP

I'm creating a simple app in CakePHP that will be used to record members in a youth group, the idea being that many units around the country (similar to say Scout troops) can login and record new member details, and these records are available at a state and national level.
One of the fields recorded is the school that the new member attends, rather than just enter a text field the school is in a related table and the member 'belongsTo' the school. This gives a nice little drop down field to select the school, however given there are thousands of schools in the country the schools list is by no means complete. To simplify data entry, rather than have the person entering the data either skip that field or have to create the school first, THEN add the member, I'd like to have the option of being able to create the school entry in a modal popup then returning back to the new member entry and having the new school available in the drop down.
I've found a few simplified examples in stack overflow but nothing that meets this need.
Instead of a dropdown of a distracting modal, why don't you simply use a autocomplete/typeahead field?
There are several examples arround like the jQueryUI autocomplete or the Twitter Bootstrap Typeahead and many more if you do a search
You could even make it so that if a new value is entered it is added to the database and available for the next visitor as autocomplete

How to prefill a field of a node using rules in Drupal7?

Using rules it's easy to fill field values of a node after user pressed the save button. Just add a rule on before saving content event. But is it possible to have a rule to prefill a node field before edit form is shown to the user? So he has a change to corrent the default values.
This is a very late reply, but hopefully someone might find it to be of some help:
If you are creating the node using Rules, you could save it first, selecting "Force saving immediately: true". In the next step, you could set the value of the node field. You might need to save again. (also 'Force save' immediately.) And in the next step, do a 'page redirect' to the edit url.
Not sure if this is an elegant way to do it, but it might work. I had a somewhat similar requirement (not the same), and this is how I finally did that - by saving first, and then redirecting to the edit url of the saved node.
Not sure if this is something you can accomplish with rules or not, but if you go to structure->content types you can click "manage fields" and edit the default value of any field other than the title field (which you could always turn off and replace with a custom title field with a default value)
I think there are basically two ways of doing this:
1) Use Rules Forms. I don't know very much about that module, and I have had some less than perfect experiences with the module, but I'm fairly certain it could be done with the module.
2) Use Rules to create a node, populate the relevant field values, and then send the user to the edit page. One downside with this approach is that if the user decides to abort the node creation, you'll end up with a half-populated node that needs deletion in one way or another.
If you choose to go for option 2, and are comfortable with Page manager and Panels, it is probably worth checking out the Rules Panes module.

Resources