Google's Business Messages

Build conversational experiences and chatbots right into your business location on Google Maps and Google Search with this Business Messages platform integration for Jovo.

Introduction

Google's Business Messages allows you to build chatbots and conversational experiences that can be connected to many Google channels, including Maps and Search. You can find the official documentation here.

Learn more about getting started in the installation and configuration sections. You can also find a sample app here.

Installation

If you want to create a new Google Business messages project with Jovo, we recommend installing the Jovo CLI, creating a new Jovo project, and selecting Google Business Messages as platform using the CLI wizard. Learn more in our getting started guide.

# Install Jovo CLI globally
$ npm install -g @jovotech/cli

# Start new project wizard
# In the platform step, use the space key to select Google Business Messages
$ jovo new <directory>

If you want to add Google Business Messages to an existing Jovo project, you can install the plugin like this:

$ npm install @jovotech/platform-googlebusiness

Add it as plugin to your app configuration. Google Business Messages requires at least a serviceAccount (learn more in the configuration section below) and we also recommend adding an NLU integration like NLP.js:

import { App } from '@jovotech/framework';
import { GoogleBusinessPlatform } from '@jovotech/platform-googlebusiness';
import { NlpjsNlu } from '@jovotech/nlu-nlpjs';
import { LangEn } from '@nlpjs/lang-en';
import serviceAccount from './service-account.json';
// ...

const app = new App({
  plugins: [
    new GoogleBusinessPlatform({
      serviceAccount, // Used to authenticate with the GBM platform
      plugins: [
        new NlpjsNlu({
          languageMap: {
            en: LangEn,
          },
        }),
      ],
    }),
    // ...
  ],
});

Configuration

You can configure the Google Business platform in the app configuration, for example app.ts:

import { GoogleBusinessPlatform } from '@jovotech/platform-googlebusiness';
import serviceAccount from './service-account.json';
// ...

const app = new App({
  plugins: [
    new GoogleBusinessPlatform({
      serviceAccount,
      plugins: [
        /* ... */
      ],
      session: {
        /* ... */
      },
    }),
    // ...
  ],
});

Options include:

NLU Integration

Google Business requests mostly consist of raw text that need to be turned into structured data using an natural language understanding (NLU) integration.

Here is an example how you can add an NLU integration (in this case NLP.js) to the app configuration in app.ts:

import { GoogleBusinessPlatform } from '@jovotech/platform-googlebusiness';
import { NlpjsNlu } from '@jovotech/nlu-nlpjs';
import { LangEn } from '@nlpjs/lang-en';
// ...

const app = new App({
  plugins: [
    new GoogleBusinessPlatform({
      plugins: [
        new NlpjsNlu({
          languageMap: {
            en: LangEn,
          },
        }),
      ],
    }),
    // ...
  ],
});

Session Data

Google Business does not offer session storage, which is needed for features like session data, component data, and the $state stack.

To make Google Business bots work with these features, Jovo automatically enables the storage of session data to the active database integration. Under the hood, it adds session to the storedElements config.

Since Google Business does not have the concept of sessions, we need to define after which time a request should be seen as the start of the new session. The default is 15 minutes and can be modified either in the storedElements config (works across platforms) or in the Google Business config:

new GoogleBusinessPlatform({
  // ...
  session: {
    expiresAfterSeconds: 900,
  },
});

Platform-Specific Features

You can access the Google Business specific object like this:

this.$googleBusiness;

You can also use this object to see if the request is coming from Google Business (or a different platform):

if (this.$googleBusiness) {
  // ...
}

Output

There are various Google Business specific elements that can be added to the output.

For output that is only used for Google Business, you can add the following to the output object:

{
  // ...
  platforms: {
    googleBusiness: {
      // ...
    }
  }
}

You can add response objects that should show up exactly like this in the Google Business response object using the nativeResponse object:

{
  // ...
  platforms: {
    googleBusiness: {
      nativeResponse: {
        // ...
      }
      // ...
    }
  }
}