Integrating Tokopedia App with Google Assistant

Firmanda Nugroho
Jul 13 · 4 min read
Image for post
Image for post

Tokopedia always cares about our users. We want to give the best experience when users using our app. There is a lot of things that we can use. But now we are providing you the fastest way to access our feature in Tokopedia using Google Assistant.

In Tokopedia we have some problems that require a lot of steps to check out some products. For example, we have feature Top Up and Bills that need to open the Tokopedia app, input some client numbers, and checkout. Action and Slice can solve this problem for us. With this, users who want fast transaction can use feature Top Up and Bills with Google Assistant.

Slice

We must use Slice if we want to show our data in Google Assistant. Slice is using as a Boilerplate to build our Slice. For example, let us see our .

Code 1.1 MainSliceProvider.kt

Like you see above in , we are using as our Main method to show our Slice in Google Assistant. If you notice, we use to determine which Slice that we want to show.

Then we must register our provider to your Please make sure your on the right path.

Code 1.2 AndroidManifest.xml

Actions

Action has two types, Slice and Deeplink. You can use one of them or both of them. What are the differences between both of them?

Table 2.1 Differences between Slice and Deeplink in Actions.

Action with Slice

If you want to see the difference between both of them in the implemented feature, this is when we use Slice. There you can see that we show our Recharge Bill in Slice.

Code 2.1 actions.xml with Slice.
Image for post
Image for post
Video 2.1 Action with Slice

Action with Deeplink

Action with Deeplink is when we use Actions Deeplink. When you say “Get Tokopedia Bill” in Google Assistant, you will be redirected to Recharge Home of Tokopedia.

Code 2.2 actions.xml with deeplink.
Image for post
Image for post
Video 2.2 Actions with Deeplink

Then we need to make and embed it to our .

Code 2.3 actions.xml in AndroidManifest.xml

Build-in Intents

Build-in Intents is the way our app to express its to Google. If you want to your be recognize by Google Assistant, you must register your to your actions.xml. Build-in Intent is grouped and categorized per unique feature. For example we use GET_INVOICE to show our Recharge Bill in Tokopedia. For a list of built-in intents, they support for deep linking into your app or launching your custom slices, see Implement built-in intents for App Actions.

Build-in Intent has a parameter that we can use as a unique value used in our feature. For example we can use queries like “My Bill Electricity in Tokopedia.” The unique value here is “Electricity” and used as .

Code 2.4 actions.xml with parameter

Testing

If you want to test your Actions, you need to use the plugin App Action Test Tool. This Test Tool is listing your actions.xml and trigger your Google Assistant what intentName you choose. Please login to your Google Account, which has access to your playConsole to your Android Studio.

Image for post
Image for post
Figure 3.1 App Action Test Tool

Future Development

After knowing what Action and Slice are, you must understand that the category in Build-in-Intent is limited. In the food and drink category, for example, you only can use order menu item. For Transportation, you can only use create order taxi, cancel order taxi, and get order taxi. But what is the future Development in Tokopedia is possible to use? We can use pay invoice, get our order, and open feature. With this, we hope our user will have a better experience using Tokopedia App.

Tips

  • Language in Action and Slice is something vital that we must know it is limited per Build-in-Intent. Some build intent has their list usable language keyword. For example, in Get Invoice, you can only use English, Spain, and Brazilian-Portuguese. Please pay attention to the language too.
  • When you upload to the Play Store, and you are using proguard, please take notice that your proguard will remove your actions.xml. For avoid that, you can whitelist your actions.xml in your keep.xml so that your proguard does not remove your actions.xml

Conclusion

  1. Slice is a UI framework that we can use in our Assistant, to show our UI that we needed.
  2. Action is used to Provide a shortcut to your app as users talk to the Google Assistant.
  3. Action has two types, Slice and Deeplink. Slice will show UI in the Assistant. Deeplink will redirect you to your Activity.
  4. Testing Action using the account that can access playConsole, use your account in Android Studio and your Device.

Tokopedia Engineering

Story from people who build Tokopedia

Medium is an open platform where 170 million readers come to find insightful and dynamic thinking. Here, expert and undiscovered voices alike dive into the heart of any topic and bring new ideas to the surface. Learn more

Follow the writers, publications, and topics that matter to you, and you’ll see them on your homepage and in your inbox. Explore

If you have a story to tell, knowledge to share, or a perspective to offer — welcome home. It’s easy and free to post your thinking on any topic. Write on Medium

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store