Support Chat Guide v1
Support Chat
Version 1

Customer Satisfaction (CSAT)

Copy link

The Customer Satisfaction (CSAT) feature enables users to rate their experience after interacting with an agent. When CSAT is activated, a CSAT question message is sent to the user once the chat session has ended. Users can then provide feedback by selecting a satisfaction score and optionally leaving a comment. The feedback gathered from CSAT responses helps enhance the quality of customer support services.


Prerequisites

Copy link
  1. Sendbird Chat SDK integration with Salesforce Service Cloud. See guide.

Step 1. Update UI for CSAT

Copy link

Start by updating the end user's UI to display the CSAT question message and allow users to submit their feedback. The CSAT question message is sent as an admin message with a custom type of SALESFORCE_SUPPORT_CHAT_CUSTOMER_SATISFACTION. The user can respond with a score and an optional comment.

CSAT message types

Copy link

The CSAT functionality uses specific custom message types:

  • CSAT Question: Sent as an admin message with custom type SALESFORCE_SUPPORT_CHAT_CUSTOMER_SATISFACTION.
  • CSAT Response: Sent with custom type SALESFORCE_SUPPORT_CHAT_CUSTOMER_SATISFACTION_RESPONSE.

The UI should be customized to display CSAT questions differently from standard admin messages, including options for scoring and comments.

Implementation details

Copy link

When submitting feedback, include the following data as a JSON string:

Properties
RequiredDescription

question_message_id

ID of the original CSAT question message.

csat_score

User's satisfaction score, typically a numeric value representing the rating given by the user.

OptionalDescription

csat_comment

User's feedback comment, providing additional context to the score.

Code examples

Copy link

To implement this, you can use either the MessageCollectionHandler or the GroupChannelHandler to listen for incoming messages in a group channel.

Option 1. Using collection

Copy link
collection.setMessageCollectionHandler({
  onMessagesAdded: (context: MessageEventContext, channel: GroupChannel, messages: BaseMessage[]) => {
    if (channel.customType === 'SALESFORCE_SUPPORT_CHAT_CHANNEL') {
      const csatMessage = messages[0];
      if (csatMessage instanceOf AdminMessage) {
        if (csatMessage.customType === 'SALESFORCE_SUPPORT_CHAT_CUSTOMER_SATISFACTION') {
          // Draw CSAT Screen
          drawCsat(channel, csatMessage);
        }
      }
    }  
  },
  // ...
});

Option 2. Using GroupChannelHandler

Copy link
channel.addGroupChannelHandler('HANDLER_KEY', new GroupChannelHandler({
  onMessageReceived: (channel: GroupChannel, message: BaseMessage) => {
    if (channel.customType === 'SALESFORCE_SUPPORT_CHAT_CHANNEL') {
      if (message instanceOf AdminMessage) {
        if (csatMessage.customType === 'SALESFORCE_SUPPORT_CHAT_CUSTOMER_SATISFACTION') {
          // Draw CSAT Screen
          drawCsat(channel, message);
        }
      }
    }
  }
}));

drawCsat(channel: GroupChannel, csatMessage: AdminMessage): void {
  const satisfactionMessageData = JSON.parse(csatMessage.message);
  // code for display csat screen
  // use satisfactionMessageData.body
  // when rating completed.
  const csatResponse = {
    question_message_id: csatMessage.messageId,
    csat_score: score,
    csat_comment: comment,
  };
  channel.sendUserMessage({
    customType: 'SALESFORCE_SUPPORT_CHAT_CUSTOMER_SATISFACTION_RESPONSE',
    message: JSON.stringfy(csatResponse),
  });
}

CSAT response format

Copy link

When a CSAT question message includes a rating, the data field contains:

{
  "data": "{
    \"csat_comment\": \"good\",
    \"csat_score\": \"4\",
    \"csat_rated_message\": \"Thanks for your feedback!\",
    \"csat_question_message\": \"How was your conversation?\"
  }"
}

Step 2. Enable CSAT

Copy link

To enable CSAT, update the CSAT related settings in the Sendbird Support Chat Configuration page within your Salesforce organization.


Step 3. Updating CSAT feedback in Salesforce case

Copy link

To add CSAT feedback data to a Case, use the Sendbird Chat Platform API. This allows you to log customer CSAT feedback and retrieve CSAT records updated over a specific period. For more information, refer to the Sendbird Chat Platform API documentation here.

HTTP request

Copy link
GET https://api-{{app_id}}.sendbird.com/v3/salesforce_channel_csat_logs/

Parameters

Copy link

The following table lists the parameters that this action supports.

Properties
RequiredTypeDescription

start_dt

string

Specifies the start date and time for the range of CSAT logs to retrieve. The date string should be in the format %Y-%m-%dT%H:%M:%SZ.

end_dt

string

Specifies the end date and time for the range of CSAT logs to retrieve. The date string should be in the format %Y-%m-%dT%H:%M:%SZ.

OptionalTypeDescription

token

string

Specifies a page token that indicates the starting index of results to retrieve. If not specified, the index is set to 0.

limit

int

Specifies the number of bots to return per page. Acceptable values are 1 to 100, inclusive. (Default: 10)

Response

Copy link

If successful, an example response is as follows:

{
    "salesforce_channel_csat_logs": [
        {
            "channel_url": "sendbird_group_channel_12345",
            "last_agent_user_id": null,
            "question_message_id": 249528566,
            "response_message_id": 249528762,
            "csat_question_message": "How was your conversation?",
            "csat_score": 4.0,
            "csat_comment": "great",
            "responded_ts": 1730878375630,
            "created_at": "2024-11-06T07:32:56Z",
            "updated_at": "2024-11-06T07:32:56Z"
        }
    ],
    "next": "YB0RRFZTS1JAEEZdXF1afx"
}