Get user information from user input using IBM Watson conversation - ibm-watson

I'm Wondering how to extract the username using IBM Watson Conversation within the standard chat:
For example:
bot: What is your name?
User respond: my name is Mike
bot: ok good morning Mike. -> i want this
How to store the name that user type in the chat? so the bot can answer the given name?

EDIT: There is a new feature in WCS that enabled to extract pattern-based entities - in other words, user is able to define entities based on regular expressions. More information in the DOC here:
https://console.bluemix.net/docs/services/conversation/entities.html#creating-entities [30.11.2017]
You can access the user input text by writing <? input.text ?> then two methods supported by WCS might be useful:
<?input.text.matches('regexp')?> return true if the input matches input regexp expression.
and
<?input.text.extract('regexp', 0)?> (second parameter is regexp group number). That extracts part of the input String as specified by regexp and group.
For example this expression on a dialog node context:
"lastword" : "<?input.text.extract('\\w+$', 0)?>" will extract the last word from the input text provided by user.
Note that this is not a perfect solution for your use case, so it might be a good idea to add a dialog flow that confirms whether the parsed string is really a user name...

Related

append a piece of text to user's input before determining it's intent by Watson assistant engine

I want to append a piece of text to user's input before determining it's intent by Watson assistant engine
for example:
set context variable $subject = "VPN"
user input : "I want to set it up"
add context variable to the input so it becomes :
"I want to set it up $subject" ------> "I want to set it up VPN"
then after doing that watson determines which intent this input belongs to
PS: it doesn't have to be a context variable, I can append some static text
I recommend to split this problem up into intent and entities.
What is the desired action, the intent? Set something up.
What is the object / subject involved, the entity? A VPN, a computer.
That way your chatbot is more flexible and can be extended later on.
If you are already talking about VPN in a dialog, you may branch into a VPN-specific set of dialog nodes.

How to use search function in ldp.exe to search class (user) attributes (mustcontain)

I need to admit that I am a beginner with AD DS Schema.
I want to make some user attribute fields required at the time of creating a user account in AD.
I followed the instructions in the article here. I made a mistake (don't remember which values I set in mustContain attribute) now I can't create an active directory account I would like to query mustContain attribute in class= user to find the values in mustContain. I tried ldp.exe search but confuse what parameters in need to use in search function.
Probably you would need to set up your Base DN to CN=User,CN=Schema,CN=Configuration,DC=... and Scope to Base. In the Attributes section put mustContain or leave asterisk to get all the attributes.

Conversation - using entities values/size as a condition

I'd like to know how to use the values from the entity as a IF bot recognizes
condition on Watson Conversation.
I have one menu for the users choose one option. And all of these options are inside one Entity called #optionsNumbers with the values: 1, 2, 3, 4, 5.
And I want to make one condition that will verify if user chooses more than one option.
E.g:
Watson: Hello, welcome to the Official Virtual Assistant from the Company XX. You can choose this options above:
1. About products 2. About Services 3. Exit
User: I want the option 1 and 2
So, the entity #sys-number have 2 values, and not just one, like I need.
As you can see, the user types 2 values of the entity #option. And I'd like to know how to recognize if the user typed more than one value for this particular entity, also #sys-number, cause the user can type just ONE option (business rules).
I'm enthusiast about Watson and pretty sure I read all documentation. So, what I have tried and does not work (I saw these methods with Intents examples):
if bot recognizes entities.sys-number[1].value
if bot recognizes entities['sys-number'].size > 1
And I know that I can create two conditions, but if my Options menu have more than 20 options? That's why my asking.
First, you could use the system number entity built-in type provided by Watson :
Entities > System Entities > Enable System Number
Your intent should now be able to recognize it easily by default, let's check the following intent :
And you test it with the sandbox, it works as expected
EDIT: Using Dialog to add a condition on sys-number
Create new dialog node for matching the intent :
Then enable the Multiple Responses for this node ( click Customize ) :
Add your conditions as part of the responses :
Then test your dialog :

Watson Dialog parsing input node

In a Watson dialog xml file, we are trying to query the user for a twitter handle and then assign that twitter handle to the Dialog profile variable Twitter_Handle. The associated input node is triggered by "$ #*"
If the user were to type in say "their twitter handle is #xxxxx" I don't want to assign that whole phrase to Twitter_Handle... just the "#xxxxx" part.
Is there a way within Dialog to parse the users input to look for say the "#" and what immediately follows so that I can assign just the actual twitter handle to Twitter_Handle?
I had a similar problem, and I was using Java so here what I did. You can check if the user input contains the symbol '#' and then try to split the whole answer in strings and get the string right after the '#'.

Making Related Models Optional

I have a form where a user can enter a location address as well as the utility companies that provide service to that address. The Utility data is associated to the building:
Location hasMany Utility
Solely within the context of the utility, the name field is required so there's validation indicating as much. Within the context of a location, though, any utility information is optional. The user can choose not to enter that data when entering a location which would simply indicate that they don't want to associate the location with any or all of the utility companies we track.
Using the FormHelper, though, the validation is detected and the field gets marked as required. I want to retain that validation for the instances where utility data is being entered independently, but remove the required indicator on the location form.
I know I can hack this in any number of ways (e.g. removing the required class via javascript, etc.), but I'm wondering if there's a clean way to do this using the Cake API. I haven't seen anything obvious, so I'm hoping someone else has been here and found a clean, simple solution.
Thanks.
You can either ask the user how many utilities they want to add before creating the form, or you can add the Utility record inputs dynamically using js (the later is more work to do, and not as error-proof as the former).
An example of the view (if you want to do it in 1 view):
if (empty($this->data){
// a form to ask how many utility records the users want to create.
}else{
// generate the form based on user input.
}
I assume you know what to do in the controller.
I would add a class to the form element that are optionnal, and use that class to override the "required" indicator.
In fact there is a Cake solution, use the error param
$this->Form->input('Model.field', array('error' => false));
To disable error message output set the error key to false.

Resources