2

I am trying to get permissions for location and name for my app.
Here is my index.js - link

It seems to be stuck in a loop :- enter image description here

Here are my intents on API.AI :- enter image description here enter image description here

Anurag-Sharma
  • 4,278
  • 5
  • 27
  • 42

1 Answers1

6

The event actions_intent_PERMISSION needs to be attached to an Intent that will be called after the user authorizes the information to be sent. The handling for it in the webhook needs to read the information given and save it or do something with it immediately.

Your code is looping because the code that is processing the request_permission action is, itself, requesting permission:

function requestPermission(app){
    const permissions = [
      app.SupportedPermissions.NAME,
      app.SupportedPermissions.DEVICE_PRECISE_LOCATION
    ];
    app.askForPermissions('To pick you up', permissions);
}

So you will need:

  • A new intent
  • that has actions_intent_PERMISSION set for the event
  • that has a new action string associated with it
  • and maps to a new function that handles the information that the user has consented to.
Prisoner
  • 49,922
  • 7
  • 53
  • 105
  • 1
    I would just echo @Prisoner's suggestion to use the actions_intent_PERMISSION event in the new API.AI intent you create. – Sachit Mishra Jul 14 '17 at 05:02
  • Thanks @SachitMishra - I've added that bullet to make sure it was clear. – Prisoner Jul 14 '17 at 15:38
  • @Prisoner I am trying the same with dialogflow-fulfillment but I am not getting any prompt asking for permissions. – Sachin Apr 24 '20 at 03:43
  • @Sachin - Without seeing exactly what you're doing or how, it is difficult to diagnose what you're doing that varies from this answer. Please create a nw question discussing your problem and showing the code you're using. – Prisoner Apr 24 '20 at 09:25