The Google Chat API allows you to build custom bots for Google Chat, enabling automated interactions with users within a chat space. By leveraging this API on Pipedream, you can create powerful workflows that respond to messages, automate tasks, and connect Google Chat with other services. Pipedream's serverless platform provides a seamless way to invoke these APIs based on triggers from Google Chat or other apps.
import { axios } from "@pipedream/platform"
export default defineComponent({
props: {
google_chat: {
type: "app",
app: "google_chat",
}
},
async run({steps, $}) {
return await axios($, {
url: `https://www.googleapis.com/oauth2/v1/userinfo`,
headers: {
Authorization: `Bearer ${this.google_chat.$auth.oauth_access_token}`,
},
})
},
})
Automated Helpdesk Bot: Deploy a bot that listens for specific keywords in Google Chat messages. When a user mentions a support-related keyword, the bot can reply with helpful information or create a ticket in a service like Zendesk.
Meeting Scheduler: Set up a workflow that triggers when someone requests a meeting in a Google Chat room. The bot can interact with Google Calendar to find available slots and propose meeting times directly within the chat.
CI/CD Notifications: Integrate with GitHub to send updates on code commits, pull requests, or build statuses from your CI/CD pipeline into a Google Chat room, keeping your development team informed in real-time.
In order to connect your workspace Google Chat account to Pipedream, you'll need do the following:
Create a Google Chat app in Google Cloud (a Google workspace account is required).
Connect this app using custom OAuth clients on Pipedream. See the directions here on how to configure a custom OAuth client on Pipedream.
Sign in to the Google Cloud Console
Select an existing project or create a new one
pipedream.com
Chat API
select whichever scopes you intend to use and then click "Update". For more information about available Google Chat scopes, please see this overview.You will need to generate a set of OAuth credentials to connect your new Google Chat app to Pipedream.
Navigate to the Credentials section on the left side.
Click Create Credentials at the top and select “*OAuth client ID
Navigate to the workspace where you want to connect your Google Chat app, and go to Accounts, then OAuth Clients, and click **New OAuth Client.
Search for the "Google Chat" app and name your custom OAuth client. You will get a unique Redirect URI which you will need to configure in Google.
In the Google Cloud app configuration, under Authorized redirect URIs, click Add URI and enter the Redirect URI of your custom Google Chat client.
Click Enable APIs & Services on the top-left navigation bar, then Google Chat API.
Click Configuration
Fill in the required details - please note that the values you provide here will be the name of the app that you add to your Google Chat workspace.
You can name the application whatever you'd like for the app to be called within the Google Chat workspace, e.g. Pipedream
If you'd like to use the Pipedream logo for the avatar, use the URL https://pipedream.com/s.v0/app_13GhYE/logo/orig for the Avatar URL
Add a Description.
Select any Interactive features you require for your app.
Add an App URL, ideally, an HTTPS URL that you control, or you can provide the following app url https://pipedream.com/apps/google-chat-developer-app.
Under Visibility, add the email addresses of the individuals or groups within your Google Workspace organization.
Click Save.
At this point, you should have a Google Chat App under your Google Project, and a custom OAuth client on Pipedream. Make sure that the scopes in your custom OAuth client match the scopes you enabled in Google Cloud.
You should now be able to use your Google Chat application that you created on Pipedream!
Google has a 7 day expiration window on refresh tokens for applications that are set to External users with a publishing status of "Testing", so you will need to Publish your application in order to maintain your account connection.
Application disconnects after 7 days
If your developer application disconnects after 7 days, you need to follow the steps above to Publish your Google Chat app in order to keep your account connected.
Google Chat uses OAuth authentication. When you connect your Google Chat account, Pipedream will open a popup window where you can sign into Google Chat and grant Pipedream permission to connect to your account. Pipedream securely stores and automatically refreshes the OAuth tokens so you can easily authenticate any Google Chat API.
Pipedream requests the following authorization scopes when you connect your account:
email
profile
https://www.googleapis.com/auth/chat.memberships
https://www.googleapis.com/auth/chat.memberships.app
https://www.googleapis.com/auth/chat.messages
https://www.googleapis.com/auth/chat.messages.reactions
https://www.googleapis.com/auth/chat.spaces
GET
https://accounts.google.com/o/oauth2/auth
?
client_id={{oauth.client_id}}
&
redirect_uri={{oauth.redirect_uri}}
&
state={{oauth.state}}
&
response_type=code
&
scope={{oauth.space_separated_scopes}}
&
access_type=offline
&
prompt=consent
POST
https://oauth2.googleapis.com/token
content-type: application/x-www-form-urlencoded
accept: application/json
client_id={{oauth.client_id}}
&
client_secret={{oauth.client_secret}}
&
redirect_uri={{oauth.redirect_uri}}
&
grant_type=authorization_code
&
code={{oauth.code}}
POST
https://oauth2.googleapis.com/token
content-type: application/x-www-form-urlencoded
accept: application/json
client_id={{oauth.client_id}}
&
client_secret={{oauth.client_secret}}
&
grant_type=refresh_token
&
refresh_token={{oauth.refresh_token}}