How to add a URL parameter to {@url} for actions.intent.OPEN_APP_FEATURE?

234 views Asked by At

Google's official document says actions.intent.OPEN_APP_FEATURE supports only urlTemplate set to "{@url}" with no fallback fulfillment.

The following is their sample code for actions.xml:

  <?xml version="1.0" encoding="utf-8"?>
  <!-- This is a sample actions.xml -->
  <actions>
    <action intentName="actions.intent.OPEN_APP_FEATURE">
      <!-- Use url from inventory match for deep link fulfillment -->
      <fulfillment urlTemplate="{@url}" />


      <!-- Define parameters with inventories here -->
      <parameter name="feature">
        <entity-set-reference entitySetId="featureParamEntitySet"/>
      </parameter>
    </action>

    <entity-set entitySetId="featureParamEntitySet">
      <!-- Provide a URL per entity -->
      <entity url="myapp://deeplink/one" name="featureParam_one" alternateName="@array/featureParam_one_synonyms"/>
      <entity url="myapp://deeplink/two" name="featureParam_two" alternateName="@array/featureParam_two_synonyms"/>
    </entity-set>
  </actions>

It means that I can say "Open featureParam_two from myapp" to start the app with deep link "myapp://deeplink/two".

If the app has user-defined names such as "front door", "first bathroom", how can those names be passed to the app to allow users to say "open front door from myapp" or "open first bathroom from myapp" to open the app and the corresponding feature?

1

There are 1 answers

4
Diego On

You can use alternate names/synonyms to define those features.

For example, you can use the following definition:

<entity-set entitySetId="featureParamEntitySet">
      <!-- Provide a URL per entity -->
      <entity url="myapp://deeplink/front-door" name="front door" alternateName="@array/front-door-synonyms"/>
      <entity url="myapp://deeplink/two" name="first bathrooms" alternateName="@array/first-bathroom-synonyms"/>
</entity-set>