2

I am developing a Google Assistant Action and want to create an event that can automatically launch an intent that I had. The problem is I cannot seem to find any good documentation on how to actually define an event so this way it launches an intent without having to communicate with the user in between.

To give you example.. I attached images of the intents I am trying to use. I want to have the user prompt get_location intent with an utterance. From this my code checks if we have permissions already, and if we do not I want the intent request-permission to be launched through an event. How do I set up the event in order for this to be done?

This is the conversation/work flow that I am looking for: - User Says: 'Book a tee time near me' - That launches my get_location intent - get_location intent checks to see if permission was granted with isPermissionGranted() - it realizes there is no permission granted - launches request-permission intent - prompt the user for permission

Here is how my intents are setup: enter image description here

enter image description here

Antonio Cucciniello
  • 643
  • 1
  • 5
  • 19
  • Could you edit the question to give an example of the dialog you're trying to build? And when you say "permissions", are you talking about Actions on Google permissions (i.e. https://developers.google.com/actions/assistant/helpers#user_information)? – Daniel Situnayake Aug 03 '17 at 18:49
  • Yes I am trying to get permissions for location. I can get permissions. What I want is a way to have the request permissions intent get launched through an event when I do not have permissions from the user. – Antonio Cucciniello Aug 03 '17 at 19:01
  • When you invoke the permissions helper, the Assistant will handle requesting permissions from the user if they haven't already granted it, so you won't need to worry about asking for permission yourself. If you're using the Node.js client library, just call `askForPermission`. – Daniel Situnayake Aug 03 '17 at 20:08
  • @DanImrie-Situnayake So the issue is not asking for permissions, I can verify that I can ask for them using `askForPermission()`. What I want to do have the API.AI launch send an event that causes the `request-permission` intent to be launched automatically. What is happening now is, I tell the user we do not have permissions, and I say 'Can I ask you for permissions?' that executes the request-permissions intent through user says phrases. I want to avoid having to prompt the user to ask if we can ask for permissions first and simply go straight to asking for permissions. – Antonio Cucciniello Aug 04 '17 at 12:52
  • @DanImrie-Situnayake I saw that you answered this on Friday, but now I cannot seem to see your answer anymore. Would you be able to re-answer this? – Antonio Cucciniello Aug 07 '17 at 12:29
  • Apologies - I realized there was a mistake in my answer and took it down so I could fix it. I'll update it now. – Daniel Situnayake Aug 07 '17 at 16:11

1 Answers1

1

It sounds like in your current implementation, you have a flow like this:

  1. User says "Book a tee time nearby".
  2. get_location intent is matched.
  3. In the webhook for get_location, you check if the user has previously granted permission with isPermissionGranted().
    • If they have previously granted, you move forward with looking up their local course.
  4. If they have not previously granted, you call ask from the webhook to ask the user's permission to ask them for permission to get their location.
  5. If they say "yes", the request-permission intent is matched.
  6. In the webhook for request-permission, you call askForPermission() and the Assistant asks the user for permission to get their location.
  7. You now move forward with looking up their local course.

In this case, the dialog will be as follows:

User: Book a tee time nearby
App:  Can I ask permission to get your location?
User: Yes
App:  [from Assistant] Can I access your location?
User: Yes
App:  Thanks, your local course is Pebble Beach and I booked you a tee time.

You're trying to avoid the process starting in step 4, where you ask the user's permission to ask them for permission to get their location.

In order to do this, you can implement the following flow:

  1. User says "Book a tee time nearby".
  2. get_location intent is matched.
  3. In the webhook for get_location, you check if the user has previously granted permission with isPermissionGranted().
    • If they have previously granted, you move forward with looking up their local course.
  4. If they have not previously granted, you should call askForPermission(), still in the webhook for get_location. The Assistant will ask the user for permission to get their location.
  5. To handle the response from the permission request, you need to create a new intent and add to it an event named actions_intent_PERMISSION (see the docs for reference). This event will cause the intent to be triggered when the user has granted location permission.
  6. Build a webhook for this new intent that, in its webhook, confirms the permission with isPermissionGranted() and then moves forward with looking up their local course.

Now, the dialog will be as follows:

User: Book a tee time nearby
App:  [from Assistant] Can I access your location?
User: Yes
App:  Thanks, your local course is Pebble Beach and I booked you a tee time.
Daniel Situnayake
  • 2,874
  • 2
  • 30
  • 38