Dialogflow API - Set location on request - dialogflow-es

I have a question regarding the Dialogflow API. I have a dialog with multiple stages. Let's just call them stage 1, 2 and 3. The deeper you are in the conversation, the higher the number. The welcome intent is 1, second 2 and the third 3.
There are three buttons (1, 2 and 3). The should set the context (or something similar..) when requesting the conversation. So button 3 connects to the dialog at 3, skipping intent 1 and 2.
I was wondering how to do this using the API? I tried setting events but somehow it's not working.
Thanks in advance!

Related

Is it possible for users to choose between a few intents for Bot Framework Composer (LUIS)?

I'm trying to get something like this Stack Overflow question but within Bot Framework Composer. In Power Virtual Agents, if the bot is not sure about which 'Topic' aka 'Intent' is the right one, it gives the user a few options. How can I achieve that in Bot Framework Composer, or at least extend the bot with code?
In your dialog, create a trigger for "Duplicated intents recognized" :
Duplicated intents recognized automatically sets some variables for the turn that you use to customize your logic in how to handle duplicate intent recognition.
From here I refer to the Enterprise Assistant template :
conversation.lastAmbiguousUtterance = turn.activity.text
You don't really need to use this, but it's set in the Enterprise template in case you want to use the user input in the bot's response
dialog.candidates =
=take(sortByDescending(where(flatten(select(turn.recognized.candidates,
x, if (x.intent=="ChooseIntent", x.result.candidates, x))), c,
not(startsWith(c.intent, "DeferToRecognizer_QnA")) && c.score >
turn.minThreshold), 'score'), turn.maxChoices)
This basically organizes the duplicate intents into a list, dialog.candidates, by
sorting the intent recognized in descending order (so first element is the highest recognition score intent)
filtering out intents starting with "DeferToRecognizer_QnA" that are automatically generated from cross-training
filtering out intent scores that don't meet the minimum threshold that you set
getting only the number of intents for max choices that you set
From here you can set your logic so that if
count(dialog.candidates) = 0
, you emit an UnknownIntent event, or emit a recognizedIntent for
=first(dialog.candidates).result
if your dialog.candidates has at least one result.
Or, you can customize your logic to handle however which way you want, which in your case is inputting dialog.candidates in an adaptive card so the user can choose which intent they wanted.

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)

Reset Context in DialogFlow V2

I would like to know how to reset contexts in DialogFlow V2. I m currently using V2 and writing the backend codes in node.js.
Got the Solution Myself:-
There are several ways to clear contexts:
In a detectIntent query, you can set resetContexts to "true".
To reset contexts when testing in the Dialogflow test console, click the 'RESET CONTEXTS' button.
In order to reset all contexts in an intent, click on the 'X' button in the 'Contexts' section below the intent name. The contexts will be cleared after the intent completion.
If you want to reset an individual context in the intent, set the context lifespan value to 0.
You can also use our /contexts endpoint to perform these operations programmatically: https://dialogflow.com/docs/reference/api-v2/rest/v2/projects.agent.sessions.contexts.
For resetting contexts via webhook, use the "outputContexts" field in the response from the web service: https://dialogflow.com/docs/reference/v1-v2-migration-guide-fulfillment#webhook_responses. Note that the contexts will be updated after the intent completion.
It depends exactly what you mean by "reset contexts", but if you want to remove a context from being considered during the next user statement, you can set the context's lifespan to 0.

How to call a intent from Node.js for DialogFlow

I am making a app for the Google Assistant and when it runs, i only want 6 people to be able to play. Is there a way to say back to the players "Only say 6 names" and then get input again? I want to use a webhook to remember the names and if it gets more than 6 names, it will call a intent that says only 6 people can play.
Thanks!
Assuming you have an intent that captures a list of names, you should just return a response from your webhook that tells the user that they've input too many names and that they should try again.
Since your original intent already captures a list of names, it will be triggered a second time when they input their amended list.

Parameter value filling with quick responses in messenger

I have created a bot using Dialogflow (api.ai) and integrated it with Facebook messenger. I want to get the parameter values from user: like city, date (today, tomorrow) by using the quick reply feature of messenger, where user is presented with select-box like options, and can tap on one of the options. The required parameter receives the user-tapped value, saving the user from typing it manually.
I cannot find anywhere in documentation any way to fill up parameter values (slots) using quick replies. There is an option to give quick replies in response section, but the response section is called on fulfilment, and if I take user input in response, then I have to create another follow up intent to process the user-response further, because the current intent gets fulfilled after response.
If I add quick replies in the response section, then I have to create multiple levels of follow-up intents. Ex: I take city input in one intent, and give two options to user (like New York, Delhi). Then I have to create two follow up intents, each for handling one reply (New York and Delhi), and then for each follow up intent, I will have to create more follow up intents to get more parameter inputs. Below is the flow diagram of this case. --->
This can get pretty complex when more levels are added! Amazon Lex has this feature of filling slots using quick replies. Can't I just fill up parameter values directly using the quick replies like Lex?
You don't have to go this far. There is a simple way of using entities & prompts in dialogflow.com. The workflow can be: Weather(intent)->quick reply(New york/Delhi)->City(intent) use entities here->quick reply(Today/Tomorrow)->Use different intents here for today & tomorrow as you will have different responses. You don't need to create different intents unless you have different responses. User says can have different parameters for which you can define different prompts as well. This will again reduce your complexity of creating follow-up intents. Let me know if you need more explanation on this.

Resources