[Dialogflow]Update Permission through Webhook form

2019-07-11 20:28发布

问题:

ORIGINAL REQUEST: I'm trying to implement the push notifications following the documentation: https://developers.google.com/actions/assistant/updates/notifications

I'm using Dialogflow with webhooks (in PHP) and the documentation is giving example in nodeJS

Right now, i'm blocked because of the Update permission, here's my Webhook response :

{
"source": "webhook",
"payload": {
    "google": {
        "expectUserResponse": true,
        "systemIntent": {
            "intent": "actions.intent.PERMISSION",
            "data": {
                "@type": "type.googleapis.com/google.actions.v2.PermissionValueSpec",
                "permissions": [
                    "UPDATE"
                ]
            },
            "updatePermission": {
                "intent": "notification.simple.text"
            }
        }
    }
}
}

When I do the simulation, asks me a permission for a push, but not for the intent I specified.

I'm quiet sure that the problem is the updatePermission, something must be wrong with that: Is it the field name? In intent, i put the intent name that i filled in dialogflow, maybe do i have to an use action? Is it in the good format ?

If someone can help me or just give me an example of a clean response for an update permission.

Thanks!

Solution

I just found why, my json wasn't good, the updatePermissionValueSpec must be into data object.

{
"source": "webhook",
"payload": {
    "google": {
        "expectUserResponse": true,
        "systemIntent": {
            "intent": "actions.intent.PERMISSION",
            "data": {
                "@type": "type.googleapis.com/google.actions.v2.PermissionValueSpec",
                "permissions": [
                    "UPDATE"
                ],
                "updatePermissionValueSpec": {
                    "intent": "notification_simple_text"
                }
            }
        }
    }
}
}

回答1:

I believe updatePermission should be named updatePermissionValueSpec.

Example response:

"payload": {
  "google": {
    "expectUserResponse": true,
    "richResponse": {
      "items": [
        {
          "simpleResponse": {
            "textToSpeech": "PLACEHOLDER"
          }
        }
      ]
    },
    "systemIntent": {
      "intent": "actions.intent.PERMISSION",
      "data": {
        "@type": "type.googleapis.com/google.actions.v2.PermissionValueSpec",
        "permissions": [
          "UPDATE"
        ],
        "updatePermissionValueSpec": {
          "intent": "intent_name"
        }
      }
    }
  }
}