Dialogflow - SilasBerger/coachbot-brain GitHub Wiki

Dialogflow is a Natural Language Processing framework. It receives the user's natural speech or text (through the test-input in the Dialogflow dashboard, or through any chat integration, parses the user's intended action, and retrieves relevant context objects (for example: the action is order.drink, so, relevant context objects might be size, delivery-or-pickup, milk-type, sugar, iced, etc.).

Useful resources for getting started with Dialogflow (formerly known as API.AI) include this introduction by one of the developers, and their YouTube channel. Another useful resources is the pre-built "Coffee-Shop" agent. It doesn't yet have webhook integration, but gives a good overview of intents and entities. It is available through the Dialogflow dashboard. Dialogflow documentation can be found here

The most important concepts are entities and intents. Entities represent objects of your business logic, that a user wants to interact with. For our project, an entity could be @feeling. We can then define instances of an entity. In this case, such instances could be "happy", "sad", "anxious", "depressed", etc. We can also define synonyms for each entity, such as "joyous" and "gay", for "happy". The idea behind entities is to define a semantic background for our business domain. For example, what does "happy" mean? In our case, it means the user is expressing a @feeling.

Intents are a representation of a user's intention, or "what the user wants to express". For example, an intent could be "mood.feeling-sad". If Dialogflow detects this intent, we know the user is expressing the fact that he's sad, and we can take appropriate actions. We train an intent by giving example sentences of how a user might express such an intent. For example, for "mood.feeling-sad", we would enter training sentences such as "I'm feeling sad today", "I'm so down right now", "I feel blue", "I want to cry", etc. Dialogflow's ML algorithms will take these sentences as training data and take care of the rest.

In a context, we can also define what entities need to be specified. For example, if we build a "Coffe Shop" chatbot, we might have an intent order.drink. Required entities may include @drink, @size @delivery-pickup. Optional entities may include @iced, @sugar, etc. In the intent, we can define how Dialogflow should prompt for missing entities. A request to the webhook will only occur after all required entities for an intent are specified. In this example, "2 small lattes please" will not yet be forwarded to the webhook, since @drink and @size are provided, but @delivery-pickup is still missing. Dialogflow will then respond with our defined prompt (e.g. "would you like that delivered or do you wan to pick it up"). Only after a value for @delivery-pickup has been determined, will the request be forwarded to the webhook.

We can also define input and output contexts of an intent. I need to do further research on what contexts are used for, and how they affect the dialog behavior.