In a previous article, we saw how we can integrate a Rasa chatbot with Twilio messaging channel. In this article, I will show you how to integrate the chatbot with another messaging channel – Google Chat.
Google Chat (previously called Google Hangouts Chat) is Google's paid team chat service, provided only as part of Google Workspace. This means regular Google account is not enough, you have to be inside a Google Workspace.
Furthermore, in order to add a chatbot to Google Chat, you have to be an admin of that workspace.
First, let's create a new workspace. To be able to create a new Google Workspace, you need to own a domain. You either already have one or you can purchase it.
Go to https://workspace.google.com/ and click Get started. Fill in the business name, number of employees, country and your contact info (follow the Google Workspace setup wizard).
Enter your domain name (e.g.
petrjanik.com, but it must be yours). Complete the rest of the setup wizard.
Next, sign in to the newly created account. You will be prompted to select a payment plan. Google Workspace is a paid service, but it offers 14 days free trial, which will be enough for this experimental Rasa integration. Click Next. You will now need to fill in your address and payment method and details. You won't be billed until the 14 days free period ends. You can delete the account before the first payment.
You will be taken to the Admin console.
You will see a prompt to verify the domain you have entered earlier. You have to verify it in order to proceed with the setup. If you don't see the prompt, click Home -> Domains -> Manage domains. Click Verify domain. Follow the verification process till the end.
After the domain is verified, go to the Google Cloud Platform Console. We will create a new project and enable the Google Chat API.
Click Select a project -> NEW PROJECT.
Fill in the project name, organization and location. Click CREATE. Wait until it is created.
Select that project.
Search for "APIs & Services" and go there.
+ ENABLE APIS AND SERVICES.
Search for "Google Chat API". Open the Google Chat API search result and click ENABLE.
On the Hangouts Chat API page, go to the Configuration.
Enter the name of the chatbot, avatar URL and a description. You can select whether the chatbot works in direct messages or in rooms and direct messages with multiple users.
In the Connection settings section, select Bot URL. The URL have the form of
https://<host>:<port>/webhooks/hangouts/webhook. The protocol must be
port with the host and port of your running rasa server. You can expose locally running rasa server using ngrok. Please refer to the previous article to find out how to use ngrok.
To make this channel endpoint available for Google Chat, all you need to do is to add the following to
credentials.yml in your Rasa chatbot project.
# credentials.yml hangouts: # no credentials required here
Run the rasa server:
In a new terminal window, run the actions server:
rasa run actions.
In a new terminal window, run ngrok:
ngrok http 5005.
Ngrok is listening on port 5005 since this is where the rasa server is running.
Copy the https version of the tunnel URL that was generated by ngrok and paste it into the Bot URL input followed by
Lastly, choose who in your domain can install this chatbot.
Go to the Google Chat application.
Click on Start a chat and search for your chatbot.
You can see that Google Chat nicely displays rich responses as cards.
To learn more about Google Hangouts Chat channel connector, visit the Rasa documentation.
Repository for this tutorial:
You can checkout the state of the repository at the end of this tutorial by running:
git clone --branch 21-google-chat-integration email@example.com:petr7555/rasa-dev-tutorial.git