How to Connect Google Chat with Salesforce Integration

Introduction to Google Chat

Google Chat, developed by Google, is a versatile messaging and collaboration platform that has evolved from Google Talk and Google Hangouts. It offers features like instant messaging, group chats, seamless file sharing, integration with Google Workspace apps, video conferencing, notifications, and robust search functionality.

Available on various platforms, Google Chat is well-suited for both personal and professional communication, providing users with a one-stop solution for efficient and organized messaging and collaboration.

Why Integrate Google Chat with Salesforce

Integrating Google Chat with Salesforce offers several benefits, much like Slack and Microsoft Teams integrations, but with some unique aspects. 

1. Enhanced Collaboration: Integrating Google Chat with Salesforce allows teams to discuss, share updates, and collaborate seamlessly within the context of customer relationships and sales opportunities. It offers a centralized platform for real-time communication alongside customer data, streamlining decision-making and customer support.

2. Streamlined Workflows: Users can automate and simplify tasks by integrating Google Chat with Salesforce, allowing for the creation of custom workflows and automated notifications. This integration can improve efficiency, reducing manual data entry and enabling quick responses to customer inquiries or hot sales opportunities.

3. Improved Customer Engagement: By connecting Google Chat with Salesforce, teams can access action custom needs in real-time, making it easier to provide personalized service. This helps in understanding customer needs, providing quicker resolutions, and ultimately enhancing customer satisfaction.

Examples of How Businesses Can Leverage Google Chat Integration with Salesforce

Google Chat integration with Salesforce can enhance productivity and collaboration within a sales or customer support team. Here are some examples of how this integration can be utilized:

1. Real-time Lead and Opportunity Updates: Receive immediate Google Chat notifications for important lead and opportunity changes in Salesforce to facilitate quick decision-making by sales teams.

2. Case Management: Integrate Salesforce cases with Google Chat for efficient handling of customer support cases. Notifications in the chat room help support teams allocate and address cases effectively.

3. Automated Task Assignments: Automate task assignment notifications in Google Chat when tasks are created or updated in Salesforce, ensuring timely task completion.

4. Meeting Scheduling:  Simplify client meeting scheduling by pulling availability data from Salesforce and sharing it within Google Chat rooms, streamlining the process.

5. Document Sharing and Collaboration: Collaborate on important documents related to Salesforce records by sharing Google Docs, Sheets, or Slides directly within Google Chat rooms, making it easier to work on proposals, reports, and presentations collaboratively.

Real Use Case of How We Use Google Chat Integration with Salesforce

Omnitoria harnesses the power of Google Chat Integration with Salesforce to enhance our sales processes. Whenever users on the Salesforce AppExchange provide us with their contact information to access our Demo video or when a new lead installs Declarative Webhooks in their Salesforce organization, our system automatically posts messages to our Sales Google Space.

Our Google Chat integration with Salesforce streamlines communication within our sales team, ensuring that critical information reaches the right people promptly. This not only accelerates follow-ups but also allows us to provide timely support and guidance to potential customers, ultimately increasing our sales opportunities and fostering more meaningful interactions with our prospects.

Now, I bet you’d like to see what we’re about to build in in action. Here you go!

Google Chat versus Slack and Microsoft Teams

  • Google Workspace Integration: Google Chat’s existing integrations with Google Workspace tools like Google Drive and Google Meet provides a unique advantage for users heavily invested in Google’s ecosystem. Slack and Microsoft Teams, while offering integrations, may not provide the same level of seamless access to Google productivity apps  for Google users.
  • Salesforce Integration Focus: While Slack and Microsoft Teams offer Salesforce integrations, Google Chat’s integration is designed to align specifically with Google Workspace, making it a top choice for organizations that primarily use Google’s productivity tools alongside Salesforce.
  • Pricing and Licensing: Google Chat may be more cost-effective for organizations already using Google Workspace, as it is often included in Google’s pricing bundles. Slack and Microsoft Teams have their own pricing structures, which may vary depending on the scale and features required.
  • User Interface and Experience: Each platform has a unique user interface and experience. Slack is known for its simplicity and extensive app integration options, while Microsoft Teams is favored by organizations using Microsoft 365 due to its out-of-box integration with Office apps. Google Chat, on the other hand, offers a clean and intuitive interface familiar to Google users.

In summary, integrating Google Chat with Salesforce offers a tailored solution for organizations that rely on Google Workspace and Salesforce. It provides a tightly integrated experience within Google’s ecosystem, which can be advantageous for users already immersed in Google’s productivity tools.

Steps to Integrate Salesforce with the Google Chat API

Create a Project in Google Cloud

  1. Login to Google Cloud and the Google Cloud Console at https://console.cloud.google.com/
  2. Create a New Project
  3. Provide a Project name, select and Organization and Location and then click the CREATE button.
  4. Select the new project you have created and click API & Services.
  5. Click Enable APIs and Services and select the Google Chat API and click the Enable button
  6. Once enabled click Create Credentials then Select an API should be Google Chat API and you will select User data for what data you will be accessing. Then click Next.
  7. You can name your App whatever you want i.e. Salesforce Integration with Google Chat. Enter a User support email, optionally an App Logo as well as a required Developer contact information email. Then click Save and Continue.
  8. Add relevant scopes depending on your requirements. Best practices are to use the principle of least privilege, but to keep things simple you can search Google Chat API and add all permissions related to the Google Chat API then click Save and Continue.
  9. Under OAuth Client ID select Application type ‘Web Application’ and name it whatever you want.
  10. We haven’t setup the Authorized redirect URIs yet, but we can anticipate it as something like: https://omnitoria.my.salesforce.com/services/authcallback/DW_Google_Chat. You’ll get the actual URL when we setup the Named Credentials and Auth Provider in Salesforce later on. Click Create.
  11. Finally Download your credentials copying your Client Id and downloading your Client Secret then click Done.

You should be well-equipped to complete the authentication process for your project and gain access to the Google Chat API through Salesforce.

Authenticating your Google Chat API Project from Salesforce

  1. Go to Salesforce Setup → Auth. Providers and click New
    1. Provider Type select Google
    2. Name can be whatever you want but I’m going with DW Google Chat Demo. 
    3. URL Suffix will get set to DW_Google_Chat_Demo if you just hit tab.
    4. Enter your Consumer Key and Consumer Secret from the Google Chat API Project you created above.
    5. Set Authorize Endpoint URL to https://accounts.google.com/o/oauth2/v2/auth?access_type=offline&prompt=consent
    6. Set Token Endpoint URL to https://accounts.google.com/o/oauth2/token
    7. User Info Endpoint URL to https://www.googleapis.com/oauth2/v3/userinfo
    8. I set User Proof Key for Code Exchange (PKCE) Extension to false
    9. Set Default Scopes to https://www.googleapis.com/oauth2/v3/userinfo
    10. Set Include Consumer Secret in SOAP API Response to true
    11. Finally, click Save. The final result should look like this.
  2. Go to Setup → Named Credentials → External Credentials
    1. Label: DW Google Chat Demo
    2. Name: DW_Google_Chat_Demo
    3. Authentication Protocol: OAuth 2.0
    4. Authentication Flow Type: Browser Flow
    5. Scope: https://www.googleapis.com/auth/chat.messages.create openid
    6. Authentication Provider: DW Google Chat Demo
    7. Click the New button in the Principals section and enter the following information:
      1. Parameter Name: Named Principal
      2. Sequence Number: 1
      3. Identity Type: Named Principal
      4. Scope: https://www.googleapis.com/auth/chat.messages.create openid
  3. Click the down arrow next to the Principal and select Authenticate. This will initiate the authentication flow.
    1. Choose your Google User Account
    2. Click Allow. It will look something like this:

Hopefully you will see the following success message:

  1. Go to Setup → Named Credentials → New
    1. Label and Name can be whatever you want.
    2. URL: https://chat.googleapis.com/v1/
    3. Enabled for Callouts: true
    4. External Credential:  DW Google Chat Demo (in my case)
    5. Generate Authorization Header: false (this is important!)
    6. Allowed Namespaces for Callouts: d_wh
  2. Create Permission Set and Assign to Users
    1. Go to Setup → Permission Sets → New
    2. Add whatever Label and API Name you want and click Save
    3. Under Apps → External Credential Principal Access → Edit → Add Available External Credential Principal
    4. Click Manage Assignments and assign the permission set to users you want to have the ability to make the callout.

Create a Google Space and Get the Webhook URL

  1. Go to Gmail → Spaces and click + New space → Create a space
  2. Enter the Space name and optional Description and add anybody you wish to the Space and click Create.
  3. Click the dropdown next to your space name at the top of the screen and select Apps & integrations.
  1. Click Add webhooks.
  2. Enter the Name and an Optional icon.
  3. Finally click the three dots next to your Webhook and click Copy link. Store your webhook URL somewhere. You will need it soon.

Implement an API Callout from Salesforce to the Google Chat API

At Omnitoria, we want to make the API callout from Salesforce to the Google Chat API to notify our sales team when someone watches our demo video or installs Declarative Webhooks.

If you’re not a Salesforce ISV, you may not know that we employ a partner org to add leads as Campaign Members when someone watches a gated demo or installs our applications. This enables us to trigger callouts and send messages to our sales team in a Google Space, similar to the one we configured earlier.

You can easily adapt this to any situation where you are adding a Campaign Member to a campaign and you want to know about it. Let’s demonstrate.

Go to the Declarative Webhooks App and Create a Callout Template:

  1. HTTP Method: POST
  2. Callout URL: callout:DW_Google_Chat_Demo/spaces/AAAAzosnaas/messages?key=AIzaSyDdI0hCZtE6vySjMm-WEfRq3CPzqKqqsHI&token=fK6M6BPuJxW9yR4oEZjjeBIO4phdXyntU4-96yWG4pM
  3. Active: Toggle On
  4. Call Authentication: Named Credentials
  5. Request Body Format: JSON (application/JSON)
  6. Template Name: DW Google Chat
  7. Main Object: CampaignMember. I’m going to use CampaignMember because I will want to post messages to the Google Space when a lead or contact records is added to my Campaign.
  8. Number of Records Per Callout: One Record 

The final result will look like the following:

Click Save and Continue.

Google API Callout Headers

There’s not any configuration you have to do to the Callout Headers and you can accept the default:

  1. Content-Type: application/json
  2. Accept: application/json

Click Save and Continue.

Google Chat API Callout Request Body

The Request Body is extraordinarily simple for the Google Chat API and has the following form:

{"text" : "some text"}

I’m going to create a little magic in the text node by making it a formula so we can post different messages for different Campaigns. This will make our Callout template re-usable for multiple notifications. Create the “text” node as follows:

  1. Node Name: text
  2. Node Type: Single Value
  3. Node Data Type: Text (String)
  4. If value is null: Send NULL
  5. Value Source: Formula
  6. Formula:
    1. CASE( Campaign.Name, 

“AppExchange – Watch a Demo”,  “Declarative Webhooks demo video watched on the Salesforce AppExchange by ” &  FirstName  & ” ” & LastName & IF(ISBLANK(Title), “”, “, ” & Title & “,”) & ” at ” &  CompanyOrAccount & ” with email address ” &  Email  & “. For more information go to: ” & “https://omnitoria.lightning.force.com/” & LeadOrContactId, 

“Welcome Email”,  “Declarative Webhooks installed from the Salesforce AppExchange by ” &  FirstName  & ” ” & LastName & IF(ISBLANK(Title), “”, “, ” & Title & “,”) & ” at ” &  CompanyOrAccount & ” with email address ” &  Email  & “. For more information go to: ” & “https://omnitoria.lightning.force.com/” & LeadOrContactId,

“Something happened. I don’t know what.”

)

In the formula, you may observe that we’re examining the Campaign Name and generating distinct messages to post on Google Spaces. This differentiation is based on whether an individual merely viewed the demo or installed Declarative Webhooks.

When you click Done it will look like this and you will click Save and Continue:

Google Chat API Callout Response

There’s nothing really from the Google Chat API Callout Response that I am interested in mapping back to Salesforce so in this case I will leave the Response Body Template alone and click Save and Continue.

Google Chat API Callout Actions

Again, I’m not mapping anything back in the response to Salesforce so configuring Response Actions isn’t necessary in this case and we should proceed to clicking Save and Close.

The final callout template will look like this:

Implement a Salesforce Record-Triggered Flow to Invoke your Google Chat API Callout

Now it’s time to automate the process of posting messages to our Google Space from Salesforce. To do this, we simply need to create a Record-Triggered Flow as follows:

  1. Object: Campaign Member
  2. Trigger: A record is created
  3. Condition Requirements: None
  4. Optimize the Flow for: Action and Related Records:

Next add a Decision element called ‘Which Campaign?” Add the following Outcomes:

  1. AppExchange Demo Video Watched Outcome
    1. Label: AppExchange Demo Video Watched
    2. Outcome API Name: AppExchange_Demo_Video_Watched
    3. Condition Requirement to Execute Outcome: All Condition Are Met (AND)
      1. {!$Record.Campaign.Name} Equals AppExchange – Watch a Demo
  2. AppExchange Install Outcome
    1. Label: AppExchange Install
    2. Outcome API Name: AppExchange_Install
    3. Condition Requirement to Execute Outcome: All Condition Are Met (AND)
      1. {!$Record.Campaign.Name} Equals Welcome Email

The final step is to Invoke our Callouts, but we can actually use the same Callout Template for each because we planned it that way. Simply:

  1. Add two Action Element just name them something unique and add them to both outcomes above.
  2. Select Invoke Callout (Using Developer Name)
    1. Callout Template Developer Name: DWGoogleChat
    2. Record Id: {!$Record.Id}

Your flow will look like the following:

We’ve successfully set up our Salesforce Flow to automatically post a message in our Google Space when a Campaign Member is added to either our “Demo Video Watched” campaign or our “Install” campaign.The kean observer might have noticed a second Apex Action called ‘Add to List and Journey’ in the flow above. We’ll dive into the details of that another time. It’s worth noting the significant power that comes with automating and sequencing multiple integrations together.

Conclusion

We’ve explored the integration of Google Chat with Salesforce, a powerful combination for enhancing collaboration and automating workflows. Google Chat offers a robust messaging and collaboration platform, and when integrated with Salesforce, it brings several benefits, such as improved collaboration, streamlined workflows, and enhanced customer engagement.

We’ve compared this integration with alternatives like Slack and Microsoft Teams, highlighting its advantages for organizations already using Google Workspace and Salesforce. Additionally, we’ve provided examples of how businesses can leverage this integration to boost productivity and improve customer support.

To demonstrate the practicality of this integration, we shared a real use case from Omnitoria, where it streamlines communication within the sales team, ensuring timely follow-ups and support for potential customers.

Finally, we’ve guided you through the steps to integrate Salesforce with the Google Chat API, showing you how to create a project in Google Cloud, authenticate it from Salesforce, and implement an API callout to post messages in Google Chat. The potential for automating and sequencing multiple integrations together opens up new possibilities for efficiency and effectiveness in your operations.

Thank you for joining us on this journey of integration and automation.

If you want to learn more about Declarative Webhooks, please follow the links below: