[英]Actions on Google - Suddenly keeps getting into fallback Permission
在我的設備上,它會記住位置許可已被接受並跟進意圖,其他一切正常。 但是在模擬器上它不想再記住了。 它一直在說:
對不起,我沒聽懂。 馬上,但首先,我需要從 Google 獲取你的當前位置。 這樣好嗎?
不管你說是什么,不管它是不會發生的。 就像他仍然在請求位置許可的意圖中一樣。 這是我的 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我在真實設備上對其進行了測試,它可以正常工作。 看起來,問題出在 actions-on-google 上。
它適用於設備但不適用於模擬器,這似乎很奇怪。
但實際上,我認為應該是在 Dialogflow 中聲明事件actions_intent_PERMISSION
的handler_permission_location_details
意圖。
我還有一個執行定位權限的代理,可以找到附近的超市。 這是一個有效的簡短片段。 Locate supermarkets - Resolve permission
intent 是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
事件並實現了結果的處理程序
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.