0

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

Kaci Hyou
  • 65
  • 11

2 Answers2

0

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/

Michal Bida
  • 1,316
  • 9
  • 24
  • The problem is that my rooms can sometimes have a composed named like Room Pablo Picasso, – Kaci Hyou Apr 05 '17 at 09:13
  • You can extend the regexp by listing all the special room names instead of using \w+, however, then it might get bigger... E.g. ^[bB]ook[^\w]+(Pablo Picasso|\w+).+ (tomorrow|today)$ Alternatively you can match for more words before "for tomorrow" String. – Michal Bida Apr 05 '17 at 18:03
  • mm if I have to list all the rooms names that means that it would be better for me to add them into entities. Think that it's one of the cons of Conversation – Kaci Hyou Apr 12 '17 at 22:22
0

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

Dudi
  • 2,340
  • 1
  • 24
  • 39