Google Assistant (Conversational)

Integration published by Jovo | 4,030 downloads

Build Conversational Actions for Google's Assistant platform

Google Transactions

Learn how to sell digital and physical goods in your Google Actions by using Google Transactions.

Introduction

Official Google Docs: Transactions

Transactions for Google Conversational Actions allow you to sell both digital and physical goods in your app. The Jovo implementation of Google Transactions can be accessed like this:

The two types (digital and physical goods) differ in functionality and configuration, this is why they are addressed as distinct features in this document.

Learn more below:

Digital Goods

Official Google Docs: Build digital transactions.

Digital transactions allow you to sell in-app products in the Google Play store.

Digital Goods Configuration

Learn more about the prerequisites in the official Google Docs.

Here are some of the steps that need to be taken:

Prepare your Conversational Action

To use transactions in your action, you'll need to enable the Transactions API. Go to your Actions Console and open your project. Head to Deploy and go to Directory information. Under Additional information, enable transactions for physical goods.

Next, you need to create a Service Account to send requests to the Transactions API with. Copy your Action's Project ID and paste it into the following link: https://console.developers.google.com/apis/credentials?project=. If you then follow that link, you can create your Service Account with respective credentials.

After you gave your service account an appropriate name, choose the Role Project > Owner, to give your account all necessary permissions. When you're done, go to the Service Account details and add a new key certificate in JSON format, which you can then download and store in your project's directory.

The last step of configuring your Conversational Action includes associating your verified web domain and your Android app with your project. For that, return to your Actions Console, head to Deploy and go to Brand verification. Here, you first need to connect your web domain. Google will send you further instructions to the domain's associated email address. Once completed, it should appear as connected. Now, you should be able to connect your app. Follow the instructions shown. Again, Google will send a verification email to your associated email address. Once you're done, your app should show up in the list of connected apps. Enable Access Play purchases, and you can begin configuring your Jovo app.

Configuring your Jovo app

To use transactions for digital goods with the Jovo Framework, you need to install the googleapis npm package. If you use one of our [Transaction Examples](), you can skip this step.

Next, in your src/app.js, add the Android App package name you created earlier and the service account credentials to your Google Assistant configuration:

Digital Goods Implementation

To implement the transaction of digital goods in your Jovo project, there are a few things you need to do (in line with the transaction flow described in the Google docs):

Gather Information

Before the user can make a purchase, it is recommended to check if the user is eligible to make purchases and what products are available.

Check for eligibility

To validate a user's ability to purchase products from your Conversational Action, you can use a DigitalPurchaseCheck [scene](), which checks, whether the user is verified, their device is eligible for transactions and that they are located in a supported region.

In your handler, it's sufficient to just transition to the scene:

Once your user completes the conversational flow of this scene, control will be given to your handler again, where you can check for the result:

Check for available products

Once you can verify that the user can purchase your goods, you need to create an inventory array of your products to present to the user:

Here, this.$googleAction.$transaction.getSkus() will be used to get an array of SKUs for the specified product IDs and the specified SKU type. There are two types of digital goods that can be sold:

  • SKU_TYPE_IN_APP: One-time in-app purchases
  • SKU_TYPE_SUBSCRIPTION: Automatically charge users on a recurring schedule

Build the Order

This part of the flow prompts the user to select an item. You can either choose to follow the example, or use rich responses to display your products in a [list](), for example.

Learn more in the official docs by Google how to create a rich response that describes the available items to the user.

Complete Purchase

Once you built your order and your user has selected an item, you can complete the purchase:

After calling this.$googleAction.$transaction.completePurchase() with the selected product, we use [scenes]() again to delegate the conversation flow to the Conversational Action.

Once the user completed the purchase, control will be given to your handler again, where you can check for the purchase result:

The following purchase status can be returned:

  • PURCHASE_STATUS_OK
  • PURCHASE_STATUS_ITEM_CHANGE_REQUESTED
  • PURCHASE_STATUS_USER_CANCELLED
  • PURCHASE_STATUS_ERROR
  • PURCHASE_STATUS_UNSPECIFIED

Physical Goods

Official Google Docs: Build physical transactions.

Physical transactions allow you to sell physical items (e.g. books, clothes) in your Google Action. You can choose whether you want to use Google Pay or your own custom payment method for purchases. The transaction flow is mostly the same, apart from a few configurations such as the payment parameters.

Learn more about configurations for Google Pay in the official Google Docs.

Learn more about configurations for merchant-managed payments in the official Google Docs.

Physical Goods Configuration

Prepare your Conversational Action

TODO sufficient to link to digital goods here?

To use transactions in your action, you'll need to enable the Digital Purchase API. Go to your Actions Console and open your project. Head to Deploy and go to Directory information. Under Additional information, enable transactions for digital goods.

Next, you need to create a Service Account to send requests to the Digital Goods API with. Copy your Action's Project ID and paste it into the following link: https://console.developers.google.com/apis/credentials?project=. If you then follow that link, you can create your Service Account with respective credentials.

After you gave your service account an appropriate name, choose the Role Project > Owner, to give your account all necessary permissions. When you're done, go to the Service Account details and add a new key certificate in JSON format, which you can then download and store in your project's directory.

Create credentials for your service account

Configuring your Jovo app

To use transactions for physical goods with the Jovo Framework, you need to install the googleapis npm package. If you use one of our [Transaction Examples](), you can skip this step.

Physical Goods Implementation

To implement the transaction of physical goods in your Jovo project, there are a few things you need to do (in line with the transaction flow described in the Google docs):

If you use your own payment method for purchases, it is recommended to link their Google account with their account on your service. If you want to use Google Pay, you can skip this step.

Learn more about Account Linking with Conversational Actions [here]().

Gather Information

Before the user can perform a transaction, it is recommended to check if the user meets all transaction requirements. You can also try to request a delivery address, if you want.

Check for eligibility

To validate a user's ability to perform transactions from your Conversational Action, you can use a TransactionRequirementsCheck [scene](), which checks, whether the user is verified, their device is eligible for transactions and that they are located in a supported region.

In your handler, it's sufficient to just transition to the scene:

Once your user completes the conversational flow of this scene, control will be given to your handler again, where you can check for the result:

Request a delivery address

If your transaction depends on the user's delivery address, you can use the TransactionDeliveryAddress [scene]() to request it:

Before delegating the conversation to TransactionDeliveryAddress, you can also choose to provide a reason, which will be prompted to the user. If you do not provide a parameter to askForDeliveryAddress(), the default reason "to know where to send the order" will be used.

Once your user completes the conversational flow of this scene, control will be given to your handler again, where you can check for the result:

Build the order

Now that you gathered all the information that you need, you can start building your order. In the [Jovo example](), you can find a preconfigured order object inside src/order.ts. You can import this order object into your app.ts and adjust it based on your gathered information:

Learn more about the order object here.

Depending on whether you choose to use Google Pay or your own pament method, you need to adjust the payment parameters.

Learn more about payment parameters for Google Pay in the official Google Docs.

Learn more about payment parameters for merchant-managed payments in the official Google Docs.

Propose the order

Now that you've built your order, it's time to present it to your user using the TransactionDecision [scene]().

In your handler, it's sufficient to just transition to the scene:

Handle the transaction result

Your Action presents the order to the user in the format of a "cart preview card". Once the user responded to the order, you can use one of the following functions to check for the result:

If the transaction has succeeded, you must initiate the required steps to confirm the order, such as charging the user and providing an order update:

Example Javascript | Example Typescript

Google Assistant Changelog

Current version might be higher than the latest changes displayed below because of updates of dependencies.

2022-03-02 [3.6.4]
2022-02-17 [3.6.3]
2021-07-07 [3.5.4]
  • #948 ✨ Add enableFullScreen and continueTtsDuringTouch (@aswetlow)

2021-02-22 [3.5]

  • #901 Move setResponse from response to after.response middleware (@aswetlow)
  • #901 Fix missing unit test methods in ConversationalResponse (@aswetlow)
2021-02-04 [3.4.0]
  • #892 ✨ Transactions for Google Assistant Conversational Actions (@aswetlow)
2021-01-28 [3.3.2]
  • #890 ✨ Add Conversational Actions functionality to Jovo Debugger (@aswetlow)
2020-12-03 [3.3.0]
  • #871 Add missing and broken Google Conversational Action features (@aswetlow)
2020-11-20 [3.2.4]
2020-11-16 [3.2.3]
  • Adds Interactive Canvas to Google Conversational Actions (@aswetlow)
2020-11-10 [3.2.2]
  • #856 Fixes several Google Conversational Actions issues (@aswetlow)
2020-11-05 [3.2.1]

Fix missing locale in push notifications object

2020-09-29 [3.1.3]
  • #831 :recycle: Enhance Google AssisConversational Actions (@maswetlow)

2020-09-29 [3.1.0-alpha.0]

  • #829 ✨ Work In Progress: Google Assistant Conversational Actions (@aswetlow)

Join Our Newsletter

Be the first to get our free tutorials, courses, and other resources for voice app developers.