Connect WhatsApp Business Account and Salesforce Live Agent using Mule 4

Edgar Moran
Another Integration Blog
4 min readSep 19, 2023

During Dreamforce 23 I had the chance to present “Keep Live Agent Conversations Organized” where I shared a proof of concept using WhatsApp business account, a MuleSoft implementation and Salesforce Live Agent.

The main idea behind this POC was to demonstrate how as a company running a business where customer support is one of the most important part, a company with a few steps is able to enable customers to send messages using WhatsApp Business Account and receive those requests inside Salesforce Service Cloud using Live Agent and on behind the scenes a MuleSoft application controlling the incoming requests and existing sessions.

Here’s a general overview of how the applications was built.

WhatsApp, MuleSoft and Live Agent Integration

Setting up Whatsapp Business Account.

For me, this was the first step. which required for me to open a Business Facebook page, and later I was requested to setup my Meta developer account. For a full reference and step by step guide you can go https://developers.facebook.com/docs/whatsapp/business-management-api/get-started/ .

In the end, once you enable the WhatsApp module in your developer account, meta provides a test phone number, it will allow to hold one single channel for communication

Then you need to follow the steps for how to configure Webhooks. There is where you need to use a MuleSoft endpoint (GET) in order to create the handshake

Then you should be able to setup what notifications you want to receive

In the other hand, you will get a section for the API information to send the messages to your customers:

The request payload to send the messages to the user is similar to this:

Basically this information allows to send a message to the customer and the webhook will receive any message they sent back.

The MuleSoft implementation

The Mule application has multiple pieces:

  • The Web-hook endpoint: Allows WhatsApp to make the handshake with your application and allows to receive incoming events (POST).
  • Validation of incoming request: In order to check if a customer (using their phone number as unique identifier) is already in the system with a session, we need to have a validation, either it will create a new one or it will pass the message directly to the Agent.
  • Session Handler: It will allow to poll messages from Live agent every 10 seconds and send the reply to the correspondent customer in WhatsApp.
Storing the session
Validating the session
Pulling messages from Live agent.

The Salesforce Live Agent piece

We will use Salesforce Live agent for this POC, in order to use it we will need to make use of the official documentation but a general before start we need to setup the Omni Channel for Chat in Salesforce, this can be done easily in Salesforce using the Service Setup:

You will need to follow the step by step guide until the setup for you looks ok, at the very end you will need to keep track of the ButtonId , DeploymentId and Organization Id, as those are values we will use in the MuleSoft application to know whenever a new request is done in Salesforce

How the process looks like in a video.

Hope you like it and looks interesting. I will eventually share a GitHub repository so you can play with it.

--

--

Edgar Moran
Another Integration Blog

@Mulesoft Ambassador | Software Engineer @Cisco Meraki | Ex-Twitter | Sr. Force.com developer | innovating in technology, love coding, and photography !