Changing to 'follow-up' intent based on entity value in Dialogflow [duplicate] - dialogflow-es

This question already has an answer here:
is there a way to activate a dialogflow intent dynamically?
(1 answer)
Closed 3 years ago.
I've an intent 'Setup' that has two followup intents 'Android' and 'IOS'.
The intent 'Setup' has an entity - deviceType - which is 'Required' and has a prompt (Can you tell me the device type?). Note - this intent does not have any 'responses'.
When the user says, 'How do I setup your app?', entity's prompt gets triggered and the user says - Ios / android. Now, based on this device type value, can I route the conversation to one of the followup intents?

If you are using a webhook, you should be able to use an if statement to change the intent response based on the entity that was used by the user. Something like this.
if(iosEntity) {
conv.contexts.set("ios", 1);
return conv.ask("Ios response");
} else {
conv.contexts.set("android", 1);
return conv.ask("Android Response");
};
It isn't really changing to the "fallback intent", but it would allow you to change output based on the entity.

I'm curious if the user device type is able to be detected? If so, asking this question will invite potential conflicting response, and enable ios settings on Android and vice versa. I'm sorry not answering but asking another question - I feel it's more efficient than posting a new question.

Related

( Alexa ) Is it possible to get the response in same Intent Handler?

I have a custom Alexa Skill similar to some Q&A skill , in which I'm asking the user for a response (say option_1, option_2, option_3), but when the user responds with one of these asked options a different intent (say ruleIntent) is triggered because the option text is somewhat similar to its utterances.
I think it is not a good design if more than one IntentHandler is triggered for same( or similar) phrase, but then I don't know the text of options in advance to avoid this (or what the user is going to speak out as the answer of asked question). What if I can somehow maintain the context of user's response, I think that will be one of the solutions.
Example : -
1.User : Start a Science test {Invokes testIntent }.
2.Alexa : Okay, but before starting do you want to know the rules. Please answer in Yes or No. { response generated from testIntentHandler}
3.User : Yes { invokes many intents }
In line 3 even if I hard-code this to a Intent (say ruleIntent) , then what will happen if some question contains its options as Yes or No. How will I differentiate that and map that to the response of asked question.
One way to deal with this is to track the state using persistent or session attributes.
You can do a check of the state in the canhandle method to route the user to appropriate test intent
One way to solve this could be to use Dialogs. You can use auto delegation for dialogs
Enable auto delegation, either for the entire skill or for specific
intents. In this case, Alexa completes all of the dialog steps based
on your dialog model. Alexa sends your skill a single IntentRequest
when the dialog is complete
Delegate the Dialog to Alexa

Dialogflow - Multiple Yes / No Questions not staying in context

I am trying to setup a structure in the Dialogflow console that involves multiple yes / no questions. It looks like something like this:
Agent: do you want to go to Basel?
If User: No -> Agent: Do you want to go to Zurich?
If User: Yes: Great, you chose Zurich!
If User: Yes -> Agent: Great, you chose Basel!
Basically, it keeps asking questions based on something like a location and when the user says Yes, it responds with with the chosen location.
If the user says yes for the first question everything works fine. However, when the user responds with yes for a followup question, Dialogflow still maps the intent of the first question and responds with:
Great, you chose Basel!
Instead of:
Great, you chose Zurich!
In the image you can see my intent structure from the Dialogflow console.
IntentStructure
Does anyone have any recommendations here? I am aware that the mutliple yes / no questions all contain the same examples, but how can I make sure that Dialogflow stays in context?
I will suggest not to keep all your intents as a follow-up intent. Instead, you can manage all your contexts. What you have to do is that create an intent for each location and two follow-up intent "Yes" and "No". If the user responds with yes show the message else add your next question to the no follow-up intent response and set its output context for the new location "yes" follow-up intent. Similarly, you can create a chain.

Is there any way to ask for confirmation from user using inline-editor instead of using follow-up intents?

I have two intents get_name and get_age
in get_name I take the user name, this intent is enabled for fulfillment.
In the editor, how to ask for confirmation of the name?
if confirmed, then I should add output context to get_name, so that get_age intent gets invoked.
i tried using the conv object to start a conversation without leaving the intent, but it does not even call the function.
function confirmation(agent){
var entity_name = agent.name;
var name = agent.parameters.name;
var conv = agent.conv();
conv.ask(`Is ${name} correct?`);
agent.add(conv);
var user_query = conv.query;
if(user_query.entities.name=='yes'){
agent.setContext({
name: `${entity_name}`+'_done',
lifespan: 2
});
agent.add(`Give your age ${name}`);
}
}
You're mixing up a couple of concepts. While it is possible to use the Inline Editor to do fulfillment, and it is possible to confirm an entry from a user without a Followup Intent, you will still need additional Intents to do the confirmation.
There are two important things to understand about Dialogflow fulfillment programming:
All responses from the user have to come through an Intent. It doesn't need to be a unique or Followup Intent, but the intent of what the user says is always captured this way.
When an Intent is triggered, it can send the information to an Intent Handler. This is the only way an Intent Handler gets information from the user. When a Handler is triggered, it does not wait for further user input. All it can do is send a reply.
So in your code, once you have sent
conv.ask(`Is ${name} correct?`);
agent.add(conv);
you will not get the response from that prompt in the same Intent Handler.
You will need another Intent that can capture the user saying yes or no. You can do this as one Intent or two - which you do is up to you. Based on what the user says, you then prompt them again.
Your issue is similar to what is described in this article, which points out that how we reply is based on two things:
The current state (in your case, which question you are asking them to confirm)
The user's reply ("yes", in which case you save the info and ask about the next question, or "no", in which case you repeat the question)

How to redirect to another intent within a Google Action (Google Assistant Action)

Currently I'm creating an Action for the Google Assistant.
In this Action, I ask the user to provide its phone number. After this, another intent will repeat the phone number given, and asks if it's correct. If the user responds with 'no', I would like to redirect the user back to the first intent, so it can provide its phone number again. It should be a kind of loop.
(I'm working in a local environment, so only the intents are created within Dialogflow.)
I tried to apply contexts for this case, but in someway it won't succeed.
Thank you guys!
Remember that Intents represent what the user has said, and not what you are doing with that data. So saying that "another intent will repeat the phone number" suggests that you're making some things more complicated.
A better design is likely to have the Intent that collected the data to several things:
Repeat the phone number back
Prompt if this is correct
Set a content indicating you have prompted for confirmation
You can then have another Intent handle the "yes" or "no" statements responding to this prompt. The user may say other things, remember, including giving a correction to the phone number.
See also these articles (based on a StackOverflow question and answer) on designing a conversation and the Dialogflow Intents based on that conversation:
Thinking for Voice: Design conversations, not logic
Conversation to Code (Part 1)

Dialogflow inline editor ask for additional info

I am developing a google assistant app on Dialogflow.
And I have a intent that receives two entities: #name and #age
Using the fulfillment throught the inline editor I verify if the #age is below 18.
In that case I need to ask for additional info, I need to ask the name of the person responsible for the child.
I looked around the internet, including the fulfillment samples at https://dialogflow.com/docs/samples
I believe it would look something like this:
let conv = agent.conv();
conv.ask('As your age is under 18 I need the name of the person responsible for you:');
//Some code to retrieve user input into a variable
agent.add(conv);
But I was unable to find how to do it.
Can someone help me to achieve this?
Thanks in advance.
While you are handling an Intent, there is no way to "wait for" the user to respond to your question. Instead, you need to handle user input this way:
You send a response back from your Intent.
The user replies with something they say.
You handle this new user statement through an Intent.
Intents always represent the user taking some action - usually saying something.
So one approach would be to create a new Intent that accepts the user's response. But somehow you need to distinguish this response from the initial Intent that captured the person's name.
One way to do this would be, in the case you ask the question about who the responsible adult is, is to also set a Context. Then you can have a different Intent be triggered only when that Context is set and handle this new Intent to get the name of the adult.

Resources