dialogflow / dialogflow-fulfillment-nodejs

Dialogflow agent fulfillment library supporting v1&v2, 8 platforms, and text, card, image, suggestion, custom responses
Apache License 2.0
597 stars 281 forks source link

WebHookClient add function is not working to handle PermissionValueSpec #259

Open 4rpit opened 4 years ago

4rpit commented 4 years ago

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)
cibergarri commented 4 years ago

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