Integrate Dialogflow with Actions on Google with intents using Fulfillment - dialogflow-es

When I try to interact with Actions on Google it does not respond when the intent has Fulfillment active.
I receive this error in the logs of Google Cloud Platform:
MalformedResponse: Failed to parse Dialogflow response into AppResponse because of empty speech response
My webhook is responding with a follow-up event input. Here is the response from my API:
{
"followupEventInput": {
"name": "campo-harmonico-found",
"languageCode": "pt-BR",
"parameters": {
"campo-harmonico": "campo harmônico de dó maior ou campo harmônico de ré maior"
}
}
}
The Intent that should call my webhook:
The Intent that should be called after webhook respond:
What is wrong?

I'm not entirely sure what the problem is, but two things jump out at me.
Your campo-harmonico-found Intent has both Training Phrases and an Event set. You should only have one or the other. I would expect that the Event would take priority, but this could be confusing Dialogflow.
It isn't clear that you need to use followupEventInput at all. If your purpose is to just reply with this message - you can just reply with the message from the acorde Intent Handler. Most of the time we don't need to use Followup Events, we should just return the reply that we want from the Intent handler itself.

Related

Is there a way to get dialpad input through dialogflow telephony

I had written a node js server code so that dialog-flow can connect to my server through web-hook and integrated dialog-flow phone gateway. I am able to get the voice transcript text when made call to that number. But if i type any number on dial-pad i am not getting it. Is there any thing i should do to get the number input from dial-pad on call.
The response is something like this if i say 'hello' on call.
{
"responseId":"b5644842-75bf-41f3-bf84-cf7b4f02c71f",
"queryResult": :{
"queryText":"Hello.","action":
"input.welcome",
"parameters":{},
"allRequiredParamsPresent":true,
"intent":{
"name":"projects/maps-ec9e1/agent/intents/54f5f623-2011-4d95-92a7-b8e873cd55a7",
"displayName":"Default Welcome Intent"
},
"intentDetectionConfidence":1,
"languageCode":"en-us"
},
"originalDetectIntentRequest":{
"source":"GOOGLE_TELEPHONY",
"payload":{
"telephony":{
"caller_id":"REDACTED_IN_STANDARD_TIER_AGENT"
}
}
},
"session":"projects/maps-ec9e1/agent/sessions/l0vQqOpaSsq9rvJc0sMMYA"
}
}
You are looking for DTMF detection. Google's Dialogflow Phone Gateway does not support this, but you can get this capability from some third party Dialogflow Gateway products like Voximplant, Audiocodes' VoiceAI Gateway, and drachtio.org.
There is no standard method for how to do this, but generally the telephony gateway needs to detect a digit and then sends a text query or event to Dialogflow where your bot can handle it.
I wrote reviews at cogint.ai with details on how to do this for Voximplant and Audiocodes.

In a chatbot conversation using dialogflow, Is there a way to make the bot speak first?

Is it possible to format a conversation so that the bot initiates conversation using dialogflow in a web demo integration?
The objective is to say something like “Hi, I’m a bot, I can do x” to establish that it’s a chatbot rather than a human.
Can anyone suggest any idea for this?
You can set a welcome intent, then send a /query request containing an event parameter. Set the event parameter to WELCOME and your chatbot will respond with whatever conversation opening you set.
More info here: https://dialogflow.com/docs/events
If you are using something other than the API for interacting with your Dialogflow agent (Slack, Facebook Messenger, etc.) you will need to add an appropriate event under "intents" in your console (such as the "Facebook Welcome" event).
For interacting with your Dialogflow agent via the API, see below.
In the API interaction quickstart documentation, Dialogflow gives you the SessionClient's detectIntent method for sharing messages with your bot.
Each language has a different solution. But on an abstract level, you want to change the request object that you send to Dialogflow to include a "Welcome" event (no input message required), as Omegastick described.
For example, in Node.js, your request object would look like this:
// The text query request.
const request = {
session: sessionPath,
queryInput: {
event: {
name: "Welcome",
languageCode: languageCode
}
},
};
This assumes you have an appropriate intent set up in your Dialogflow console to handle Welcome events. One is provided by default that you can observe.
You can also add contexts, so that your agent gives a different greeting message based on some condition.

How to end session through Dialogflow api v2 webhook response?

I am developing Google Assistant Action (for google home) using the Dialogflow and the API v2 webhooks
I am having trouble finding how to end session!
There was expectUserResponse in API v1, there is shouldEndSession on Alexa, but I can not find anything similar for Dialogflow v2.
In the Dialogflow console, select the intent you want, and go to the Responses section.
Select Set this intent as end of conversation.
You do not need to specify a response to send back (you can do that in your code as long as Fulfillment is set to Enable webhook call for this intent)
For Dialogflow v2 the expectUserResponse attribute still works for ending a conversation on Actions on Google, its just in a slightly different place (... indicates the rest of your Actions on Google payload):
{
"fulfillmentMessages": [
{
"payload": {
"expectUserResponse": true,
...
},
"platform": "ACTIONS_ON_GOOGLE"
}
]
}

Unable to trigger event from webhook - api.ai

I need your help with the using of events for communication from webhook to demo chat (https://snag.gy/6tfGEZ.jpg) of api.ai. I have already test in telegram too and it does no work either.
My flow is the following:
The user request something from the api.ai web demo chat. for instance: “Hi, I need my access code”
Api.ai gets the intent and send it to my webhook.
My webhook starts an asynchounous operation to process user request (it could take more than 6 seconds) and returns “We are processing your request please wait a few seconds” to api.api therefore the user will see that message in demo chat.
After the asynchrounous process has been finished the next step will be call POST https://api.api.ai/api/query?v=20150910 with body
{
"event": {
"name": "result_event",
"data": {
"code": "ABDDRR787545HHTTU4545454"
}
},
"timezone": "America/New_York",
"lang": "en",
"sessionId": "a77875da-4bd5-db26-dce2-e42439d4fbde"
}
result_event already exists inside an Intent that contains the response “Your request was processed. Here your code: $code”.
The idea here is the user get the respond to his request for instance: “Your request was processed. Here your code: ABDDRR787545HHTTU4545454”
Althought I get a successfully respond of (https://api.api.ai/api/query) called from my webhook the user don’t get any response in the demo chat.
This is the screen (https://snag.gy/qN3tTC.jpg) of the intent with my event in api.ai.
What do you think I’m doing bad ?
Thanks in advance
Events in API.AI are calling methods for a specific intent. it does not trigger anything so you can not get any triggered for you web-demo bot.
this will work if you can make a custom html bot where you can call events endpoint to get the json data and show it in your html bot.

fallback intent not invoked from Carousel (Actions on Google)

I am connecting Actions on Google (on my Android) to my webhook via API.AI
When a user orders, say pizza online, API.AI creates a fallback intent and the webhook sends a json with Carousel.
This works fine. If user clicks on Carousel item, the response is sent to webhook too.
I am responding to that click by asking "How many pizzas" and use a suggestion chip.
However, no fallback intent is activated in API.AI and the app crashes.
Earlier, I was giving a simple text response to carousel select "Thanks for the order" and it was working.
Can someone help me solve this problem?
I realize that the problem is not in API.AI or fallback intent but in JSON I am sending. If I reply to user's selection in Carousel with a simple text/speech response it works. It also works if I send a Carousel chip again. However, if I try to send a list or card, it crashes. Perhaps, I don't have right json formatting for them.
If someone has any json sent by their webhook (working with API.AI) for list/suggestion chip or card, it would be very helpful!
#matthewayne When I send the following as a reply (json), it works:
speech = "Thank you. People also looked at these:"
print(speech)
webhook_result={
"speech": speech,
"contextOut": [
{
"name": "_actions_on_google_,complementary",
"lifespan": 100,
"parameters": {}
}
],
"data": {
"google": {
"expectUserResponse": True,
"richResponse": {
"items": [
{
"simpleResponse": {
"textToSpeech": speech
}
}
],
"suggestions": []
},
"systemIntent": {
"intent": "actions.intent.OPTION",
"data": {
"#type": "type.googleapis.com/google.actions.v2.OptionValueSpec",
"carouselSelect": {}
}
}
}
}
}
I also populate carouselSelect with list of things in carousel. But if I change it to listSelect, and respond, it crashes.
When I say crash, it means that Google says that my app has stopped responding.
It would be very helpful to have a template or sample listResponse json.
After a carousel response is sent to the user the next request that will be sent will likely be a list selection event. You need to handle this either:
in API.AI (by creating an intent with the event actions_intent_OPTION, docs here)
or
in your webhook using the Google Assistant client library (docs here).

Resources