IBM Watson Assistant: How to set a 'jump to' target node dynamically (i.e. using context variables) - ibm-cloud

I want to jump from a dialog node to a node the ID of which is stored in a context variable.
I'm trying to solve a problem that has to do with a digression and which has been described here:
Conditionally return from digression in watson assistant
Especially this chart visualizes the problem:
In my opinion, A.H. posed a very reasonable and relevant question that has got no viable answer.
As far as I can see the problem can not be solved by digression settings. Either the root level node (triggered by matching the intent # Want_to_speak_to_someone) is set to 'return after digression' or it is not.
If the digression setting of this digression node is set to 'return' it will always return - no matter what happens further down in the dialog flow of this digression. Even if the user confirms that he wants to speak to a person (i.e. he does not want to return) the dialog will return to the node where the digression started.
This even happens when I jump from the yes-node (user confirms that he wants to speak to a person) out to any other node. As soon as the branch (or the branch the user jumped to) ends the dialog returns to the node where digression started.
If the digression setting of this digression node is set to 'does not return' however, a return is not possible - even if the user decides against speaking to a person and opts for returning to where he was.
What A.H. and I want is that the user can digress from a dialog flow and can still decide whether he wants to return or not. I think this is a pretty natural and important feature of a dialog. People like to reverse their decision or maybe they even digressed unintentionally from the given dialog flow.
Akaykay proposed to have two different nodes - a 'yes-node' which allows returning and a 'no-node' that does not allow returning. But this doesn't work, because before that I must have another node that asks the user for confirmation - and this 'confirmation-node' has to be set either to 'return' or 'does not return' (yielding the problems described above).
For this reason, I tried to figure out a workaround: I store the dialog node ID from which the dialog digresses in a context variable.
It is a context variable
"context": {
"last_node": "<? output.nodes_visited [0]?>",
...
},
which gets updated in every node of a dialog flow which allows digression.
In the example I could then jump back to the $last_node if the user wants to return and I could jump to another (fixed) node if the user wants to speak to a person - digressions settings of the 'digression node' would not interfere and could be set to 'does not return'.
Then I tried to edit the respective node (from which to return to the $last_node) in the json file of my skill:
"next_step": {
"behavior": "jump_to",
"selector": "user_input",
"dialog_node": "$last_node"
},
But when I reimport the skill-json-file again I get this error message:
I would be fine with either solution - one that uses digression settings or one that allows setting the 'jump to' target node dynamically. I deeply appriciate any help - thanks!

If you want to prevent Watson Assistent from returning from digression just call <? clearDialogStack() ?> function in the node where you don't want Watson Assistant to return from digression and that's it.
In your chart you would write "Ok, click here. <?clearDialogStack()?>" in the output text of the node "Ok, click here." and that should do the trick.
Here it is in the doc in this section: https://cloud.ibm.com/docs/services/assistant?topic=assistant-dialog-runtime#dialog-runtime-digressions
Also note that currently it is not possible to create dynamic gotos with Watson Assistant. Only thing you can do is to create a dialog node with all the needed gotos conditioned by something underneath it and then you would goto this node. It is hard to create this manually but it can be generated automatically. For more magic with WA check out this project:
https://github.com/IBM/watson-assistant-workbench
It is possible to develop chatbots with WA completely without UI.

Related

Setting context variable in Watson Assistant from an entity that uses pattern

I am trying to build a chatbot that implemnts a simple calculator, using Watson assistant. It needs to recognize simple math expressions , e.g "1+2". I set up an intent called #simple_math that recognizes phrases like "what is 1+1", which works fine.
I then created an entity called #mathexp that uses a pattern (regexp) to identify the expression part:
Which also seems to fire correctly when a simple expression is detected. But when I go to the node where I try to assign the value identified using #mathexp.literal, it never gets set. I go into the node called "math", the assistant recognized #simple_math and #mathexp, but the context variable $Mexp (which I am setting to "<? #mathexp.literal ?>") is always blank
What am I missing

Why does the Google Tag Manager automaticalls has a Trigger event for gtm.load for my custom variables?

So I want to Trigger my Tags when the user accept cookies, obviously.
I tried different approaches, JSVariable, Custom JS, First party cookie and datalayer variable.
Now I have them all set in Triggers, for example if the JSVariable is true or if the first party cookie contains the cookie value I set, or the datalayer variable contains filled.
Now in Debug mode these Triggers actually seem to work. They all get Ticks under firing triggers, but the Tags don't seem to Trigger because I get another Trigger for some reason which states
gtm.load equals [variableName] (for example: gtm.load equals myJSVariable) and it always has this red X.
I just don't seem to find an answer to this problem.
Thank you all very much
So if anyone experienceses something similar (in case I am not the only dummy):
When you type in the eventname, it is about WHEN to look for your variable basically.
So for example you would enter gtm.load, when the site has been completely loaded. Then GTM would look for your CustomVariable

IBM Watson Assistant: How to retrieve input value from chosen dialog option?

I already followed these great instructions on how to dynamically create dialog node options from generic input and it's working like charm. But for now I cannot see how to hand over the chosen option value to the next node to process further. Is there any documentation how to pass the chosen option value to the child node?
You can store any selected option and other information in context variables. They are passed around and can be accessed in other nodes. The information is available until you unset or delete the context variable.

IBM Chatbot Assistant - Array with same values

I have this piece of code in JSON editor of Watson:
"context": {
"array": "<? entities['spare_part'].![literal] ?>",
"array_size": "<?$array.size() ?>"
When the input of the user, for example, is "Hello, I need a valve, and the part number of the valve is 1234", the size of the array ends up being 2 since the user mentions the word "valve" twice in his input. Some nodes are being executed depending on size of the array. For instance if the size of the array is 1, some nodes will be ignored because they are only executed only if the size of the array is 2.
I want the array to store only the inputs with different values, which is basically I don`t want the array to store the values of the same type, in my case 2 valves. If it is possible somehow please show me a way.
All that can be done, but the best approach depends on the overall system architecture. Remember that Watson Assistant is a conversation service, not a data processing platform...
You can process JSON in either Watson Assistant directly using the built-in methods and SpEL, see these links to get started:
- https://console.bluemix.net/docs/services/conversation/expression-language.html#expressions-for-accessing-objects
- http://docs.spring.io/spring/docs/current/spring-framework-reference/html/expressions.html
- https://console.bluemix.net/docs/services/conversation/dialog-methods.html#expression-language-methods
That would require some coding within the dialog nodes. It could be ok. What I would recommend is to either process in your app that drives the dialog (you need that app anyway) or to code up small server actions to transform data.
If it is the word you are looking for, you can use contextual entities to train for this.
As an example I created the following intent (along with general intents from catalog).
For each example I highlighted the "valve" word that is the one I am interested in, and added to the entity.
Now when I test it I get the following.
All this was done in a couple of minutes. For production level you may want to add more examples, or think about how you want to annotate.

IBM Assistant(Conversation) Error: SpelEvaluationException when evaluating dialog node ID

I have a flow in my chatBot application where I switch workspaces and its giving me SpelEvaluationException error.
I have a router workspace that determine initial indent of the client, once I know the initial intend I route the next request to appropriate workspaces
Workspace Router :
Bot :- Hey this is an awesome bot, what do you need help with
1. Apples
2. Bananas
3. Oranges
Client :- I need help with my apples
--- I pass a custom JSON from the workspace with tells my app to route next request to apples workspace ----
Apple Workspace :
BOT: Hey what can I help you in apples .
The flow works fine but when I send request to Apples workspace. I get the following error in log_message .
SpelEvaluationException when evaluating dialog node ID [node_2_1517933972148]. The syntax of condition [intents[0].confidence < 0.50] is valid, but cannot be evaluated. Check that objects in expression are not null or out of bounds.\nSpEL evaluation error: EL1025E: The collection has '0' elements, index '0' is invalid\n
So somehow you are asking Watson to evaluate the intents array before actually passing any input, so no intent data is returned, thus the spell expression fails and throws the error.
So however you are calling that second Apples workspace make sure you have input text being sent as well.
The same thing happened to me, you can try to jump by response so that the condition is not evaluated and check if you are not trying to save the intent in a variable inside the JSON. Possibly you already solved it but I leave my proposal hoping it will serve someone else.