I have an intent which reads the user_id. When the user asks for his history or new test i want to use the same intent user_id to get his ID.
As far as i have understood when i use multiple input contexts all of them need to be satisfied.
How would i go about doing this?
Edit: I am a beginner so i dont know if this is the right way to do it but it seems to work
function customerIDHandler(agent){
if(agent.getContext('view-history') !== null){
}else if(agent.getContext('test-menu') !== null){
}
}
where view-history and test-menu are two output context used just to show which path i came from to this intent
You don't need one Context per ID, you just need a Context to store the ID in the parameters. In the Intent where they express their ID, set an Outgoing Context and it will store the ID as a parameter. Then, in future Intents, you can use this parameter from the Context in your fulfillment.
Related
Hi I’m look in for simple solutions for passing values between intents and contexts.
I’ve tried to set output context (c1) for intent A, and use c1 as input context for intent B. However, I’m not able to access the parameters value within intent B. Do I have to use fullfillment to implement this ?
Besides, I also want to use the previous parameters’ value of intent A when intent A is triggered next time. Again, can we do this without using fullfillment?
If fullfillment is essential, can you give some guidance please?
Accessing parameter values from one intent to another where contexts are used can be done from the Console itself. Fulfillment Webhook response can also be used but for your use case this can be done from the Console itself.
You can refer to the below replication steps:
In the text response of Default Welcome Intent add Hi what is your name? and add an output context awaiting_name.
Create another Intent Get Name and in that pass “awaiting_name” as input context . Pass some training phrases like "john,sandeep,jacob" and map it with them to the #sys.given.name entity.
In the Get Name Intent the text response is Ok $name, what is your email address?. Add awaiting_email in the output context field of this intent.
Create another intent “Get Email” and add awaiting_email in the Input context. Add training phrases like "sandeep#abc.com","john#xyz.com" and map them with #sys.email entity.
When you want to fetch the parameter value from another intent to the present intent where context is used you need to call it by #context-name.parameter-name as per this doc.
My final output response is Thanks #awaiting_name.name we will contact you soon on $email
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)
I'm new to dialogflow. In my default Hello Intent, I have something like this:
Good day! My name is xyz and I'm here to help you. May I know your name please?
This response is for when users say something like "hi"
After that, I will pass the context to another Intent to wait for the name input
I would like to avoid asking these information if I already have the user's contact information. Is there away to check for the context and trigger a different response?
If you just need to check if the context contains a property called "name" or similar, simply add a parameter in the second intent, set its value to #awaiting_contact.name and enable the mandatory option. That will let you define prompts if the property has no value, so you can re-ask the user.
However, I'm not sure what the Welcome Intent context has. You are just giving a welcome message. Then, when the user inputs his name, this will trigger a different intent.
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.
I have one intent named "search.category" which has user queries like "32gb phones" and it has a follow up intent to get_brand question like "do you have any specific brand? ".
This can have two type of answers that user can enter brand name or he can say "I don't know."
Is there any way to pass the whole user query in main intent to followup intents.
How can we pass the original user query(32gb phones) as a parameter across the intents?
In the second picture, you can see that two entities are selected, so is there any way to select the other text from user query ( I want the "show me some under 40000")
To do this, you would create a new Output Context on the first intent. Output contexts created as part of an intent contain the parameters that were set by the user when they were created and are available in subsequent intents (for as long as their lifespan is active). You can access the context's parameters either in the response or in your fulfillment webhook.
If you're trying to use values that aren't set in the parameters, then in the fulfillment of the original intent you can set any value you want as a parameter of an Output Context that you create in your webhook.