This guide explains how to integrate Salesforce Service Cloud with Sendbird Chat through Salesforce Connector. First, download the Salesforce Connector installation package. Then set up the integration environment on both Sendbird Dashboard and Salesforce Setup. After the set-up, create a group channel on Sendbird Chat SDK and create a Case using Salesforce's site to connect to the channel.
Log in to your organization’s Salesforce account with a System Administrator’s ID and password.
Select Install for All Users and Do not install for What if existing component names conflict with ones in this package. Then click Install. Make sure if the file is the latest version. As of May 12, 2023, the latest version of the package is 1.62.
A popup will appear asking if you would like to grant third-party access to Sendbird. See if Sendbird’s websites are listed and check Yes, grant access to these third-party web sites. Then click Continue.
Note: If you see an error message saying Invalid type: UserServicePresence, AgentWork, go to Setup > Omni Channel Settings, check the box next to Enable Omni-Channel, and Save.
Now, go to Sendbird Dashboard and add Salesforce integration under Settings > Chat > Integrations. Once Salesforce Connector integrates Salesforce Service Cloud and Sendbird Chat, a conversation within each Salesforce Case takes place in a group channel in Sendbird Chat SDK. Therefore, make sure to configure the group channel settings on Sendbird Dashboard as well to meet your service needs.
On Sendbird Dashboard, go to Settings > Chat > Integrations and select Salesforce.
Click the Add button in the top-right corner to start Salesforce integration.
The API Token field will appear and you'll need the token later, so copy and paste it somewhere safe.
Note: You can enable additional add-on services, such as Einstein Bots, from the Salesforce integration page in the dashboard. But before doing so, you need to complete the settings for Service Cloud. To integrate Einstein Bots with Sendbird Chat, see our documentation on Salesforce Einstein Bot integration.
Once integrated, all conversations between your agents and customers will happen in group channels in Sendbird Chat SDK. Enable the following functionalities of group channels for a fuller context of your customer service. This can ensure comprehensive and timely customer support, allowing agents to see previous conversations for context and be informed of any change in their Cases.
Go to Settings > Chat > Channels > Group channels.
Turn on Chat history to allow agents to see old messages between them and their customers in a group channel.
Select Joins automatically when invited for Default channel invitation preference.
(Optional) Select which Auto message to send to group channels for specific user and channel events. Auto message is an admin message that is systematically sent to group channels when a specific event occurs. The screenshot below shows the recommended settings for Auto message.
Step 3: Configure the Salesforce Service Cloud settings
After configuring group channels on Sendbird Dashboard, go to Salesforce Service Cloud's Setup page and set up the service environment for integration.
Note: As Salesforce Service Cloud offers a wide range of functionalities in their Setup page, use Quick Find in the left menu bar when you need to move to a different settings page.
Create a Sendbird__c object on Salesforce Service Cloud
Register your Sendbird application ID and its API token to Salesforce Service Cloud using a Sendbird__c object. Use Salesforce's Developer Console in Apex.
Click the Setup button in the top-right corner of your screen and you will find the Developer Console.
Set values of the following properties in a Sendbird__c object.
Property name
Type
Description
name
string
Specifies the name of the object in Apex. The value of this property is automatically generated and given by the system. Once the object is created, make sure its name is SB-0000 because Sendbird can only recognize an object with the name SB-0000.
Application_ID__c
string
Specifies your Sendbird application ID. This can be found under Settings > Application > General on Sendbird Dashboard.
API_Token__c
string
Specifies the Salesforce integration's API token generated on Sendbird Dashboard. This can be found under Settings > Chat > Integrations > Salesforce on Sendbird Dashboard.
On the Developer Console window, go to Debug > Open Execute Anonymous Window in the menu bar and execute the following Apex code.
If you want to check the object is created correctly, select the Query Editor tab and execute the following query.
SELECT FIELDS(ALL) FROM Sendbird__c WHERE Name = 'SB-0000' LIMIT 1
Then a Sendbird__c object like below is created.
Note: Sendbird can only recognize a Sendbird__c object whose Name is set to SB-0000. If you entered a wrong value to the object, click the cell on the Console and correct the value directly instead of running the code multiple times and creating more objects.
To send an HTTP request to and from Salesforce, your Sendbird API request URL must be registered as a Remote Site on the platform.
On Salesforce Service Cloud's Setup Home, type Remote Site Settings in the Quick Find search bar. Or go to Setup Home > Security > Remote Site Settings in the left menu bar.
Click New Remote Site at the top of the Remote Site table.
Fill in each field according to the following instructions.
Remote Site Name: Enter any value of your choice. Only alphanumeric characters and underscores are allowed in Remote Site Name. Don't use spaces.
Remote Site URL: The URL should be https://api-[YOUR_SENDBIRD_APPLICATION_ID].sendbird.com. Replace [YOUR_SENDBIRD_APPLICATION_ID] in the URL with your Sendbird application ID.
Once integrated, Support Chat connects Cases in Salesforce with group channels in Sendbird Chat SDK. In order to effectively manage and route these channels to your agents, leverage the Omni-Channel feature in Salesforce. The Omni-Channel feature automatically routes all the work items, such as Cases, to agents based on the agent's capacity, priority, status, and etc. Here, you need to create and configure Service Channel, Presence Status, User Access, and Routing Rule to get started with Omni-Channel.
This guide demonstrates the basic requirements of Omni-Channel for the integration. To learn more about how to customize Omni-Channel, see Salesforce's guide on Omni-Channel.
On Salesforce Service Cloud, search Omni Channel Settings in Quick Find or go to Omni-Channel > Omni-Channel Settings in the left menu bar.
In the Omni-Channel Settings page, check the box next to Enable Omni-Channel. Depending on your service needs, configure other settings such as Skills-Based Routing and Secondary Routing Priority as well.
Go to Omni-Channel > Service Channels in the left menu bar and click the New button at the top of the table.
You can now create a new Service Channel for Cases. Fill in each field according to the following instructions and Save the Service Channel.
Service Channel Name: Enter any value of your choice. Copy the channel name on the side as it’s required when creating a new Presence Status in the following section.
Developer Name: Enter any value of your choice.
Salesforce Object: Select Case.
(Optional) Check the box next to Minimize the Omni-Channel widget when work is accepted.
(Optional) Check the box next to Automatically accept work requests. If this option is unchecked, agents manually take Cases routed through Omni-Channel Utility.
Go to Omni-Channel > Presence Statuses in the left menu bar and click the New button at the top of the table.
Note: If your organization already have a Presence Status in use, you can add the new Service Channel you've created in the previous section to the existing statuses instead of creating a new Presence Status.
You can now create a new status. Fill in each field according to the following instructions and click Save the Presence Status.
Status Name: Enter any value of your choice. Examples can be Available and Online. Copy the status name on the side because it’s needed when granting status access to users in the following section. For more information, see Salesforce's guide on Presence Status Settings.
Developer Name: Enter any value of your choice.
Status Options: Select Online.
Add the service channel you created in the previous section to Selected Channels.
Go to Omni-Channel > Routing Configurations in the left menu bar and click the New button to create a new routing rule. This rule can be applied to your Queues in the following section.
Fill in each field according to the following instructions and Save.
Routing Configuration Name: Enter any value of your choice.
Units of Capacity or Percentage of Capacity (optional): You must enter a value of your choice to either one of the two fields. See Salesforce’s guide to learn more.
In Salesforce Service Cloud, each issue raised by customers or agents is called Case and Cases are queued and assigned to its members according to Assignment Rules. Create a Queue and Assignment Rules for the Cases that utilizes Sendbird Support Chat.
This guide demonstrates the basic requirements for the integration. To learn more about how to customize Queues and Assignment Rules, see Salesforce guide.
To assign Cases connected to Sendbird Chat to agents, you must create a dedicated Queue and Assignment Rules for them.
Go to Setup Home > Administration > Users > Queues the left menu bar or search Queues in Quick Find.
Select the New button at the top of the Queues table.
Fill in each field according to the following instructions and Save.
Label: Enter Sendbird Chat Queue as shown in the image below. The value of Label must be Sendbird Chat Queue. Otherwise, conversations through Sendbird Chat SDK won’t show in Cases properly.
Queue Name: Once Label is entered, Queue Name is automatically generated.
Configuration with Omni-Channel Routing: Search and select the Routing Rule you created in the previous step.
Supported Objects: Select Case in Available Objects and add it to Selected Objects.
Queue Members: Add Members to Selected Members so that they can be assigned to the Cases that fall into this queue.
Go to Setup Home > Feature Settings > Service > Case Assignment Rules in the left menu bar or search Case Assignment Rules in Quick Find.
Select the New button at the top of the Assignment Rules table.
Enter a name for the new assignment rule. Check Active and Save. You will return to the Case Assignment Rules page. Click the rule you've just created.
Select the New button in the Rule Entries section.
Enter a new rule entry as shown in the image below and Save.
Step 1: Set Sort Order to 1. If you plan to use Salesforce Einstein Bots along with Service Cloud, set the order to 2 so that bots can take new Cases first.
Step 2: Salesforce Connector utilizes a Case object’s custom field to differentiate conversations by a chatbot and a human agent. Select Case: Sendbird Channel URL and not equal to for Field and Operator, respectively. Then enter Null in Value as shown below.
Step 3: Select the queue to apply this Assignment Rule to. Select Queue in the dropdown menu and search Sendbird Chat Queue you just created in the previous section.
Now, add a UI component to Cases. With the UI component, agents can hold real-time conversation with customers still accessing all the data on Salesforce Service Cloud. Salesforce Connector provides two types of user interfaces: a utility widget chat UI and a Case-embedded chat UI.
Note: You need at least one Case available on Salesforce Service Cloud to insert the case-embedded UI component to the view. If you already have a Case on Salesforce Service Cloud, you can proceed with the process. If not, create a Case first and come back to this section.
You can also add the UI component of Sendbird Chat Panel into the Case view.
Select the Apps icon next to Setup in the top-left corner of your screen. Then search Service Console and choose the default Service Console app.
If you already have Cases in your organization, select any Case of your choice.
Select the Setup button in the top-right corner of your screen and go to the Edit page.
In the search box located at the top of the left menu bar, type Sendbird Chat Panel. Click and drag Sendbird Chat Panel under Custom to place it where it best fits your agents' experiences within a Case. Make sure the chat UI component is embedded in the right place you planned. It could be anywhere within the Case view. Drag and adjust the component to your needs.
An error message will appear in the embedded chat UI if the Case isn’t linked to a valid Sendbird group channel. To prevent the error message from showing in the UI, use the Component Visibility filter. Select the chat UI component to see the Set Component Visibility sidebar. Then click the Add Filter button and create a filter with the following values.
Field: Sendbird Channel URL
Operator: Not Equal
Value: ''
Select Activation in the top-right corner of the screen to apply this change to all Cases.
When an Activation popup appears, go to the APP DEFAULT tab and select Assign as App Default. Select Service Console when the Select Apps popup appears. For Select form factor, select Desktop and click the Next button. Review assignment and Save.
If changes are saved, you can go back to the Case view and see if the chat UI component is working properly.
The configurations for integration are completed. Before jumping onto building your application with Sendbird Chat SDK, you can visit our live demo to try out the chat experience that Salesforce Connector offers.
Note: We recommend that this demo application should be tested with a development or testing account on Salesforce to prevent any confusion. While Sendbird doesn’t retrieve or store any sensitive Salesforce data to the Sendbird server, creating Cases in your Salesforce organization through this demo application can cause inconvenience or confusion among users if used with the production account.
The demo showcases the chat experience from an end-user's perspective, enabling you to create a Salesforce Case by sending a message and initiating a chat with an agent in a Sendbird’s group channel.
Select Login with Salesforce to enter your account ID and password.
Select Allow to allow Salesforce Connector to access user data and identity URL service.
Click the Start chat button in the top-right corner of the sample app to begin a chat.
Confirm that the Salesforce Case is created correctly on your Salesforce Service Console. If you have enabled Einstein Bots, the bot takes the Case. If not, an agent is assigned to it in Salesforce Service Console.
Confirm if the Sendbird Chat Panel UI component you added earlier displays the chat in the agent view.
Once you’ve set up both Sendbird Dashboard and Salesforce Service Cloud for integration, implement integration codes on the client app.
Salesforce Connector links a Salesforce's Case to a group channel in Sendbird Chat SDK with its channel URL. So, link the group channel's URL to the SendbirdChannelURL__c property of Case. Set the optimal configurations of group channels including setting the value of custom_type to SALESFORCE_SUPPORT_CHAT_CHANNEL.
Once the group channel are set, add the SampleCaseController class to Salesforce Service Cloud to handle the API requests for Cases and create a Case using the Apex RESTful API. Salesforce Service Cloud doesn’t provide a client-side SDK and a dedicated server to process the API requests related to Cases. Use AWS’ Lambda, your own server, or create an API endpoint in Apex to make and receive API calls. This guide demonstrates how to create a public endpoint in Apex for a quick and easy implementation.
For the implementation of general chat features such as loading a list of group channels, entering a channel, and sending messages, see our Sendbird Chat Docs.
First of all, a group channel must be created so that its channel URL can be passed to a Case in Salesforce and the connection is made. In order for Salesforce Connector to recognize such group channels, the channel's custom_type must be set to SALESFORCE_SUPPORT_CHAT_CHANNEL. The following is an example of group channel data in JSON format.
{
"name": "User Inquiry: Payment not working",
"channel_url": "support-chat-23489",
"cover_url": "https://sendbird.com/main/img/cover/cover_08.jpg",
"custom_type": "SALESFORCE_SUPPORT_CHAT_CHANNEL",
"unread_message_count": 0,
"data": "",
"members": [],
/* Other group channel properties below ...*/
}
Besides the group channel’s custom_type, the following properties need to be checked for Salesforce Connector integration.
For example, once Salesforce Connector is integrated, a group channel must be created first in your app or through Sendbird Platform API. Only then a Case can be linked to the channel because the group channel’s channel_url should be passed to the Case’s SendbirdChannelURL__c property.
Add the following custom fields to the Case so that each Case object can be linked to a group channel of your Sendbird application.
Property name
Type
Description
SendbirdUserId__c
string
Specifies the unique ID of the user who created the Case. This user ID is from your Sendbird application.
SendbirdChannelURL__c
string
Specifies the URL of the group channel to be linked to the Case on Salesforce Service Cloud.
IsEinsteinBotCase__c
boolean
Indicates whether the Einstein Bots feature is enabled for the Case. The value of true returns only if you are using the bot service on Salesforce. To integrate Einstein Bots with Sendbird Chat, see Salesforce Einstein Bots integration. To learn more about the Bots, see Salesforce's guide.
The group channel linked to a Case synchronizes the Case's status information to its metadata.caseStatus property. You can also be notified of the change by adding a channel event handler such as onMetaDataUpdated. See our Docs to learn more.
By tracking the change of Case status, Salesforce Connector also supports a functionality that enables an agent to leave a group channel when the Case is closed. To enable this feature, the Case status label of Closed should not be edited or changed. Make sure that the status label for closed Cases is set to Closed in Setup > Object Manager > Case > Fields & Relationships > Status.
There are multiple ways to create a Case, such as making a REST API request, but this guide uses a public domain and Apex REST API. By default, the Salesforce REST API requires authentication. However, in this guide, you will create a public endpoint using Salesforce’s Site, which allows you to make calls without authentication.
Before creating a Site, add the SampleCaseController class to Salesforce Service Cloud.
Select the Setup button in the top-right corner of your screen to open Developer Console.
When the console appears, go to File > New > Apex Class. Enter a new class name SampleCaseController and select OK.
Copy and paste the following code into the console and Save.
// For the REST API, we use the RestResource annotation.
// We map it to /cases/, so the final URL is YOUR-PUBLIC-DOMAIN/services/apexrest/cases/.
@RestResource(urlMapping='/cases/')
global with sharing class SampleCaseController {
// According to the REST API protocol, creating a Case object uses a POST method.
@HttpPost
global static void create() {
RestRequest request = RestContext.request;
RestResponse response = RestContext.response;
Map<String, String> headers = request.headers;
// To use the request body, we should deserialize it. In this sample, we use Map.
String requestBodyStr = request.requestBody.toString();
Map<String, Object> body = (Map<String, Object>) JSON.deserializeUntyped(requestBodyStr);
// Create a Case record and edit its status by setting its parameters.
// SendbirdUserId__c, SendbirdChannelURL__c, and IsEinsteinBotCase__c are required.
Case newCase = new Case();
newCase.Subject = (String) body.get('subject');
newCase.Description = (String) body.get('description');
newCase.SuppliedName = (String) body.get('suppliedName');
newCase.SuppliedEmail = (String) body.get('suppliedEmail');
newCase.SendbirdUserId__c = (String) body.get('sendbirdUserId');
newCase.SendbirdChannelURL__c = (String) body.get('sendbirdChannelURL');
newCase.IsEinsteinBotCase__c = (Boolean) body.get('isEinsteinBotCase');
// Save your new Case.
insert newCase;
// Get a response with the information of your new Case.
response.addHeader('Access-Control-Allow-Origin', '*');
response.responseBody = Blob.valueof(JSON.serialize(newCase));
response.statusCode = 200;
}
}
On Salesforce Service Cloud, go to Setup > User Interface > Sites and Domains > Sites in the left menu bar. If you already have a site domain you can use, click Site Label of your choice and skip to #5. If you don’t have a site yet, check Sites Terms of Use first and then select Register My Salesforce Site Domain.
Click the New button at the top of the Sites table.
Fill in and check each item according to the following instructions.
Site Label: Enter a name of your choice.
Site Name: This is automatically generated once you’ve entered Site Label.
Active Site Home Page: Choose any site from the search list. This won’t affect the behavior of the Site.
Check the box next to Active.
Check the box next to Lightning Features for Guest Users.
Check the box next to Enable Content Sniffing Protection.
Check the box next to Referrer URL Protection.
Check the box next to Redirect to Custom Domain.
Check the box next to Cache public Visualforce pages.
Note: Make sure to leave the Default Web Address empty.
Save the Site and you will see Site Details of the new site you’ve created. Select Public Access Settings at the top of the Site Detail table.
Select Enable Apex Class Access at the top of the table. This will land you to the Enabled Apex Class Access section. Then choose Edit next to the section title.
Select SampleCaseController from Available Apex Classes and add it to Enabled Apex Classes. Then Save.
You will see the controller added as an accessible class.
Now you can send a message to the Apex REST API server you’ve created and create a Case using the following sample. Copy the Site URL from the Sites list and replace YOUR-PUBLIC-DOMAIN in the request URL with it. Then copy the following code and add it to your client app.
// POST 'YOUR-PUBLIC-DOMAIN/services/apexrest/cases/' // A trailing slash is required.
// Request body
{
"subject": "chat",
"suppliedName": "chat user",
"suppliedEmail": "user@test.com",
"sendbirdUserId": "user@123",
"sendbirdChannelURL": "channel@url@123",
"isEinsteinBotCase": false
}
Note: This sample is intended to serve as a quickstart for your convenience and doesn’t support crucial security features such as a validator, authenticator, error handling, security checks, etc. We strongly recommend that developers thoroughly review and test any codes before deployment and modify them to meet the security and functionality requirements of your organization. We aren't responsible for any damages or issues that may arise from the use of this sample code. To learn more about authorization on Salesforce, visit Salesforce’s guide.