在我的设备上,它会记住位置许可已被接受并跟进意图,其他一切正常。但是在模拟器上它不想再记住了。它一直在说:
无论如何,如果你说是,不管它不会去。
就像他请求位置许可的意图一样。
这是我的 webhook,并提供了一些模拟器和调试的屏幕截图。
app.intent('location_permission_question', (conv) => {
if (conv.user.storage.currentReservationID) {
return conv.ask(`No can't do, you have an active reservation.`)
}
return conv.ask(new Permission({
context: `Right away but first`,
permissions:
['DEVICE_PRECISE_LOCATION'],
}));
});
app.intent('handler_permission_location_details', (conv, params, permissionGranted) => {
if (!permissionGranted) {
return conv.close(`I can't help you then.`);
}
const userLatitude = conv.device.location.coordinates.latitude;
const userLongitude = conv.device.location.coordinates.longitude;
conv.user.storage.currentUserLocationLatitude = userLatitude;
conv.user.storage.currentUserLocationLongitude = userLongitude;
return clientInitGetNewLocations(conv, userLatitude, userLongitude, false)
});
app.intent('choose_car', (conv, {carModel}) => {
if (!conv.data.cars[carModel]) {
if (conv.surface.capabilities.has('actions.capability.SCREEN_OUTPUT')) {
conv.ask(new Suggestions('Next Location'));
}
return conv.ask(`I'm sorry but that car model isn't available at ${conv.data.currentLocation.name} you can choose between ${conv.data.carsNames.toString().replaceAll(',', ' and ')}. Which one do you want?`);
}
let car = conv.data.cars[carModel][0];
conv.user.storage.carWaitingForConfirmation = car;
let carName = car.carModelID.manufacturer;
const battery = car.batteryChargeLevel;
const pricePerKM = car.pricing.pricePerKM;
const pricePerMinDay = car.pricing.pricePerDayMin;
const pricePerMinNight = car.pricing.pricePerNightMin;
if (conv.surface.capabilities.has('actions.capability.SCREEN_OUTPUT')) {
conv.ask(new Suggestions(['Yes', 'No']));
}
return conv.ask(`${carName} at ${conv.data.currentLocation.name} has ${battery}% of battery and costs ${pricePerMinDay}€ per minute and ${pricePerKM}€ per kilometer. Is that okay?`);
}
);
更新 #1
我在真实设备上对其进行了测试,并且可以正常工作。看起来,问题在于对谷歌的操作。
最佳答案
它适用于设备但不适用于模拟器,这似乎很奇怪。
但实际上,我认为在 Dialogflow 中声明事件 handler_permission_location_details
的应该是 actions_intent_PERMISSION
意图。
我还有一个代理,可以实现位置权限以查找附近的超市。这是一个有效的简短片段。 Locate supermarkets - Resolve permission
意图是 Locate supermarkets
的后续。
app.intent('Locate supermarkets', conv => {
conv.ask(new aog.Permission({
permissions: 'DEVICE_PRECISE_LOCATION',
context: 'To look for supermarkets near you'
}));
});
app.intent('Locate supermarkets - Resolve permission', (conv) => {
if (!!conv.arguments.get('PERMISSION')) {
// permission granted
} else {
// permission NOT granted
}
});
Locate supermarkets - Resolve permission
声明了 actions_intent_PERMISSION
事件并实现了 result 的处理程序关于dialogflow-es - Actions on Google - 突然进入后备权限,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/53650536/