Options
All
  • Public
  • Public/Protected
  • All
Menu

Class Permission

Asks the Assistant to guide the user to grant a permission. For example, if you want your app to get access to the user's name, you would invoke conv.ask(new Permission) with the context containing the reason for the request, and the GoogleActionsV2PermissionValueSpecPermissions permission. With this, the Assistant will ask the user, in your agent's voice, the following: '[Context with reason for the request], I'll just need to get your name from Google, is that OK?'.

Once the user accepts or denies the request, the Assistant will fire another intent: actions.intent.PERMISSION with a boolean argument: PERMISSION and, if granted, the information that you requested.

Notes for multiple permissions:

  • The order in which you specify the permission prompts does not matter - it is controlled by the Assistant to provide a consistent user experience.
  • The user will be able to either accept all permissions at once, or none. If you wish to allow them to selectively accept one or other, make several dialog turns asking for each permission independently with conv.ask(new Permission).
  • Asking for DEVICE_COARSE_LOCATION and DEVICE_PRECISE_LOCATION at once is equivalent to just asking for DEVICE_PRECISE_LOCATION
example

// Actions SDK
const app = actionssdk()

app.intent('actions.intent.MAIN', conv => {
  conv.ask(new Permission({
    context: 'To read your mind',
    permissions: 'NAME',
  }))
})

app.intent('actions.intent.PERMISSION', (conv, input, granted) => {
  // granted: inferred first (and only) argument value, boolean true if granted, false if not
  const explicit = conv.arguments.get('PERMISSION') // also retrievable w/ explicit arguments.get
  const name = conv.user.name
})

// Dialogflow
const app = dialogflow()

app.intent('Default Welcome Intent', conv => {
  conv.ask(new Permission({
    context: 'To read your mind',
    permissions: 'NAME',
  }))
})

// Create a Dialogflow intent with the `actions_intent_PERMISSION` event
app.intent('Get Permission', (conv, params, granted) => {
  // granted: inferred first (and only) argument value, boolean true if granted, false if not
  const explicit = conv.arguments.get('PERMISSION') // also retrievable w/ explicit arguments.get
  const name = conv.user.name
})

Read more:

  • Supported Permissions
  • Check if the permission has been granted with conv.arguments.get('PERMISSION')
  • {@link Device#location|conv.device.location}
  • {@link User#name|conv.user.name}
  • conv.ask(new Place) which also can ask for Location permission to get a place

Once the user accepts or denies the request, the Assistant will fire another intent: actions.intent.PERMISSION with a boolean argument: PERMISSION and, if granted, the information that you requested.

Notes for multiple permissions:

  • The order in which you specify the permission prompts does not matter - it is controlled by the Assistant to provide a consistent user experience.
  • The user will be able to either accept all permissions at once, or none. If you wish to allow them to selectively accept one or other, make several dialog turns asking for each permission independently with conv.ask(new Permission).
  • Asking for DEVICE_COARSE_LOCATION and DEVICE_PRECISE_LOCATION at once is equivalent to just asking for DEVICE_PRECISE_LOCATION
example

// Actions SDK
const app = actionssdk()

app.intent('actions.intent.MAIN', conv => {
  conv.ask(new Permission({
    context: 'To read your mind',
    permissions: 'NAME',
  }))
})

app.intent('actions.intent.PERMISSION', (conv, input, granted) => {
  // granted: inferred first (and only) argument value, boolean true if granted, false if not
  const explicit = conv.arguments.get('PERMISSION') // also retrievable w/ explicit arguments.get
  const name = conv.user.name
})

// Dialogflow
const app = dialogflow()

app.intent('Default Welcome Intent', conv => {
  conv.ask(new Permission({
    context: 'To read your mind',
    permissions: 'NAME',
  }))
})

// Create a Dialogflow intent with the `actions_intent_PERMISSION` event
app.intent('Get Permission', (conv, params, granted) => {
  // granted: inferred first (and only) argument value, boolean true if granted, false if not
  const explicit = conv.arguments.get('PERMISSION') // also retrievable w/ explicit arguments.get
  const name = conv.user.name
})

Read more:

  • Supported Permissions
  • Check if the permission has been granted with conv.arguments.get('PERMISSION')
  • {@link Device#location|conv.device.location}
  • {@link User#name|conv.user.name}
  • conv.ask(new Place) which also can ask for Location permission to get a place
example

// Actions SDK
const app = actionssdk()

app.intent('actions.intent.MAIN', conv => {
  conv.ask(new Permission({
    context: 'To read your mind',
    permissions: 'NAME',
  }))
})

app.intent('actions.intent.PERMISSION', (conv, input, granted) => {
  // granted: inferred first (and only) argument value, boolean true if granted, false if not
  const explicit = conv.arguments.get('PERMISSION') // also retrievable w/ explicit arguments.get
  const name = conv.user.name
})

// Dialogflow
const app = dialogflow()

app.intent('Default Welcome Intent', conv => {
  conv.ask(new Permission({
    context: 'To read your mind',
    permissions: 'NAME',
  }))
})

// Create a Dialogflow intent with the `actions_intent_PERMISSION` event
app.intent('Get Permission', (conv, params, granted) => {
  // granted: inferred first (and only) argument value, boolean true if granted, false if not
  const explicit = conv.arguments.get('PERMISSION') // also retrievable w/ explicit arguments.get
  const name = conv.user.name
})

Read more:

  • Supported Permissions
  • Check if the permission has been granted with conv.arguments.get('PERMISSION')
  • {@link Device#location|conv.device.location}
  • {@link User#name|conv.user.name}
  • conv.ask(new Place) which also can ask for Location permission to get a place

Hierarchy

Constructors

constructor

Properties

Optional inputValueData

inputValueData: ApiClientObjectMap<any>

Additional configuration data required by a built-in intent. Possible values for the built-in intents: actions.intent.OPTION -> [google.actions.v2.OptionValueSpec], actions.intent.CONFIRMATION -> [google.actions.v2.ConfirmationValueSpec], actions.intent.TRANSACTION_REQUIREMENTS_CHECK -> [google.actions.v2.TransactionRequirementsCheckSpec], actions.intent.DELIVERY_ADDRESS -> [google.actions.v2.DeliveryAddressValueSpec], actions.intent.TRANSACTION_DECISION -> [google.actions.v2.TransactionDecisionValueSpec], actions.intent.PLACE -> [google.actions.v2.PlaceValueSpec], actions.intent.Link -> [google.actions.v2.LinkValueSpec]

Optional intent

intent: undefined | string

The built-in intent name, e.g. actions.intent.TEXT, or intents defined in the action package. If the intent specified is not a built-in intent, it is only used for speech biasing and the input provided by the Google Assistant will be the actions.intent.TEXT intent.

Optional parameterName

parameterName: undefined | string

Optionally, a parameter of the intent that is being requested. Only valid for requested intents. Used for speech biasing.

Generated using TypeDoc