Disable mic in google action after the response - dialogflow-es

I am building a google action using dialogflow agent. Now after every response from the dialogflow agent mic is in active state, i want mic to be inactive state after the response from the agent. Is there a way where i can configure in google action to deactivate mic after the response?

Actions on Google has an intentional conversational experience. You start the conversation with an invocation, it responds, you respond, and so on.
If an Action wants to end the conversation, it can do that and close the mic.
The user experience of an Action providing a response and not expecting the user to reply is not behavior encouraged by the platform.

I've been tacking on a randomly selected "what's next' prompt. I don't know if it will pass review though:
const whatNextPhrases = [
'What else can I help with?',
'What can I help with next?',
'What would you like to do?',
'Can I do anything else for you?'
];
I can't comment due to rep, but to answer Prisoner's question - there are use cases where it's just poor conversational flow for the agent to immediately reply. For example, if you present a list of (up to) 30 items to a user, you're expecting the user to take a moment to "take it in" before asking her next question. It's like if you go into Tiffany & Co and say "may I see your diamond rings between $1500 and $2000" and the clerk takes out 6 rings, puts them on the counter and immediately continues the conversation with like "which one do you want"? Any concierge or shopping experience the conversation should be able to reopened at the user's discretion without prompting with mic. What's interesting is Google has actions like limerick which do exactly that. Why? Because after it reads the limerick, it probably figures you want to look at it some more before asking for another.

Related

How to prompt a question from lambda function to user when dialogState is completed

I am creating an Alexa skill, but it got rejected by Amazon. The way my skill works is as follows,
User: "alexa, ask doctor is it safe to use vaccine during pregnancy"
Alexa: "gives a response, fetched from DynamoDB"
- (dialogState: Complete)
I got the following review comments from Amazon:
After the skill completes a task, the session remains open with no prompt to the user. The skill must close the session after fulfilling requests if it does not prompt the user for any input.
Can anyone help me with this?
I tried to use DelegateDialog but it doesn't seem to work.
handler_input.response_builder.add_directive(DelegateDirective())
.speak(message)
.ask(reprompt)
.set_card(SimpleCard("Custom", message))
I want Alexa to ask a question to the user, like "Do you have any other question?"
So that the conversation doesn't end and keeps going. I don't want to close the session right after Alexa sends the answer.
A couple of things:
delegate directive is when you want ASK(Alexa Skills Kit) to determine the next thing to speak. This only makes sense if you have a dialog model (requires slots, elicitation prompts, etc.) and the dialog is not yet completed. You do not seem to be using dialog model and at any case you are both delegating and providing speak() which I don't think is what you want.
For your scenario, you will likely want to produce a complete output that has both the answer and the next question. it can be as simple as string-append: message = db_response + ". Anything else?"

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)

How to add text responses to selected suggestion chips on Dialogflow

I added suggestion chips to the Dialogflow Chatbot, but I want them to continue with an existing flow based on the button selected. How can I achieve that?
For example: How else can I help you?
Locate store Choose an item About Us
I would like the user to go these flows which already exist.
How can I achieve that?
You would make each of these choices a new Intent, and take action based on that Intent being triggered. Intents represent a specific activity by the user - typically something said or entered, or a selection chip being selected. Suggestion chips are handled just like the person entered what was on the chip.
However, keep in mind that these are just suggestions. Users can enter whatever they want. You need to be prepared for them to take the conversation in a different direction or skip ahead in the conversation. For example, in response to your prompt above, they may try to send feedback, or they may enter something like "find a store near me" and ignore the suggestion chip. You need to account for this when designing your conversations and Intents.

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.

dialogflow : Don't understand how can i retrieve the context by coding

I've something that I don't succeed to understand.
Here the situation I would like to do :
Bot: Hello, what do you want to do ?
User: Search a product
Bot: Which
product are you looking for ?
User: Apple
Bot -> list of products
matched with apple
here is a fragment code :
function searchProduct() {
agent.add('Which product are you looking for ?');
// receive the product answer
//-> then research the matched product in DB
}
const intentMap = new Map();
intentMap.set('I want a product', searchProduct);
agent.handleRequest(intentMap);
In this code, I ask to user the product that he's looking for.
But when he answered "Apple", how can I receive the user response in the same function to continue my process ?
I know there is the "context" concept, but to continue the "search product" process, I need to come back in the function.
For now, I use dialog-fulfillment. And I try to understand this documentation to find the solution :
https://github.com/dialogflow/dialogflow-fulfillment-nodejs/blob/master/docs/WebhookClient.md
The short answer is that you can't (or, at the very least, shouldn't) do it in the "same" function. Each function represents an Intent, or what the user has communicated to us. In the function we need to do the following:
Determine what the user has said that is important to us.
Compute anything based on what they've said.
Send a reply to the user based on (1) and (2).
Once we have sent the reply to the user - that round of the conversation is over. We need to wait for the next Intent to be triggered by the user so we can repeat the above.
Contexts are used so we know which stage of the overall conversation we're in. As part of our reply (step 3 above), we can set a Context which will help Dialogflow determine which Intent should be triggered (and thus which function should be called to process what we know so far). Contexts can also store information about previous turns of the conversation.
Keep in mind that Intents aren't about what we say, but are about what the user says. The reply we send is based on what we need, and then we would use a single Intent to capture each part. The function that handles that Intent would store the answer in the Context and determine the next part of the question.

Resources