Google Business Messages Platform Integration

The Google Business Messages platform integration allows you to build custom Google Business bots using Jovo.

Getting Started

You can install the plugin like this:

$ npm install @jovotech/platform-googlebusiness

Add it as plugin to your app configuration, e.g. app.ts:

import { App } from '@jovotech/framework';
import { GoogleBusinessPlatform } from '@jovotech/platform-googlebusiness';
// ...

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

Configuration

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

import { GoogleBusinessPlatform } from '@jovotech/platform-googlebusiness';

// ...

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

Options include:

  • plugins: For example, you need to ddd an NLU integration here.
  • session: Session specific config. Take a look at session data for more information.

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';

// ...

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

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: {
        // ...
      }
      // ...
    }
  }
}