0
votes

Please, I wanted to know if it is possible to catch different entities on Watson conversation without defining their values. For example, I am working on a Mobile up for room booking in my company and I can't define all the room's names so I want that my Bot recognize the name just according to the used pattern for example "Book @room for tomorrow" and whatever I put in place of @room it takes it as a room name.

thank you

2
this name is a number?Sayuri Mizuguchi
You can use regex for this. Watson Conversation supports SPELDudi
@SayuriMizuguchi No it is notKaci Hyou
@Dudi Is that valid even for words within phrases ? Or I have to do it in the ScriptKaci Hyou
You can do it in the dialog tool. More details on dialog methods here ibm.com/watson/developercloud/doc/conversation/…RiyaMRoy

2 Answers

0
votes

Its now available check out https://console.bluemix.net/docs/services/conversation/entities.html#pattern-entities

A pattern must be entered as a regular expression in the field. For instance internationalPhone: ^(\(?\+?[0-9]*\)?)?[0-9_\- \(\)]*$, e.g., +44 1962 815000

0
votes

EDIT: The solution below still works but right now the pattern entities as discussed by Dudi are more systematic solution. Leaving this here for legacy reasons.


Right now the regexp support inside Watson Conversation Service is probably the est bet.

For your particular example, you can use the following expression inside the dialog node condition:

input.text.matches('^[bB]ook[^\w]+(\w+).+ (tomorrow|today)$')

and inside that node you can add the following regexp to node context to extract the second word (or the word after "Book") to a variable:

"room" : "<? input.text.extract('^[bB]ook[^\\w]+(\\w+).+ (tomorrow|today)$',1) ?>" (note that in context unlike in conditions you need to actually escape \ with another \)

This will match inputs such as "book bathroom for today" or "book r101 for tomorrow".

A good place where you can try your regexp expressions is https://regex101.com/