How to integrate actions in app

Gaurav Bansal
4 min readMay 23, 2018

--

In the previous article we discussed about What is android actions and how actions work in android platform.Now we will discuss how to implement them in our app.If you haven’t read the previous article yet read it for better understanding of Actions.

App Actions

Core part of actions in android is a new configuration file actions.xml.
An actions.xml will be added in apk that will consist all the intents available inside the app and their fulfilment (corresponding landing screen using deep links).

App actions overview

Intents

Actions consist two parts semantic intent and fulfilment.
Intents used in actions are Semantics intents these are already defined in Actions catalogue (Custom intents can be defined by developer). These intents describe what your action does in a language that google can understand.

Intent catalogue-

Google define rich catalogue of built in intents(schema and grammar).Custom intents can be defined in Action console and DialogFlow.
For each intent a grammar is defined to recognise user queries and parameter.These parameter will be infer from queries and passed into app.
Built in intents are recommended to be use because google will take care of processing user query and map them to actions.We can define custom intents also in Action console but then we have to build our own grammar so user query can be mapped to our actions .

Android intents vs Semantics intents
Semantic intents are different from the android intents.Android intents allow app components or apps to talk to each other.On the other hand Semantic intents are part of a larger catalogue that extends beyond android that includes assistant,google search and other surfaces.

actions.xml works as a bridge between android intents and semantic intents and defines the mapping between the two.
actions.xml defines how a semantic intent inferred from a user’s query can be converted in to a URL then Android intent filter logic convert URL to a Specific android intent.

Why URLs -
URLs are used to connect semantics intent to android intents because-

  • Deep link urls are already part of app discovery ecosystem where we can link app url to web content using verified app links and site maps.
  • Google structured data programs we can precisely define the specific content that our app can support.It also uses URLs.
  • Firebase App indexing can enable google to personalise Action suggestions by action logging.It also use URLs to identify content in your app.

Fulfilment- Connect intent to deeplinks

It describes the specific mechanism to invoke a particular actions in app.It tells google how to determine the specific deep link url to open for a given semantic intent.

Actions.xml use two models to provide fulfilment for a semantic intent.

  • URL template model- in this model we use the parameters of semantic intent to dynamically construct a fulfilment URL at runtime. actions.xml provide URL template with placeholders for specific parameters.This is ideal for Action-centric apps with deep link apis.
Fulfilment in actions
  • Content driven model- in this model fulfilment url is discovered by web content or structured data.User’s query is used to find the relevant content in web presence and then connect the URL of that content to appropriate intent using actions

How actions.xml submitted to Google-
actions.xml is present in the android apk. When we publish app in play console it parses actions.xml and register actions in the Actions on Google database.This registrations allows your app to respond to queries in google apps(Assistant, Search).

How to test actions-
A new plugin App Actions test tool is available in android studio.It will validate actions.xml and submit to Actions on google in preview mode which will be available only to developer account.Then we can check how our app actions works inside assistant or search.

Usage Logging- personalize actions

Firebase App indexing can enable google to personalise Action suggestions based on user context and usage patterns by user action logging.Users can see and control log activity through myactivity.google.com.

Enhance actions- rich UI and dialog

Slices(a new UI framework works on API≥19) can be used to enhance Action representation through rich UI templates.Slices are customizable templates that enable you to create an even richer user experience. With Slices, you can include things like text, images, videos, and interactive controls that allow users to engage with your app right from within the Google Search app and the Google Assistant.
Conversational experience can be built for Google Assistant.

--

--