NLU - Intents and entities

This page walks through Narratory's NLU (Natural language understanding) capabilities, today largely resting on the shoulders of giants (Dialogflow/Google is used under the hood).

Intents

Intents is an important concept in building conversational apps and refers to what a user means when he/she says something. For example, both "yes" and "I want ice cream" and "why not" likely means that the user wants to buy an icrecream if the bot just have asked the question "Do you want icecream?". This highlights the fact that intents almost always are context-dependent since a Yes would mean something completely different if the bot asked "Do you hate icecream?" or "Have I seen you before?".

Creating intents is done in a similar fashion to defining turns, you do it on the Intents menu.

Each intent has a number of example phrases - basically different ways users can say the same thing.

It is recommended to supply 5-15 example phrases for each intent to start off. When you start testing your app with users you will also quickly learn what phrases you have to add to your intents.

Entities in intents

Quite often you want to extract some information from an intent. This is where entities come in handy. For example, if you build a fruit seller bot, you likely need to distinguish between the two utterances "I want a banan" and "I want an apple". This would typically be done with an Order fruit intent which has a Fruit entity. The fruit entity would then consist of a list of fruits, with each fruit possibly having synonyms.

Entities have to be included in the example phrases you give an intent. To do so:

  1. Press the cog icon on the define intent block and drag the entities block to the settings block.
  2. Fetch a new entity block from the toolbox
  3. Name your entity variable and choose what type of entity it is.
  4. Add the entity variable to example phrases. You have to use a special block to group the entity values and the text values together for the system to know which entities and texts that together make up an example phrase.

Using captured entity variables

The entity variables you create are available to use in the dialog as output, and to pass to APIs. For example, you might want to repeat the value of a captured entity right back to the user. The following two blocks shows an example of this:

First, we define our intent which captures the user's favorite color.

Then, we use it in a bot turn and repeat the color back to the user

Several entities in one intent

An intent can have several entities and even more than one entity of the same type. For example, if an intent captures users attempts at ordering a flight, the relevant entities are typically a destination, a departure city, number of tickets and so on.

Intents with optional entities

An entity will be considered mandatory if it is included in ALL example phrases. In the below example, the entity is not mandatory.

Built in entities

Narratory comes with a set of built-in entities (provided by Dialogflow) that allows you to extract everything from numbers and currencies to cities, music artists, countries and (for some countries) addresses. For a full-list of these entities, see the drop-down menu on the Intents page.

Important: Not all built-in entities are available in all languages. See Dialogflow's list of System entities to learn what entities are available in your selected language.

Wildcard entitites

A special entity is the built-in entitiy any which captures anything. This could be handy in several cases, for example if you want your backend to parse the answer, if you are capturing content that are hard to parse using intents and entities (such as free text feedback for example) or if a built in entity is not supported in the chosen language.

Try to avoid using more than one any entity in the same example phrase since these entities tend to be "greedy" and capture more than you think they would.

Custom entities

Creating custom entities is currently not supported in the graphical builder, but will be shortly.