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.
Who can use 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.
Creating a Google 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.
Creating a Google Cloud project
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.
Click + 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 https
, not http
. Replace host
and 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: rasa run
.
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 /webhooks/hangouts/webhook
.
Lastly, choose who in your domain can install this chatbot.
Click SAVE.
Start a chat with the chatbot
Go to the Google Chat application.
Click on Start a chat and search for your chatbot.
Now you are ready to chat with the 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 git@github.com:petr7555/rasa-dev-tutorial.git
Top comments (8)
Excelent tutorial, Petr!
I've been long struggling to get such detailed instructions on how to integrate Rasa and Google Chat. This article clearly demonstrates how to integrate them.
I linked to your post from my original thread in Rasa's forum about this issue, hope you don't mind it. Greatly appreciated, thanks!
I don't mind it at all. I am very glad to hear that this article helped you.
Thank you so much for this tutorial! I couldn't figure out how to deploy Rasa to google chat. But then @otmarjr helped me with your instructions! Thank you both again!
I have a question. Can we track the conversations between the bot and the user?
You're welcome.
If you want to track conversations of your test users, you could use Rasa X, which is made for this purpose.
If you want to track conversations happening "in production", i.e. someone talking to your chatbot in Google Chat, I guess you could implement custom action to send the answers and responses to some REST endpoint and save them there. However, I do not have any experience with this.
Maybe there are other ways which I am unaware of.
Thank you so much! I will check custom actions and the tracker store. Best!
You are right, Rasa indeed provides nice solution out of the box in the form of tracker stores.
Hello Petr, it's me again!
Just a couple of days after this post I saw you're now a Rasa Hero! Congratulations!
I hope you, as my greatest Rasa Hero, can help me out once again.
This time I'm trying to setup my environment using Rasa-X to develop my chatbot and I installed it using the docker-compose, just as described in
rasa.com/docs/rasa-x/installation-...
After installing it on /etc/rasa folder, I edited /etc/rasa/credentials.yml to add a hangouts entry:
rasa:
url: ${RASA_X_HOST}/api
hangouts:
Even after re-starting docker compose I could not get this hangouts channel to work.
Could you please point me in the direction for this kind of setup, docker-compose based?
Kinds regards,
Otmar
Hi Otmar,
I think Rasa X is one interface for using your chatbot and Hangouts are another one.
I don't understand how would you like to combine Rasa X with Hangouts.