Watson Dialog parsing input node - ibm-watson

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 '#'.

Related

How to force the cursor to the beginning of an input value in React?

I'm essentially trying to emulate the Apple ID account creation birthday input (can be found here: https://appleid.apple.com/account or if you google Apple ID and click "Create Your Apple ID" on top).
Part of the functionality of the input is that when you click into it, if there's no current value it will default to mm/dd/yyyy and force the user's input caret to the front of the input, replacing characters from the front as the user types. Any later clicks in the input will force the user's cursor to after the spot in the value they've typed. E.g. 05/4m/yyyy the cursor must be after the 4.
I've done a lot of searching and not came across any reliable ways to do this in React. Attempts to use setSelectionRange haven't worked. Thank you!

Get user information from user input using IBM Watson conversation

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...

How can I get AngularJS to bind an input field to an external change?

At the moment I have an input field with the following directive:
ng-model="event.location"
I also have the input field attached to a Google Maps auto complete script. By way of example, if my user types "apa", the Google auto complete list will come up and there is the option of clicking "Apartments". However, the String "Apartments" does not bind to my variable and the "location" variable only contains the String "apa". How can I get AngularJS to bind to the full location once the user selects an option from Google Maps?
Update: It's just a one liner for Google Maps
new google.maps.places.Autocomplete(document.getElementById('location-text'));
Although I'm sure a lot more is happening behind the scenes

AngularJS, Retrict Selection in Input

Im using Google Geocoding to search for address and load a list with possible locations so the user can input his/her country/city in a form.
For that I followed the example in:
Angular-ui-bootstrap
The Typehead Section
But, even after the list is loaded, the user can write and input whatever they want.
Can I restrict the input only to one of the items in the list?? (instead of just free typing)
typeahead-editable: false might do this for you. I am not in a position to test and confirm it. However, I recommend checking out ui-select2 as this may be more appropriate for what you are doing.

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