Problem with dialog nodes and intents in Watson Assistent - ibm-watson

I'm using IBM Watson Assistant for creating a chatbot. I'm using the web interface with the intents, entities and dialog flow|tree (I don't know how it is called, I'm just calling it web interface). I have four problems and hope that someone can help with it.
I have created two intens: #how_are_you with an example "How are you?" and intent #feeling_good with example "I'm good". Of course I have much more examples for these two intents. In the dialog I have now a parent node looking for #feeling_good and a child node looking for #how_are_you (skipping user input in-between). When a user now inputs the sentence "I'm good. How are you?" then only #feeling_good is triggered but not #how_are_you. How can I trigger both intents with only one user input?
I would like to have one node in the dialog which waits for say 100s and then sends another message to the user. Waiting is no problem (using pause) but how can I do it that only a message is sent after the 100s if the user did not send another message during the waiting period? That means when the user sends a message the waiting node should be canceled.
I have a node which checks for a certain intent. When the intent does not match I'm jumping back to the parent node. The problem is that the text from the parent node is repeated each time. How can I prevent this repetition when jumping back?
The last question is perhaps a bit more tricky. I would like to define an array of the numbers [1,2,3,4,5]. Then one node should sample a random number without replacement from that array (e.g. 2), i.e. the remaining array is then [1,3,4,5]. After some time another node should pick another number at random from the array (say 4). And so on. How can this be implemented? I know about variables (e.g. $var) but I don't know how to represent arrays and sample random numbers.
Thank you so much for your answers in advance. And happy new year to everybody.

1) In Watson Assistant always the intent with the highest confidence is used first. Hence processing multiple intents triggered by one sentence is tricky. The "best" solution is to use composite intent - #HELLO_HOW_ARE_YOU. Alternatively you can create conditions that would check if the first two intents returned are a comination of #HELLO and #HOW_ARE_YOU
2) Waiting and sending messages due to inactivity should be ideally handled by the client implementing the chat console in your interface. WA is not well suited for these types of operations, while there is some support, better way how to handle these is get your client application - when inactivity detected - to send something that will be mapped to #INACTIVITY_INTENT and WA will respond with your message coupled with that intent.
3) Don't jump to the node but jump to the first child of that node and use wait for user input.
4) This is possible. WA expression language supports getting random number, getting the size of an array and removing elements from the array.
E.g. <? $array.remove(new Random().nextInt(3))?>

Related

How to make a long pause in Watson Assistant?

I'm using IBM Watson Assistant for creating a chatbot. I'm using the web interface with the intents, entities and dialog flow|tree (I don't know how it is called, I'm just calling it web interface).
I would like to have one node in the dialog which waits for say 100s and then sends another message to the user but only if the user did not send another message in-between. I can add pause in a node but only a pause of at most 10s is possible. Of course I could add multiple such pause in sequence in a node but that's not so good style. How can I solve this instead to wait 100s and only sending a message afterwards if the user did not send a message during this 100s?
Moreover, I have a pretty linear flow in my chatbot (one large branch in the dialog tree). If the conversation with the chatbot is longer than 10 minutes I would like to stop it and jump out of the branch. I could solve it by storing the current time when the conversation starts and then checking in each node if the time difference is larger than 10 minutes and if so, jumping out. But this is again not good style. How can I solve this more elegant?
Unfortunately Watson Assistant does not provide this feature. But we have a lot of ways to do that, cause Watson is one API and we have all the back-end to create custom code, for instance.
You can use the last request /message and create one setInterval, adding some condition if passed more than since the last request to /message as you would like to and send some message that you want.
if(inputTiming > 100000) {
response.output.text = 'Hey, are you there?';
return response
}
Timing Events with Javascript
With Latest Watson Assistant, you can do something like this -
{
"time": 5000,
"typing": true,
"response_type": "pause"
},

IBM Watson Assistant: How do I have the chatbot repeat a response until it recognizes what the user is saying?

I am building a chatbot that needs to be able to have long, branching conversations with users. Its purpose is to be able to engage the user for longs periods of time. One of the problems that I'm running into is how to handle unrelated responses from a user in the middle of a dialogue tree without "resetting" the entire conversation.
For example, let's say they have the following conversation:
Chatbot: Do you like vanilla or chocolate ice cream?
User: Vanilla
Chatbot: (recognizes "vanilla" and responds with appropriate child node) Great! Would you like chocolate or caramel on top?
User: Caramel
Chatbot: (recognizes "caramel" and responds with appropriate child node) That sounds delicious! Do you prefer sprinkles or whipped cream?
User: I would like a cherry!
At that point, my problem is that the chatbot triggers the "anything_else" response and says something like "I didn't understand that." Which means if the user wants to continue the conversation about ice cream, he has to start from the very beginning.
I'm very new to using IBM Watson assistant, but I did as much research as I could and I wasn't able to find anything. Any advice or help would be appreciated! So far the only idea I had was to have an "anything_else" option for every single dialogue node that could jump back to the next node up. But that sounds extremely complicated and time consuming. I was wondering if there was an easier way to just have the chatbot repeat whatever question it is asking until it gets a response that triggers one of the child nodes.
EDIT: It may be helpful to add that what I'm trying to here is "funnel" the user down certain conversation paths.
In anything_else node, you can enable return after digressions which will go back to the previous node and it fulfils your requirement.
There is a Anything Else option that acts as a fallback when the chatbot fails to recognize the intent.
You can take a look at the documentation here.

Re-using entities in Watson Assistant results in automatically filled context variables

So to my understanding, entities are supposed to be re-used amongst different slots to optimize for the fact that you may want to accept a user input info for similar data types i.e. two separate slots "what is your household income", "what is your spouse's household income" would both use the #sys-currency entity.
In my current dialog flow, I have two child nodes each with one slot that checks for the sys-currency entity type. I'm using two different context variables however to set the slot.
The problem is that after the user inputs an answer for the first child node ('household income'), the context variable is then set for the following one as well. They have the same entity, but different context variables. To my understanding, this shouldn't be happening. I can confirm the node is processed, but it immediately skips the prompt as if it's already been filled and delivers the response in the node.
You are telling it to jump to the next slot and look for that entity. The user does not get the chance to input anything because their last message contained that entity. You should try jump to and wait for user input
If one node is giving a jump-to to the other, this will happen. The reason is because the intent and the entities found on the user input will be evaluated against all nodes from the flow until a new "wait for user input", where they will be changed.
In those situations, i normally create a new entity with a value that would never be found (like 389jd8239d892d8h89hf32hdsa8hdj3), to force every input into the not-found node of the slot, and there i use the entity necessary, in this case it would be the #sys-currency. This way the question will aways show, even if in a previous input the user typed a valid currency. To me it's useful when dealing with flows that use a lot of #sys-numbers/#sys-currency/#sys-date, and there isen't a lot of text to use to differenciate the values.
Another option would be to remove the slot and use a single node, with his own flow to get the answer. Personally i prefer to use slots, since it's easy to treat multiple possibilities. I would even put both questions on the same node, just using conditions to check if the slot should be evaluated or not.
I have searched for a way to clear the intent/entity recognized from the input in a previous node, but at no success.
So... I know this is a year and 3 months late, but I'll provide an answer in case anyone else is experiencing this issue.
The root cause is the "Divorce - Household Income" node sets the input.text to a value that the #sys-currency entity matches so any nodes you jump to that matches based on #sys-currency will automatically have their context variables set to the input.text without prompting the user.
Unfortunately, I haven't seen any documentation from IBM that allows you to set the input.text to null.
To solve this issue, you need the user to provide some other value that won't match #sys-currency.
Thankfully, the solution is simple to implement and users may actually prefer you follow my outline below.
Simply have your "Divorce - Household Income" node jump to a node that asks them to confirm their entry. Options such as Yes and No are perfect since they'll set input.text to "Yes" or "No", respectively.
Finally, jump to the "Divorce - Spouse Income" node. Since #sys-currency won't match the user's input.text, the node will properly prompt the user to fill the $spouse_annual_income slot.

Creating futures using Apple's GCD

I'm working on a library which implements the actor model on top of Grand Central Dispatch (specifically the C level API libdispatch). Basically a brief overview of my system is as such:
Communication happens between actors using messages
Multicast communication only (one actor to many actors)
Senders and receivers are decoupled from one another using a blackboard where messages are pushed to.
Messages are sent in the default queue asynchronously using dispatch_group_async() once a message gets pushed onto the blackboard.
I'm trying to implement futures in the language right now, so I've created a new type which holds some information:
A group of its own
The value being 'returned'
However, I have a problem since dispatch_block_t is of type void (^)(void) so it doesn't return anything. So my idea of in my future_new() function of setting up another group which can be used to execute a block returning a result, which I can store in my "value" member in my future_t structure, isn't going to work.
The rest of the futures implementation is very clear, except it all depends on being able to get the value into the future back from the actor, acting on the message.
When using the library, it would greatly reduce its usefulness if I had to ask users (and myself) to be aware when futures were going to be used by other parts of the system—It just isn't practical.
I'm wondering if anyone can think of a way around this?
Actually had Mike Ash's implementation pointed out to me, and as soon as I saw his initWithBlock: on MAFuture, I realized what I needed to do. Very much akin to what's done there, so I'll save the long winded response about how I'm doing it.

MPQueue - what is it and how do I use it?

I encountered a bug that has me beat. Fortunately, I found a work around here (not necessary reading to answer this q) -
http://lists.apple.com/archives/quartz-dev/2009/Oct/msg00088.html
The problem is, I don't understand all of it. I am ok with the event taps etc, but I am supposed to 'set up a thread-safe queue) using MPQueue, add events to it pull them back off later.
Can anyone tell me what an MPQueue is, and how I create one - also how to add items and read/remove items? Google hasn't helped at all.
It's one of the Multiprocessing Services APIs.
… [A] message queue… can be used to notify (that is, send) and wait for (that is, receive) messages consisting of three pointer-sized values in a preemptively safe manner.

Resources