Dialogflow webhook - First fulfill the current Intent and then trigger another Intent - dialogflow-es

Lets say I have two Intents QuotationIntent and SalesRepresentativeIntent.
The QuotationIntent, gets some input from the user and returns appropriate result through web-hook. After successful fulfillment, I want to trigger the SalesRepresentativeIntent to check with the user if they want our sales representative to call them. I am able to trigger the Intent through events. But the problem is QuotationIntent fulfillment message is skipped.
I don't want to add a follow up intent directly to QuotationIntent, as there are many intents from which I will have to trigger SalesRepresentativeIntent.
Can you please tell me how to achieve this? Thanks in advance.

You may use context here. Add output context say "QuotationDone" in your QuotationIntent. Use the same context as the input context for SalesRepresentativeIntent. This way SalesRepresentativeIntent will be triggered only when QuotationIntent is completed.
To trigger SalesRepresentativeIntent you need to add either "user says" phrases and train your agent or add EVENTS to your intent.
This way your SalesRepresentativeIntent will only be triggered when the following condition met:
if((inputContext is present) AND (event is triggered OR user says phrase is present)){
trigger `SalesRepresentativeIntent`
} else {
fallback intent called
}
The other way you can do your task is to use SLOTS. Here in single intent, you can have multiple parameters collected. Add parameters that you want to collect. In your case whatever you are collecting in QuotationIntent you can collect it in first few parameters and make them as required and then the things you need to collect in SalesRepresentativeIntent you can collect in other parameters in the same intent. Arrange the order of the parameters in the order you want your bot asks from your users. This way your responses will be asked automatically depending on the parameters are collected from the user or not.

Related

DialogFlow: simple ways of passing parameters between intents and from previous context to the current context? (Without using fullfillment)

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

Dialogflow fulfillment chose among options

I am writing you to ask a question about Dialogflow fulfillments.
I am trying to create an agent for Google Home and my backend is basically a web hook implemented in TypeScript.
In the conversation that I designed, the user requests to the agent to perform an action, providing a category as paramter. Now, the set of possible categories can vary through time, so I am using the entity type #sys.any to detect the parameter.
My problem is that, when on the fulfillment I try to identify the specific category on which the agent needs to take action, it may be the case that the requested paramter matches multiple cateogries, so I'd need a followup intent to ask the user to clarify which is the actual category it wants to select.
E.g. the conversation could be the following:
Agent: 'Welcome.'
User: 'Do action on **category**'
Agent: 'I have found **categoryA**, **categoryB** and **categoryC**. Please specify which one you want to select.'
User: 'Select the second || Select **categoryB**'
Agent: 'Great, action performed on **categoryB**'
Now, I was able to build this conversation using followup events and contexts: for example I created two followup events, one that detects the numbers and another that detects the text, so the user is driven on one or another depending on what it says (if the user says 'The first', a number is detected and in the backend I cycle the categories selecting the one that is associated to that index. I do a similar operation if the user says "categoryX", but inside a different intent).
What I want to understand is: what is the proper way to achieve that kind of conversation through the Node.js fulfillment API?
Thank you for any help.
From your description - you've done precisely the right thing (although you don't need followup intents).
When you reply with the options the user has, you include a Context that may contain the array of possible results. You then create Intents that have this as an Input Context, match either the index of the array (lets call this the match.index Intent) or by name (the match.name Intent).
In your webhook, the match.index Intent would determine which category was actually chosen, and then call a function that takes care of that category. Similarly, the webhook for match.name would take the parameter with the name and call the same function to take care of that category.

Dialogflow required parameters

In my dialogflow chatbot i am creating i have a scenario where a user can ask what are the available vacancies you have or they can directly ask i want to join as a project manager or something. Both are in the same intent called "jobs" and the position they want is a required parameter. If user don't mention the position (eg - "what are the available vacancies you have" ) it will list all available vacancies and minimum qualifications need for that vacancy and ask user to pick one (done with slotfilling for webhook.). Now since the intent is waiting for the parameter when user enter the position they like it will provide the details regarding that position. But even when user is trying to ask for something else (trying to call to a another intent or they don't have enough qualifications for that vacancy or the needed job is not listed with the available job list) since that parameter (the Job position) is not provided it ask again and again what is the position you want.
how do i call to another intent when the chatbot is waiting for a required parameter
There is a separate intent for "The job i want is not here". If i typed the exact same one i used to train that intent then i works. but if it is slightly different then it won't work
Try this:
make your parameter as "NOT" required by unchecking the required checkbox.
keep webhook for slot filling.
in the webhook, keep a track if the parameter is provided or not.
if the intent is triggered, check programmatically for parameter and ask the user to provide it by playing with the contexts.
if the user said something else, then there will be no "required" parameter as per Dialogflow and it will not ask repeatedly to provide the parameter.
Let me know if this helped.

How to restrict user input to a specific intent in dialogflow v2 using the inline editor/fulfilment

Lets say I have two intents "Intent1" and "Intent2" and both intents are triggered by the word/training phrase "yes".
If I go into the dialogflow intents tab and from there enter intent1-context and intent2-context into the respective input contexts is there a way to isolate the Intent I want the word "yes" to trigger? And to do this from within the inline editor?
I'm sending responses back to the user from the inline editor eg:
function send_response(agent)
{
agent.add("Say 'yes' to trigger Intent2");
}
But when the user says 'yes' either Intent1 or Intent2 will be triggered because they both take 'yes' as input.
In a previous post I was given some advice re: agent.setContext but implementing this didn't seem to work. Not sure if that was the right method for what I am trying to achieve.
Thanks.

how can we pass the user original query across all followup intent in dialogflow

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.

Resources