Conditionally return from digression in watson assistant - ibm-watson

I have been reading through the documentation and cannot find the answer to this question for Watson Assistant.
I have a digression that I only sometimes want to return back to the previous place in the dialog.
Specifically, after the user enters the digression, if the user responds "Yes" then I do not want the digression to return back, but if the user responds "No" then I do want the digression to return to the previous place.
Is there a way to do this? Perhaps by manually editing the JSON to somehow override the directive to return from the digression in some cases?
Below is a diagram of the issue:
Dialog Flow

There is a function <? clearDialogStack() ?> that when called it will erase all the digressions that are set in dialog and hence the dialog will not return from digression. So just call this function in a node where you don't want WA to return.
Here it is in the doc: https://cloud.ibm.com/docs/services/assistant?topic=assistant-dialog-runtime#dialog-runtime-digressions

If I understand you correctly, you could create two different nodes for handling the user response of "yes" or "no" based on the way digressions are setup today. If yes, the node needs to be configured to not return back (don't click the checkbox). If no, click the checkbox.

Related

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.

AngularJS: How to create a one time page?

I am wondering how one would create a one time page in angularjs. As an example, a user enters his details into a form and submits. If the submission is successful, the user is forwarded to a "thank you" which is only accessible once otherwise forward to the home page for instance. Something similar to the traditional flash message.
If what you want to show is a simple "thank you" screen, my advice would be to keep it simple and use a modal splash. It's what I usually do.
Check out this very good example (and demo here).
I suggest to use Toastr in that case.
Here you can find more examples.
I am new to angular, but I think you can set a $scope variable such as 'allowVisit' and set it to true if you need to allow viewing the thank you page, and If the thank you page found this variable false, it should change the location to /home

Display Alert box through the trigger - salesforce

Is it possible to display an alert message (not error message) through a trigger? I have written a trigger that checks for duplicate accounts in the system. The trigger at the moment gives an error message to the user telling that there is a duplicate account. But, if the user changes the value of a field "Is record near to duplicate?" to YES, the trigger allows the user to save the record.
But, I want to display the error message in an alert pop up box like "Account with this Name exists,are you sure you want to continue" and then user clicks Yes and the record gets created. Any thoughts on how I can do this. My code is below:
for(Account account: System.Trigger.New)
{
if(accountMap.containsKey(account.Physical_Street__c)==accountMap2.containsKey(account.Phone))
if(accountMap.containsKey(account.Physical_Street__c)==accountMap3.containsKey(account.Name))
if(account.Is_record_near_to_duplicate__c.equals('No'))
{
account.addError('Account with this Name,Street and Phone Number already exists. If you still wish to create the agency change the value of field "Is Record Near To Duplicate" to YES');
}
}
If you really need an alert box then you could create a custom javascript button that uses the ajax toolkit to replace the standard save button.
However, as Baxter said you are getting pretty far from standard salesforce look and feel. I would recommend instead to add an error on the checkbox field instead of the object so it is clear to the user what they need to select.
if(account.Is_record_near_to_duplicate__c.equals('No'))
{
account.Is_record_near_to_duplicate__c.addError('Agency with this Name, Physical Street and Phone Number already exists. If you still wish to create the agency change the value of field "Is Record Near To Duplicate" to YES');
}
Unless you write a custom visualforce page that processes the error message and then displays it as a popup there's no way to do this.
If you wanted the alert to modify the data you may look at using the ajax api to set the Is_record_near_to_duplicate__c field to 'Yes' but either way you're getting pretty far from the standard functionality and interface with this.
It is not straight forward to implement a pop-up alert for a trigger error, and pop-ups went out-of-fashion a long time ago. If you are going through the hassle, you might as well implement a custom soultion on a VF page.
Throw a custom exception(for dupe accounts) from the trigger, and catch it in your controller. When you catch this exception, you can dynamically displayed section on the page which asks the user to confirm his/her action. When the user confirms the action, the page will do the rest.
Hope this makes sense!
Anup

Want to display results of a callout

When a user 'Saves' a Contact (for example), whether it's new or just updated, I need to:
Do an external callout using one of the Contact field values as a lookup
Display the results of the callout, so the user can make a selection
Update the Contact based on the user's selection display the updated Contact
I have found two aproaches, but have reached a point in both that I need to resolve.
Trigger Based Method
In the 'after' trigger pass the lookup string to a callback.
Update the Contact with the selection
Issues
How do you pass the lookup string or results to a visualforce page to display the lookup results?
When the user makes the selection and the update has been done, how do I move back to the updated contact?
Override Base Method
I found a discussion here that seems to suggests using overriding & redirection to someone asking about 'Edit'. I think this could also be done with the 'Save' button.
Issue
This is meant to be a deployable sollution, so I think that the override has to be set in code (I'm using the IDE) and not via Setup (or am I wrong?). I can't find out if this is possible or how to do it
Sorry for detailed question. Didn't want to just ask the wrong question (i.e. assume I know the best approach).
Thanks...
For the trigger-based method, you cannot change the built-in Save functionality, but (per your second solution) you can override the Edit button and recreate the Edit page with Visualforce, which would give you full control over the Save button and how you handle the callout and redirecting.
The release notes for Spring '10 indicate that standard-button overrides are now available for packaging, as they can be created through the Metadata API.

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