Send back rich responses to Actions on Google through Dialogflow webhook fulfillment - webhooks

To get Google Assistant to display rich responses to the user, one must provide it with a response like the example on the Actions on Google docs. However, since I'm using Dialogflow as the intermediary party between my server and Google's, I need to provide some kind of response to Dialogflow in my webhooks to indicate that there should be a rich response. As you can see from that link, the docs mention how to send rich responses to FB Messenger, Kik, LINE, etc. but not Google Assistant.
What am I missing here? I see an option for rich responses in the Dialogflow web console, but there I can only seem to input hardcoded responses with no dynamic data from the server. What's the right way to do this?

Using the Dialogflow integration, the response JSON your webhook should return for a rich response will look like:
{
"data":{
"google":{
"expectUserResponse":true,
"noInputPrompts":[
],
"richResponse":{
"items":[
{
"simpleResponse":{
"textToSpeech":"Welcome to this Basic Card",
"displayText":"Welcome to this Basic Card"
}
},
{
"basicCard":{
"buttons":[
{
"title":"Button Title",
"openUrlAction":{
"url":"https://some.url"
}
}
],
"formattedText":"Some text",
"image":{
"url":"http://some_image.jpg",
"accessibilityText":"Accessibility text describing the image"
},
"title":"Card Title"
}
}
],
"suggestions":[
{
"title":"Aléatoire"
},
{
"title":"Top"
}
]
}
}
}
}
If you are using the Node.js library You can also use the provided methods for Dialogflow integration to build your rich response.

If you're using Node.js you should call the method buildRichResponse() and then add items as child of that object, like this:
app.ask(app.buildRichResponse()
.addSimpleResponse('A text to be spoken')
.addBasicCard(app.buildBasicCard('Some text to be displayed')
.setTitle('A title')
.addButton('Read more', 'https://example.google.com/something')
.setImage('https://example.google.com/image.png', 'Image alternate text')
.setImageDisplay('CROPPED')
)
);
That was an example for adding a BasicCard, you can see how to add Carousels, Lists and Suggestions Chips at https://developers.google.com/actions/assistant/responses#rich-responses

Related

Problem cancelling intent while filling intent parameter with word "disregard"

I have a google Action with intents that require slot/parameter filling. My Action was recently rejected by Google for leaving the mic open without prompting the user and I cannot resolve the issue.
As an example I have an intent named "trunk" which has a parameter "vehiclename".
I invoke the “trunk” intent without filling the vehiclename parameter. The assistant attempts to fill the first parameter by asking me “what is the vehicle name?” (verbiage I've defined to help with the slot filling). I respond with “disregard”. Then the assistant replies with “Sure, cancelling.” (or another similar phrase). I want to know where this response is coming from. The detailed response json is:
{
"conversationToken": "[]",
"expectUserResponse": true,
"expectedInputs": [
{
"inputPrompt": {
"richInitialPrompt": {
"items": [
{
"simpleResponse": {
"textToSpeech": "Sure, cancelling.",
"displayText": "Sure, cancelling."
}
}
]
}
},
"possibleIntents": [
{
"intent": "assistant.intent.action.TEXT"
}
],
"speechBiasingHints": [
"$vehiclename"
]
}
],
"responseMetadata": {
"status": {
"message": "Success (200)"
},
"queryMatchInfo": {
"queryMatched": true,
"intent": "686ab942-5132-451b-9a16-16dbe8648ad0"
}
}
}
This response body has “expectUserResponse”: true which explains why the mic is being left open. And since the phrase "sure, cancelling" doesn't prompt the user, it violates google's design guidelines.
What’s important about this is that I have not created this response! It is nowhere in our intents, and it is not being returned by our API webhook. Our webhook is not even being called in any of this example.
Syntactically it makes sense that google assistant would treat “disregard” as any of the other stop words (e.g. “stop”, “cancel”, “never mind”, etc.) but it doesn’t treat it the same. Any of those other words exits the app as one would expect.
Furthermore, none of these stop words are invoking a “quit” intent which has the actions_intent_CANCEL event attached to it. According to google’s documentation here: https://developers.google.com/assistant/df-asdk/conversation-exits when uttering any of these exit words, the conversation should be routed through to our “quit” intent, but it doesn’t.
I’ve also tried attaching the actions_intent_NO_INPUT action to our quit intent, but that also isn’t triggered in this situation. After the assistant has responded with “sure, cancelling”, the conversation is basically stuck there and I can’t invoke another intent or provide any more dialog to prompt the user.
Main takeaway:
Where is this “sure, cancelling” response coming from?
How do we route the conversation to another intent from that response so that we can prompt the user again OR
How do we route the word “disregard” in such a way to avoid this errant response? Can we disable it?
reminder: this is only an issue when trying to fill an intent parameter, and it is only an issue with the word “disregard”

Incomplete API response for getUsers

I'm implementing an API integration for DocuSign, and I'm currently hitting the following endpoint: /v2/organizations/{organizationId}/users
The documentaton for this: https://developers.docusign.com/docs/admin-api/reference/users/users/getusers/#response200_docusign.api.organizations.web.models.restapi.v2.response.organizationuserresponse
The documentation is showing a response field, user_status. However, when I call the API, I get a response as follows:
{
"users":[
{
"id":"xxx-xxx-xxx-xxx-xxx",
"user_name":"Xxxx",
"first_name":"",
"last_name":"Xxxx",
"membership_status":"active",
"email":"xxxx#gmail.com",
"membership_created_on":"2021-07-30T02:24:20.243",
"membership_id":"xxxx-xxxx-xxxx-xxxx-xxxx"
},
{
"id":"yyy-yyy-yyy-yyy-yyy",
"user_name":"Yyyyy",
"first_name":"Yyyyy",
"last_name":"2",
"membership_status":"active",
"email":"yyyyyyy#yyy.yyy",
"membership_created_on":"2021-07-30T02:26:59.313",
"membership_id":"yyy-yyy-yyy-yyy-yyy"
},
{
"id":"zzz-zzz-zzz-zzz-zzz",
"user_name":"Zzzzz",
"first_name":"Zzzz",
"last_name":"Zzzz",
"membership_status":"active",
"email":"zzz#zzz-zzz.net",
"membership_created_on":"2021-07-15T04:05:18.803",
"membership_id":"zzz-zzz-zzz-zzz-zzz"
}
],
"paging":{
"result_set_size":3,
"result_set_start_position":0,
"result_set_end_position":2,
"total_set_size":3
}
}
As you can see, we have no user_status. Do we need to send any request parameters, to expand the response, or has this field been removed from the API response without being updated on the API documentation?
Or, could I assume that the user is active, if it appears in the API response, with a membership_status of active?
Thank you very much!
membership_status is probably what you're looking for.
there's no such thing as user_status because a user can be a member of multiple accounts and each membership can have a different status.
Here is a useful diagram:

How to set dialogflow fulfillment response json context without using webhook client?

I want to create a rich response to Facebook integration using Dialogflow fulfillment. I tried using webhook but it's not working and then I try below way directly using response and now I am facing this context binding issue.
I tried below
let responseJson = {};
let rich = [
{
'text': {
'text': [
text
],
},
'platform': 'FACEBOOK'
},
];
responseJson.fulfillmentMessages = rich;
responseJson.outputContexts = context;
response.json(responseJson);
my context JSON
{ name: 'MAINTENANCE_REQUEST', lifespan: 5, parameters: { maintenanceRequest: maintenanceRequest }}
To add a custom payload without a webhook, go to your intent, and scroll to the bottom where it says "responses". Click on the plus sign (picture) and click on the facebook option. Click on the add responses -> custom payload. The format and available fields for the custom payload are described here. Delete the "Text Response" if it's there so the custom payload will be the only one to be returned.

Facebook Messenger Extensions on Microsoft Edge -- GET parameters absent

I want to use Facebook Messenger Extensions (opening a Webview) with Microsoft Edge.
My app sends a request to the REST API endpoint messages. The payload is as follows. Documentation on this.
{
"messaging_type":"RESPONSE",
"recipient":{
"id":"<id>"
},
"message":{
"attachment":{
"type":"template",
"payload":{
"template_type":"button",
"text":"Test text",
"buttons":[
{
"type":"web_url",
"url":"https://c0292fc0.ngrok.io/facebook/render_multi_choice?data=24561",
"title":"Test Button",
"webview_height_ratio":"full",
"messenger_extensions":"true",
"fallback_url":"https://c0292fc0.ngrok.io/facebook/render_multi_choice?data=24561"
}
]
}
}
}
}
When the user taps the button "Test Button" in Messenger, a Webview pops up and displays the response at the fallback URL / URL : https://c0292fc0.ngrok.io/facebook/render_multi_choice?data=24561
Note the URL contains one parameter, data = 24561
My Python Flask App receives the request:
#application.route("/facebook/render_multi_choice", methods=["GET"])
def render_multi_choice():
args = request.args
print(args)
return "OK"
The issue is that one would expect args to be printed out as:
ImmutableMultiDict([('data', 24561), ('fb_iframe_origin', '')])
Yet, it is printed out as:
ImmutableMultiDict([('data', ''), ('fb_iframe_origin', '')])
My flow works fine in Google Chrome, but NOT on Microsoft Edge. Do you have any idea what the issue could be? If I open the URL directly in the browser (without the Webview), things work as expected on Edge.

Is there a way to search inside a message using Gmail API?

I have thousands of email. I need to search whether any of the message contains the text "Hello world" or any other regular expression. How can I achieve this using Gmail API?
The Users.messages: list-request supports a custom query parameter that you can use. This parameter works just the same as the search input field in the regular Gmail Client.
q = Hello world
GET https://www.googleapis.com/gmail/v1/users/me/messages?q=Hello+world
Response:
{
"messages": [
{
"id": "14f9826d5e0811ee",
"threadId": "14f9826d5e0811ee"
}
],
"resultSizeEstimate": 1
}

Resources