Skip to Content

Composite entities with Dialogflow

Matching complex values thanks to composite entities

Posted on 2 mins read

When building conversational interfaces, complex patterns need to be matched.

Dialogflow comes with various built-in types (usually called system entities), to recognize various forms of: dates & times, numbers (ordinal, cardinal or even flight numbers), amounts & units (like distances, currencies, duration or temperature), unit names, geography (addresses, ZIP codes, airport codes, and more), as well as names (even music artists).

But sometimes, you need your own kind of entity, to match something that is specific to your use case.

In the example developed below, I define a special entity that represents a robot movement: which is the combination of a number of steps and a direction. And Dialogflow allows me to define such a structure, to be matched as a distinct entity within my intents.

Users of my chatbot should be able to give commands to my robot, and tell it to move a certain number of steps, in a particular direction, like this:

robot move 3 steps forward

First, we’re going to create a direction entity, which covers the 4 main directions (including some synonyms): forward, backward, left, and right:

Direction entity

Then, we can create our move composite entity, which combines a number of steps, the word step, and our newly created direction:

Our @move composite entity

Now, your intents can reference this @move entity to match complex movements that were not part of the built-in entities in Dialogflow.

comments powered by Disqus