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 A.I 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.
Related
I am getting into CX and have a simple agent going but I cannot get the agent to respond with my filled parameter.
I have a page that asks for #DrinkFrequency and #DrinkChoice, I see both get filled correctly when I test the agent and $page.params.status = FINAL takes me to my next page that says
So you drink $session.params.DrinkFrequency and prefer to drink $session.params.DrinkChoice
But the agent says exactly that, it does not replace $session.params.DrinkFrequency or $session.params.DrinkChoice with the values the user gave. I know it must be a simple issue but I have tried to write $session.params.DrinkFrequency in a few different ways and I looked at the existing tutorial bots and they also have it with just the $ sign. Am I not saving the user given value?
The page that gets the values has the two parameters and they ask for the value in their "Initial prompt fulfillment" field.
You're referring to the entity type, while the display name is the name of your parameter.
If you replace $session.params.DrinkFrequency with $session.params.frequency and $session.params.DrinkChoice with $session.params.preference it should work.
My bot asks: 'how do you (i.e. customer) want to pay for this product?'
Customer says: 'part in cash and the difference in 48x'
What the customer is saying above is that he wants to pay in cash and use financing. And that financing should consider 48 installments.
Entities:
paymentType: {cash, financed} ; Financed includes 48x as a synonym
numInstallments: {12x, 24x, 36x, 48x} ; 48x is the number of installments desired
Using the GUI only, how to do this:
IF user says '48x' THEN simultaneously add 'financed' to the paymentType list AND set numInstallments equal to '48x' ?
Apparently the GUI doesn't allow me to do that unless I'm doing something wrong (see below the screen which allows a parameter to be mapped to an entity and notice that this dropdown apparently allows selection of a single entity and not two, which is what I need).
How to solve this problem in an easy way through the GUI?
I don't know if what you have in mind is actually feasible in this case.
What you could do is keep the intent and entities as-is and then create several conditions in the page where you fill this parameters or another page (i think this is preferred).
In that page you can put different routes where your conditions are true that modify your parameters as you wish.
For example, after asking the user how they'd like to pay, you can have a route going to a "Set parameters" page which has several routes:
First route has a condition $session.params.numeroDeParcelas != null (you know the user has asked a specific number of installments, so handle the case by setting the parameters you need in this route (under parameters in the route write paymentType : "financed")
Second route has another condition, for example $session.params.numeroDeParcelas = null (you know the user hasn't asked for financing, so set the same parameter as before to "cash")
and so on, until you've exhausted your user cases (all payment methods, possibly all types of financing).
Pay attention: the routes are always evaluated in order so make sure to keep this in mind while writing/ordering them: be specific to avoid fulfilling the wrong one by mistake (e.g. by creating compound conditions, chaining parameter checks as in $session.params.numeroDeParcelas = null AND $session.params. numInstallments = "36x"
I am attempting to build a Microsoft Teams bot using the Bot Framework Composer. What I would like to do is create an integration with ServiceNow. The goal would be that if anyone posts a record number (ex. REQ0123456, INC0123456, KB0123456) into the group or direct chat (with the bot), the bot would look up that record and provide a card or a short summary of the record to the chat.
To avoid creating a completely separate intent for each record type, I was hoping to use RegEx to gather the match into 2 capture groups; one for the tbl_code and one for the number.
Here is the entry for the user input:
> add some example phrases to trigger this intent:
- look up {conversation.sn_record.tbl_code=REQ}{conversation.sn_record.number=0123456}
- lookup {conversation.sn_record.tbl_code=REQ}{conversation.sn_record.number=0123456}
- {conversation.sn_record.tbl_code=REQ}{conversation.sn_record.number=0123456}
- lu {conversation.sn_record.tbl_code=REQ}{conversation.sn_record.number=0123456}
> entity definitions:
# regex sn_record tbl_code, number = /([a-z]{2,4})([0-9]{7})/mi
The Issue I'm Having
I don't know how to get the values back from the individual capture groups. I would like to have them separate so that I can determine which table needs to be queried. I could probably just use the entire match and the search API in ServiceNow for the whole record string, but I would still like to know how to use capture group values.
I'm currently using turn.recognized.text, but I don't think this is the best method for what I'm looking to do. This returns the entire regex match.
I'm very new to this framework, so please be gentle. :) Let me know if there is more information I can provide.
Thanks all.
Best Regards,
Josh
I was able to figure this one out using the examples in the ToDosSample bot.
The answer was to use named capture groups and then add them to a dialog property to use in the corresponding dialog.
For reference here are the changes I had to make:
New Regex
(?<sn_record>(?<tbl_code>[a-z]{2,4})(?<numbers>[0-9]{7}))
New Dialog Properties
dialog.sn_record = #sn_record
dialog.sn_tbl_code = #tbl_code
dialog.sn_numbers = #numbers
New response
- Okay, looking up ${dialog.sn_tbl_code}${dialog.sn_numbers}
I want to capture the following input from the user and am using these entities:
First and last names: use sys-person (I extract first and last names later using a cloud action).
Email address: use pattern entity, name #contactEmail and value "email" pattern \b[A-Za-z0-9._%+-]+#([A-Za-z0-9-]+.)+[A-Za-z]{2,}\b
Mobile Number: use pattern entity, name #contactPhone and value "mobileNumber" pattern ^[1-9][0-9]{7}[0-9]+$
Slots
I created a node with slots:
The setup is as follows:
Check for:
Check for: #sys-person.literal Save it as $person If not present: Type your name
Check for: #contactEmail.literal Save it as $email If not present: Type your email
Check for: #contactPhone.literal Save it as $contactPhone If not present: Type your mobile.
This all works perfectly and I get the name, email address and Phone number.
The Challenge
But I want the user to be able to confirm that the details are correct.
So I have an intent called #response_yes which is activated by things like "yes", "yep", etc.
And I have a fourth slot that checks for #response_yes.
Check for #response_yes, store the value in $confirmed, if not present ask "Got $person, $contactEmail, $contactPhone is that correct?"
If #response_yes is not found, then it displays the values already typed and asks if they are correct and waits for user input.
After the user has responded, then if the #reponse_yes intent is still not found, then:
Respond with, "Let's start again".
Also, we need to clear the values already typed:
Here's where it goes wrong
When I try the chatbot, the node collects the input correctly and displays the values correctly and asks if they are correct. I type "no", the #response_no intent is correctly divined and I would expect the prompt for the first slot to show again, but it doesn't.
No matter what I type at that point, the assistant bypasses the top three slots and drops to the fourth one again. It's as if I need to clear the entities, not the variables.
What am I doing wrong? How do I make the top slot work again?!
Aaaaargh.
For anyone who's interested, I simply didn't reset the values to null.
I guess I assumed that leaving the value blank was the same as null. Not so. Once I did this, the system worked perfectly:
The following is a basic drools syntax:
$customer : Customer( )
Account( ) from $customer.accounts
As far as I know the first line create a new variable and assign it to the fact.
However I can't quite understand the second line especially what the "Account()" part means...
You have written class Customer, or must know it to understand what's going on here. Presumably it contains a Collection<Account> accounts (see note), which is (by the engine) retrieved one by one so that the rule fires for each Account object contained in Customer's object.
The rule will fire once for each Account object stored in any of the collections contained in all the Customer facts in working memory, with $customer being bound to the containing Customer.
You can bind another variable to Account.
Note: It could also contain a field Account accounts, but I hope the name was chosen carefully.