0

I am buildingg a Messenger bot with botkit and language processing is done via api.ai.

Apiai's intents are a great way to guide user through the bot's experience. I use predefiened intents to understand what user want to do and the start a conversation with him using botkit's convo object. At this point I have predefined questions that user need to answer.

For example one of the questions is "When did that happen?" and user can answer in plain text. I do not need for apiai to tell me the intent (as well as I dont want to spend time training for that) because I already know what to expect.

So I am looking for a way to simply extract system and developer-defined entities out of string. So If user provides answer "I happened yesterday" I could validate that I have entities of date but the time entity is empty so I will promt to give time as well.

I have read apiai and other competitor docs and have not found a way to do that. It is always about defining intents.

So basically - find and extract entities from string. Is it possible and if is - how to? Currently apiai is my tool but I am willing to change it if neccesary.

Community
  • 1
  • 1
Kārlis Janisels
  • 1,265
  • 3
  • 18
  • 41
  • Did you check this out? https://docs.api.ai/docs/concept-entities#section-date-and-time is this what you are looking for, or does it have some restriction that does not work for you use case? – jgranstrom Jun 20 '17 at 08:06
  • Yes, there are restrictions. The user might answer in multiple different ways like "yesterday", "I was yesterday", "It happened yesterday", ... . And form what I understand I am obligated to create intent for this question and train agent for all these possible user answers. But that seems foolish to me because I allready know the intent. These system entities are very powerfull so I am wondering why cant a developer simply search string for them. – Kārlis Janisels Jun 20 '17 at 08:15
  • I see, are you looking for a hosted service for doing this, or is it an option to set up your own APIs using open source tools? – jgranstrom Jun 20 '17 at 08:24
  • I will want to continue using intents for general messages so I'd like to stick with hosted service like apiai but I see where you are going. I have played around with TensorFlow and know that this could be achieved with their language models but I would much rather try not to overcomplicate structure of bot. I am quite sure that that for api.ai engine this task would be even easier then getting intent (correct me ih I am wrong) so I am kind of puzzled why it is not supported out-of-the-box. – Kārlis Janisels Jun 20 '17 at 09:17
  • I haven't used api.ai specifically. From looking briefly it looks like their entity recognition is trained in combination with the intents, which would explain why they aren't providing an api for extracting entities only, they might not create a separate model for entity extraction. Is the main problem with using an intent in your case that it takes too much time to set up different intents to get your required entities? Maybe it is possible to create a "fallback" intent without any special meaning that you use just for getting your entities extracted. – jgranstrom Jun 20 '17 at 12:52
  • It a matter of how I would like to design my bot. I will just have to adapt to apiai's ways. Thank for you help – Kārlis Janisels Jun 20 '17 at 21:22

1 Answers1

1

You can use required parameters to make sure you get the necessary information from the user. To make a parameter require just check the box to the left of the parameter name in the intent below the Action section (pointed to with an arrow in the screenshot below). To create a custom prompt for the parameter (i.e. "what time did it happen?") click to the right of the parameter name under the prompts column header (in a red box in the screenshot below):

If you need further validation you'll need to setup a fulfillment webhook for Api.ai. Api.ai will send requests to your webhook which will contain JSON data including the values for the entities (this is in the parameters attribute of the result object included in the request to your webhook). You can then validate any data that is necessary and respond to the user accordingly. Documentation for fulfillment webhooks are here: https://docs.api.ai/docs/webhook#webhook-requirements

mattcarrollcode
  • 3,429
  • 16
  • 16