Actions on Google is a powerful platform that allows developers to create conversational experiences for various devices, including Google Assistant. One of the features provided by Actions on Google is the ability to open specific features or functionalities within a mobile app using the actions.intent.OPEN_APP_FEATURE action. This action enables users to seamlessly transition from a conversation with the Google Assistant to a specific screen or task within a mobile app.
However, a common question that arises is whether it is possible to use actions.intent.OPEN_APP_FEATURE with dynamic values. In other words, can we pass dynamic parameters or variables to the action in order to open different app features based on user input or context?
The short answer is yes, it is possible to use actions.intent.OPEN_APP_FEATURE with dynamic values. The platform provides a mechanism called App Actions that allows developers to define deep links within their app, which can be triggered by the Google Assistant using the actions.intent.OPEN_APP_FEATURE action. These deep links can include dynamic parameters that can be used to open specific app features based on user input or context.
Let's take a closer look at how this can be achieved. Firstly, developers need to define the deep links within their app's manifest file. These deep links should include placeholders for the dynamic values that will be passed from the Google Assistant. For example, if we want to open a specific product details screen within an e-commerce app, we can define a deep link like this:
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data
android:scheme="https"
android:host="example.com"
android:pathPrefix="/products"
/>
</intent-filter>
In the above example, the deep link is defined with the scheme "https", the host "example.com", and the path prefix "/products". The path prefix can include placeholders for dynamic values, such as the product ID or name.
Once the deep links are defined, developers can configure their Action Package on the Actions Console to include the actions.intent.OPEN_APP_FEATURE action with the necessary parameters. These parameters can be passed as part of the appFeature object in the actions.intent.OPEN_APP_FEATURE action.
{
"actions": [
{
"description": "Open product details",
"name": "actions.intent.OPEN_APP_FEATURE",
"fulfillment": {
"conversationName": "actions.intent.OPEN_APP_FEATURE"
},
"intent": {
"name": "actions.intent.OPEN_APP_FEATURE",
"parameters": {
"appFeature": {
"required": true,
"type": "SchemaOrg_Text"
},
"productId": {
"required": true,
"type": "SchemaOrg_Text"
}
}
}
}
]
}
In the above example, we define an action with the name "actions.intent.OPEN_APP_FEATURE" and specify the required parameters "appFeature" and "productId". The "appFeature" parameter is of type "SchemaOrg_Text" and represents the specific feature or screen within the app that we want to open. The "productId" parameter is also of type "SchemaOrg_Text" and represents the dynamic value that will be passed from the Google Assistant.
When the user interacts with the Google Assistant and triggers the actions.intent.OPEN_APP_FEATURE action, the platform will send a deep link request to the app with the specified parameters. The app can then handle the deep link request and open the appropriate feature or screen based on the dynamic values received.
It is important to note that the deep links and the corresponding app features should be properly implemented within the app itself. The app should handle the deep link requests and navigate to the appropriate screens or tasks based on the dynamic values received. This requires proper handling of the deep links and integration with the app's navigation and feature logic.
In conclusion, it is indeed possible to use actions.intent.OPEN_APP_FEATURE with dynamic values. By defining deep links within the app and configuring the necessary parameters in the Actions Console, developers can enable the Google Assistant to seamlessly open specific app features based on user input or context. This provides a more integrated and personalized experience for users, allowing them to effortlessly transition from a conversation with the Google Assistant to a specific task within a mobile app.
References
| Reference | Link |
|---|---|
| Actions on Google Documentation | https://developers.google.com/assistant |
| Android Deep Linking Documentation | https://developer.android.com/training/app-links/deep-linking |