# Google Business Messaging

Business Messages is a mobile conversational channel that combines entry points on Google Maps, Search, and brand websites to create rich, asynchronous messaging experiences that delight customers and drive business results.

Logicdialog allows you to connect your digital assistant to this platform so that as soon as someone searches for your business, they can chat directly to the bot and get the answers they need. This page will help guide you through the integration of the two platforms. &#x20;

<figure><img src="/files/WNL2fQ27PIjKttzADf82" alt=""><figcaption></figcaption></figure>

### Overview

To setup Google Business Messaging (GBM) there are a few steps that you'll need to follow, which are outlined below : &#x20;

* [ ] Register as a Google Business Messaging Partner
* [ ] Create a Service Account
* [ ] Create an Agent
* [ ] Configure the webhook
* [ ] Test and Verify your agent

More detail on each of these steps are given below.&#x20;

### Register as a GBM Partner

In order to use GBM, you first need to register as a partner. By registering as a partner you can create agents for brands and enable messaging experiences for customer services, sales, and other business applications. The registration is a simple process, as follows :&#x20;

1. Open the [Business Communications Partner Console](https://business-communications.cloud.google.com/console/partner-console)
2. Under **Business Messages**, click **Create partner account**.
3. You will then be prompted to complete a few bits of information about your Partner account. Following that, click **Create** to create the account.&#x20;

### Create a Service Account

Once registered as a partner, you'll need to create a **Service Account.** This service account is used to securely authenticate API calls to the Business Messages and Business Communications API&#x73;**.**&#x20;

1. On the [Business Communications Partner Console](https://business-communications.cloud.google.com/?utm_source=/business-communications/business-messages/guides/how-to/register\&utm_medium=devsite\&utm_campaign=business-messages) home page, click **Partner account settings**.&#x20;
2. In the left navigation, click **Service account**.&#x20;
3. Click **Create key**, then click **Create**.

Following these steps will prompt your browser to download the service account key. Store your service account key in a secure, private location. As you need its content for the next steps.&#x20;

### Create an Agent

Now that you are registered as a partner and have a service account, we can proceed to create an **Agent**. An agent is the interface between your customers and you. It'll have a brand, including a name and an avatar, and various other settings.&#x20;

Creating an agent is straight forward and can be done from the partner console.&#x20;

<figure><img src="/files/FS4x971C1flMs6uRi7Wy" alt=""><figcaption></figcaption></figure>

Click on the `Create Agent` link here and follow the resulting dialog windows to create the agent. You can always adjust settings at a later date if needed.&#x20;

On the **Overview** screen, please make sure you copy down the **Agent ID** as you'll need this for steps in the process later on.&#x20;

<figure><img src="/files/asnnlKVTeLC3UVhLuphA" alt=""><figcaption></figcaption></figure>

Also, on the **Agent Information** page (visible in the left menu), please ensure that the `Welcome Message` is set appropriately, and that the `Primary Interaction` is set to `Bot`.

<figure><img src="/files/v0QqoZNmVBbo2G1F7KfE" alt=""><figcaption></figcaption></figure>

Finally, ensure that you have added some **Locations** to your Agent via the menu on the left hand side. These locations are how Google will map a search result to your bot and so it's important you add Locations that you are responsible for, and where you want the bot to reside.&#x20;

<figure><img src="/files/e8sFq7a4vLY8eRYUp09h" alt=""><figcaption></figcaption></figure>

### Configure a webhook

When messages arrive into **GBM** from your users, these need to be forwarded on to the Logicdialog platform so that we can handle them. This is done through a mechanism called a `Webhook`. This is essentially an address that will be sent data.&#x20;

Before configuring this, you'll need to set some credentials on channel settings within Logicdialog. To do this, visit the **LogicDialog** **Channels** page (it's part of **Settings** page) and click **Connect** on the **Google Business Messaging** option :

<figure><img src="/files/4A34fSHQDspFW8Spry8m" alt=""><figcaption></figcaption></figure>

A new window will open with the settings that you need to change in order to configure GBM.&#x20;

<figure><img src="/files/bOf1uHqJ3KAgSxxnmHos" alt=""><figcaption></figcaption></figure>

The **Agent ID** was copied in the steps above when you created an agent, and **Service Account** is downloaded to your computer so you just need to copy its content and paste there.

To set **Client Token** you need to go to the **Integrations** section on the **Agent** page from [Business Communications Partner Console](https://business-communications.cloud.google.com/console/partner-console).&#x20;

<figure><img src="/files/ptSttioblxjriqj2ukFP" alt=""><figcaption></figcaption></figure>

Firstly disable **Helper Bot**, afterwards click *Configure* on the **Webhook** section. It should show a small window like the one below:

<figure><img src="/files/TtbkXY40rAJFr1lGUOnK" alt=""><figcaption></figcaption></figure>

As you can see the client token is hidden so click the rotate arrow and a new token will be shown. Afterwards copy its value and go to **LogicDialog** to paste it at the field of **Client Token** on the **GBM Configuration**, then click submit.

Now to verify the webhook, go to the open window of **Webhook** integration from [Business Communications Partner Console](https://business-communications.cloud.google.com/console/partner-console) and for webhook endpoint put the URL that was shown at GBM Configuration with this format (e.g. if the client is `webuildbots-customer-service):`&#x20;

`https://backend.logicdialog.ai/input/gbm/callback/webuildbots-customer-service`

Afterwards, click **Verify**.

When Business Messages verifies your webhook, the dialogue closes.

### Test and verify your agent

With everything now setup, you can test your solution works as expected. To do this you'll need to send yourself unique URLs that allow you to talk to your bot before it has been verified and published. These URLs are at Agent Test URLs which you'll find at the Agent Information on the **Overview** page of the agent you wish to test - `Android`, `iOS` and `Send`.&#x20;

<figure><img src="/files/JQVk1zGzFsssTkGcZLJ2" alt=""><figcaption></figcaption></figure>

The first two of these will show a QR code you can scan with your mobile's camera to take you to the bot. The `Send` button will email you links, which again will take you directly to the application.&#x20;

Once you have confirmed that the bot is working as you'd expect, you'll need to verify the application. This can be done using the **Verify** menu in the left hand menu.&#x20;

<figure><img src="/files/inGLRx4Scc65CY2F1V9q" alt=""><figcaption></figcaption></figure>

You will need to verify the locations you've added to your agent as well as the general configuration. Once verified you'll then be able to go through the **Launch** process which is again available from the left hand menu.&#x20;


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.logicdialog.ai/integrations/google-business-messaging.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
