1

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?

halfer
  • 19,824
  • 17
  • 99
  • 186
OiRc
  • 1,602
  • 4
  • 21
  • 60
  • Possible duplicate of http://stackoverflow.com/questions/39232950/how-to-give-personalised-greeting-in-watson-conversation – RiyaMRoy Mar 27 '17 at 11:24
  • @RiyaMRoy this question is more general than the one mentioned by you allowing me to give a more generic answer how to process `input.text` in general, which seems useful to me. – Michal Bida Mar 28 '17 at 08:10
  • Sure @MichalBida – RiyaMRoy Mar 28 '17 at 11:00

1 Answers1

12

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

Michal Bida
  • 1,316
  • 9
  • 24
  • what I feel is Watson conversation is not capable of extracting such user-provided information intelligently, yet. – Mohamed Iqzas Nov 29 '17 at 11:17
  • @MohamedIqzas There is new feature called open entities that allow user to train the entities. This can be used very effectively to recognize e.g. user names. Works for English workspaces right now. – Michal Bida Oct 26 '18 at 09:17