dialogflow-fulfillment-nodejs icon indicating copy to clipboard operation
dialogflow-fulfillment-nodejs copied to clipboard

WebHookClient add function is not working to handle PermissionValueSpec

Open 4rpit opened this issue 5 years ago • 1 comments

I am trying to get permission to access location by using the below code

    const requestPermission = (agent) => {
        console.log('In permission');
        agent.add(new Permission({
            context: 'To give results in your area',
            permissions: 'DEVICE_PRECISE_LOCATION',
        }));
    };

I am geeting below error in my fulfilment

Error: Unknown response type: "{"intent":"actions.intent.PERMISSION","inputValueData":{"@type":"type.googleapis.com/google.actions.v2.PermissionValueSpec","optContext":"To give results in your area","permissions":["DEVICE_PRECISE_LOCATION"]}}"
    at WebhookClient.addResponse_ (/srv/node_modules/dialogflow-fulfillment/src/dialogflow-fulfillment.js:287:13)
    at WebhookClient.add (/srv/node_modules/dialogflow-fulfillment/src/dialogflow-fulfillment.js:254:12)

4rpit avatar Jul 28 '19 12:07 4rpit

Update to the last version of the package and try this:

const {Permission} = require('actions-on-google');
 ...

const conv = agent.conv(); // Get Actions on Google library conversation object
conv.ask(new Permission({
  context: 'To give results in your area',
  permissions: 'DEVICE_PRECISE_LOCATION',
}));
agent.add(conv); // Add Actions on Google library responses to your agent's response

cibergarri avatar Nov 11 '19 09:11 cibergarri