# Installation

## Setup a Google Chat service account

[Service accounts](https://developers.google.com/hangouts/chat/how-tos/service-accounts) are the primary way to interact with Google Cloud resources, and setting up a chatbot is no different.

The first step is to create a new Google Cloud project. Visit <https://console.cloud.google.com/projectcreate> and fill the required fields:

![](https://2862118938-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-M6OZMoZlXP9VSWYMW_T%2F-MOl7ipD4gtS5tObvbRJ%2F-MOlBaf9YscO6XgpOVsx%2Fimage.png?alt=media\&token=00bd8ba9-0c38-4c33-b104-19ae931895af)

Then, [visit this page](https://console.cloud.google.com/marketplace/product/google/chat.googleapis.com) to enable the Google Chat API for this project:

![](https://2862118938-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-M6OZMoZlXP9VSWYMW_T%2F-MOl7ipD4gtS5tObvbRJ%2F-MOlBtpZhhvK4WnWP469%2Fimage.png?alt=media\&token=d05782f6-2242-460f-a3e9-b9428b7d63b0)

Then, go to Identity > Service Accounts in the menu (or visit <https://console.cloud.google.com/identity/serviceaccounts>) and create a service account for the project.

![](https://2862118938-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-M6OZMoZlXP9VSWYMW_T%2F-MOl7ipD4gtS5tObvbRJ%2F-MOlCde0GJsixxFNyKoo%2Fimage.png?alt=media\&token=15dbb067-1b8a-4d69-bed3-fee0bbc73c3d)

In the next screen, grant the **Project > Editor** role to the service account:

![](https://2862118938-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-M6OZMoZlXP9VSWYMW_T%2F-MOl7ipD4gtS5tObvbRJ%2F-MOlCl6iBIm4PFWDQydr%2Fimage.png?alt=media\&token=c28d39d5-7ef2-4dba-8afb-04fde83f61ad)

The third step (*Grant users access to this service account*) is optional and can be skipped. Click on Done to create the service account.&#x20;

Once the service account is created, you will need to generate a key. Select the service account, click on **Add Key > Create New Key**, select **JSON** as the Key type, and save the file.

## Setup the channel in CSML Studio

In CSML Studio, under **Channels > Connect a new channel**, select the Google Chat channel. In the next screen, give your channel a name, a description and upload your service account credentials.

![](https://2862118938-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-M6OZMoZlXP9VSWYMW_T%2F-MOl7ipD4gtS5tObvbRJ%2F-MOlcu3Dr6_lXn8brBR2%2Fimage.png?alt=media\&token=22368b5d-d0e0-4200-9b38-a3777cf3d962)

In the next screen, you can configure the bot's Welcome Flow, and copy the **Chatbot Endpoint URL**, which we will use in the next step.

## Connect the chatbot with Google Chat

To finalize the configuration, visit <https://console.developers.google.com/apis/api/chat.googleapis.com/hangouts-chat> (make sure that the selected project is still the same one as before) and fill the information as requested.

![](https://2862118938-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-M6OZMoZlXP9VSWYMW_T%2F-MOl7ipD4gtS5tObvbRJ%2F-MOle6I9UTNOdfN5KePo%2Fimage.png?alt=media\&token=30bcb37e-16d7-4054-8166-7aee288c0d57)

You can select **Bot works in direct messages** or **Bot works in rooms...** depending on the experience you want to give to users.

Under **Bot URL**, paste the **Chatbot Endpoint URL** from the previous step.

Click **Save**, and you are all set!

## Finding the bot in Google Chat

To find your bot in Google Chat, users have to navigate to the Bot catalog, which can be reached either by clicking the + icon next to the bot section of the left sidebar, or by searching for the name of the bot directly:

![](https://2862118938-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-M6OZMoZlXP9VSWYMW_T%2F-MOleGADGm87V_sxo6pC%2F-MOlpYr3fYgJahxue1XY%2Fimage.png?alt=media\&token=ba9ebaa6-e3d8-4bb1-8223-23a2e6fc242e)

Upon activating the bot for the first time, the Welcome Message will be displayed:

![](https://2862118938-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-M6OZMoZlXP9VSWYMW_T%2F-MOleGADGm87V_sxo6pC%2F-MOlpow9TiGy9x1Usd-N%2Fimage.png?alt=media\&token=15d5e0e6-9020-46cc-b395-4493745a593f)
