Google Chat lets you format text. So you can either use regular text or formatted text:
Google Chat does not have a typing indicator. Typings are simply interpreted as delays.
Google Chat unfurls URLs and displays a preview of the content of the page. For instance:
Google does not provide a way to display an audio player or to upload a file from the bot. These components will be rendered as simple Urls.
In some cases, Google Chat will be able to automatically display a video player in the conversation. This is obviously the case with Youtube videos, but it also works with some other players.
In other cases, you can add some optional parameters to the video to wrap it and render it better:
title
- the title that will appear on the video card
thumbnail_url
- the url to the thumbnail image
button
- the clickable button to open the video
There is no concept of Carousel
in Google Chat, but cards can be stacked vertically. When using a Carousel component, this is the end result:
You can send any valid message as per Google Chat's API reference as a raw object:
This example renders a raw image:
In the Google Chat configuration panel, you can setup slash commands for your bot. These are nice ways to force trigger a CSML flow.
To setup a slash command, you need to create the command like so:
Then, in the AI Rules panel in CSML Studio, add a rule for this command triggering a specific flow:
When the command is used, the specified flow will be triggered with the following payload:
A sample _metadata
for an incoming event will be similar to the following object:
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:
Then, visit this page to enable the Google Chat API for this project:
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.
In the next screen, grant the Project > Editor role to the service account:
The third step (Grant users access to this service account) is optional and can be skipped. Click on Done to create the service account.
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.
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.
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.
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.
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!
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:
Upon activating the bot for the first time, the Welcome Message will be displayed: