简体   繁体   中英

How to use IBM Watson Context variables without entities?

Hi all Watson Developers!

I have a question, exposing that I need to know a bit more about context variables!

A user enters "Who owns the boat DUO?" and my Dialog then uses the Intent "#owner_of_boatname" That works!

I then want to store the boatname in a variable $boatname, to pass it on to my webhook, as the value "$boatname".

If I create an entity with a list containing all possible boatnames, then it works, but what if I do not have all boatnames, and just want to pick up the $boatname from the user, and pass in on to the weebhook? How do I fill out the handler then?

I've tried to just put in "DUO" as value to my webhook, and that works fine, so the webhook itself works - I just need to be able to transfer variables to it!

How?

Thanks a lot

Lars;-) enter image description here

The ideal solution for this question should use AI model created in Watson Knowledge Studio to identify names in user's text and deploy it to Natural Language Understanding instance which you would use the extract the name.

However, we can make a simpler solution, we must assume that the name of the boat will always be at the end of user's input and we can use a regular expression on Watson Assistant to extrat the name. You have to create a node before you pass to the webhook just to identify that user will pass the name of the boat, for example:

Assistant: What is the name of your boat?
User: The name of my boat is boatname

The node that return "What is the name of your boat?"should jump to a node and wait to user request and the condition of this node should always be true. When the user says "The name of my boat is boatname" the node with the condition always true should have context variable with the following regex expression in value context area:

"<? input.text.extract('\s\"?(\w+)\"?$',0)?>"

This regex rule identify the last word of a phrase with double quotes or not.

Once you have extracted the boat's name you can make the node request you webhook.

Here we are using the SpeL language to access the assistant payload to extrat the last word of a phrase. You can find more information about functions on context variables here here .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM