Dialogflow, how to reuse Intent within another Intent - dialogflow-es

I'm building a Dialogflow app that depends on user provided location a lot. I found a pre-built agent called "Maps" that shows how to train the agent to identify locations from user's statement. However, I would like to keep this location resolution logic somewhat separate and use it part of another Intent instead of cluttering everything in the same Intent.
Is it possible to re-use Intent within another Intent?
Or
Is there a different design pattern?

An agent is made up of multiple intents. You can add more intents to your maps agent.
Alternatively, a common practice is to have multiple agents but build an abstraction layer middle between users and the agents. This abstraction layer can coordinate sharing context between the multiple agents. The catch is that this means you can’t use the dialogflow connectors that make it super easy to publish your agent for Google Assistant, Facebook Messenger, Slack, Twilio, etc. You’ll need to do your own work to connect those to your agent abstraction layer.

You can try a workaround using contexts.
Have all the intents as top-level intents without any fallback or follow-up intents.
Use context in the code for fallback or follow-up intents to identify the action/intent and perform tasks.
|--- Default Welcome
|
|--- Default Fallback (single fallback for all, use context to identify intent you want to serve)
|
|--- Follow-up YES (serve YES follow-up for all using context)
|
|--- Follow-up NO (serve NO follow-up for all using context)
|
|--- Intent A (out context A)
|
|--- Intent B (out context B)
|
..
..
|
|--- Other Intents

Related

Is there a way to program intent and is it possible to call different models on different steps in DialogFlow?

I'm currently working on building a chatbot and I saw the Dialogflow tool that can provides a lot of help in this topic, so my question if it's usable to have multiple contexts at once and also to be able to call my NLP model (stored in an API) many times? Or do I have to build my own platform for that since Dialogflow can't be call multiple webhooks at once?
Example:
I have a model to classify the initial intent,
I have a regression model to do something else if the intent is XXX.
First, remember that an Intent represents what the user says or does and not how you react to that.
Within that, yes, it is perfectly feasible to have multiple Contexts active at once. The lifespan of a Context determines how many rounds of the conversation it will be active for. All of the Input Contexts for an Intent must be active for that Intent to be considered for matching.
While Dialogflow only lets you register one webhook for all of the Intents, it provides information to that webhook about which Intent was triggered (along with which Contexts are active, parameter values, etc). Based on that, or any other information you wish, you can choose which code or handler to execute. In this way, you can certainly make multiple calls to other APIs if that makes sense - as long as you return within the timeout period (5-7 seconds).

DialogFlow, how to build a general intent for Yes and No responses

I'm building a DialogFlow agent for use on the Google Assistant, and it is a conversational model that mainly uses Yes and No responses to navigate through a hierarchical story. I'm struggling to design the architecture using DialogFlow Intents because there doesn't seem to be a way to create a generic, global intent that uses the system Yes and No intents. I know you can add these as Followup Intents as a child of a parent intent, but these only trigger once.
I'm using Cloud Functions on Firebase as the webhook, and will use JSON to build the responses and handle the input. Do I need to use entities to capture the responses instead? I don't think there is a system entity for yes and no.
There are a few ways to create global Yes/No intents:
Create global Yes intent and No intent. Add training phrases for the two intents.
Create a yes/no entity and then a Yes/No intent using the new yes/no entity
Make a follow up Yes intent and remove the context, which will make it a global intent. Do the same with No
Each of these will get you global Yes/No possibilities.
Since your story is hierarchical, a global Yes/No intent does mean that you'll need to keep track of where you are in the story (most likely with a flag in your code and adding/removing context).

Dialogflow - handling inputs with multiple intents

I'm designing a helpdesk chatbot in dialogflow and currently training it with existing data from my ticketing system. What is the best practice for handling inputs that contain multiple intents? Here is an example with the intents in bold:
"Hi, my name is John Doe and I'm a first year student. I want to know where to register for classes and also reset my enterprise password. Please help."
So is the solution to ask people to keep things simple up front? I think currently dialogflow will point the user to one of the intents above, but i'm not sure how it decides which intent to match with.
You will probably have one intent for each feature that your bot offers, i.e. RegisterClass, ResetPassword etc. In that case there is no good* way to handle the case where someone asks for two things at once, your users will have to limit themselves to one request at a time. You can however use a fallback intent to explain this at runtime. This intent would be triggered if a users utterances matches none of the other intents and could give the user a quick explanation like
"Sorry, I didn't get that. Please tell me what you would like to do,
e.g. 'register a class' or 'change my password'"
This would keep a natural conversation going and alleviate the need to "train" users specifically for your agent.
*You could of course add combined intents like RegisterClassAndChangePassword, but that would become very clumsy and most likely not work reliably. You could also try to parse the request in your backend, but then you would essentially circumvent Dialogflow's core feature.

How to clear the session between two consecutive intents?

We are using bot trees master which uses bot graph dialog for loading graph based dialogs dynamically. We have created a scenario to load multiple intents(whose intents scores are nearly matching). Now the problem I am facing is when I request for single intent , I am getting the bot response and able to enter into next intent but when I request for multiple intents bot is giving the response and when I request for another intent , bot is giving the same response of multiple intents. When bot is entering into multiple intent handler it is not clearing the session and not coming out of that handler. I have tried using session.endConversation().
To understand about bot graph dialog:
https://www.microsoft.com/developerblog/2016/11/11/extending-microsofts-bot-framework-with-graph-baseddialogs-/
Can somebody help on this. Thank you
the builder.IntentDialog() used in this project is no longer considered a best practice. Additionally, further support is not expected. Instead, you will want to use bot.Dialog() to create your dialog flows with a .triggerAction(). The trigger matches on phrases which you can set a score to. Unfortunately, it means you will need to recreate the bot-trees project to fit this new model.
You can find information on managing conversations here, including creating triggers.
If you need a more robust system, you can integrate LUIS into your project. Information regarding recognizing intents with LUIS can be found here.

Wit.ai intent issues

I am having real difficulty in understanding the intent part in Wit.ai. When I go to the understanding tab inside an app it shows me intent as a user defined entity.
Do we need to create intents as a user entity or do we need to create intents as a separate in-build entity. Just today when I was going through their HTTP API they first took me to the docs of version 20141022
and then to the version 20160526 in a matter of 15 minutes (meaning they are not stable with http api versions?). In the older version I see that for posting intent there is a separate API which is deprecated in the latter (newer version).
Also I went through some of the apps from the explore section and in each one of them I could see that intent is a different property altogether.
How should I treat the intent?
Considering the newer versions of the API if I take intent as a User defined entity and then add another entity with the search strategy trait. Wit.ai internally removes my expression for the other entity. I also need some help in understanding how this flow is working?
In the new version of Wit.ai, intent is not a special, built-in entity anymore. It's just a user-defined entity that's created for you when you create an app. The search strategy is normally trait.
If you add another entity with trait, it will be completely orthogonal to intent. What do you mean by "Wit.ai internally removes my expression"?
Don't hesitate to explain what exactly you are trying to achieve.

Resources