Google上的操作-突然进入后备权限

时间:2018-12-06 11:34:27

标签: dialogflow actions-on-google dialogflow-fulfillment

在我的设备上,它会记住位置权限已被接受,并且可以跟踪意图,并且其他所有操作都可以进行。但是在模拟器上,它不再想要记住。它一直在说:

  

对不起,我听不懂。马上但首先,我需要得到你   Google的当前位置。可以吗?

无论您说什么,都不会。 就像他仍在寻求位置许可的意图一样。 这是我的网络挂钩,并提供了一些模拟器和调试的屏幕截图。

    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?`);
    }
);

enter image description here enter image description here enter image description here enter image description here

更新#1 我在真实设备上对其进行了测试,并且可以正常工作。看来,问题出在Google的行动上。

1 个答案:

答案 0 :(得分:0)

似乎奇怪,它可以在设备上运行,但不能在模拟器上运行。

但是实际上,我认为应该使用handler_permission_location_details意图在Dialogflow中声明事件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事件并实现了结果处理程序

enter image description here