问题
Following this command in node.js using the ApiAiApp module:
app.askForPermission('To know what day it is where you are',
app.SupportedPermissions.DEVICE_PRECISE_LOCATION);
I get the following in the Actions on Google Simulator.
It correctly prompts for my response, but then is confused and doesn't recognize my answer! Is there something missing or broken in my API.AI agent? After the askForPermission
, there are no other fulfillment calls.
回答1:
The problem is likely that you need to set an Intent that will be triggered when the permission is granted. You do this by setting the Event to actions_intent_PERMISSION
.
This will look something like this:
You can set the Action to whatever makes sense for your webhook, and be sure to enable webhook fulfillment for the Intent as well.
If you need to keep track of where the permission request was initiated from, and handle it through a different Action, you can set a Context and have different handling Intents based on different Context settings.
The Fallback Intent method works because there is no better match at that point since you hadn't specified a regular Intent with actions_intent_PERMISSION
. It isn't the best choice, however, since it could match other situations from your user.
回答2:
The concept that I was missing is mentioned here.
All you have to do is create a child fallback intent for the intent you are requesting permissions from.
So if you have a few intents that ask for permissions, each of them need their own fallback intent.
来源:https://stackoverflow.com/questions/45661883/permission-response-not-handled-correctly