Configure a Chat Session

Before starting a chat session, you have several ways to configure the session using the SCSChatConfiguration object. These configuration settings allow you to specify pre-chat fields, determine whether a session starts minimized or full screen, and get updates about the user's queue position.

The legacy chat product is scheduled for retirement on February 14, 2026, and is in maintenance mode until then. During this phase, you can continue to use chat, but we no longer recommend that you implement new chat channels. To avoid service interruptions to your customers, migrate to Messaging for In-App and Web before that date. Messaging offers many of the chat features that you love plus asynchronous conversations that can be picked back up at any time. Learn about chat retirement in Help.

Important

When you start a chat session, you specify an SCSChatConfiguration object as one of the arguments. This object contains all the configuration settings necessary for Chat to start a session. To create an SCSChatConfiguration object, you specify information about your org and deployment.

In Swift:

1let config = SCSChatConfiguration(liveAgentPod: "TO_DO_POD_NAME",
2                                  // e.g. "d.gla5.gus.salesforce.com"
3                                  orgId: "TO_DO_ORG_ID",
4                                  // e.g. "00DB00000003Rxz"
5                                  deploymentId: "TO_DO_DEPLOYMENT_ID",
6                                  // e.g. "573B00000005KXz"
7                                  buttonId: "TO_DO_BUTTON_ID")
8                                  // e.g. "575C00000004h3m"

In Objective-C:

1SCSChatConfiguration *config =
2  [[SCSChatConfiguration alloc] initWithLiveAgentPod:@"TO_DO_POD_NAME"
3                                              // e.g. "d.gla5.gus.salesforce.com"
4                                               orgId:@"TO_DO_ORG_ID"
5                                              // e.g. "00DB00000003Rxz"
6                                        deploymentId:@"TO_DO_DEPLOYMENT_ID"
7                                              // e.g. "573B00000005KXz"
8                                            buttonId:@"TO_DO_BUTTON_ID"];
9                                              // e.g. "575C00000004h3m"

You can get the required parameters for this method from your Salesforce org. See Get Chat Settings from Your Org. If your Salesforce admin hasn't already set up Chat in Service Cloud or you need more guidance, see Org Setup for Chat in Lightning Experience with a Guided Flow.

Note

However, there are other options you can set using SCSChatConfiguration at configuration time.

The following features are available for configuration:

Table 1. Session Display Configuration Settings
Property Name Description Type & Default Value
allowMinimization Indicates whether the user is allowed to minimize the chat session view. Bool: true/YES
allowURLPreview Indicates whether the user is shown URL previews when the agent types a URL in the chat feed. Bool: true/YES
defaultToMinimized Indicates whether the chat session starts out as a minimized thumbnail view. Bool: true/YES

When the minimized view is visible, it displays the number of unread messages. This value represents the total number of bot, agent, and system messages that are unread.

Note

Table 2. Background Configuration Settings
Property Name Description Type & Default Value
allowBackgroundExecution Indicates whether to allow extended background execution to support active chat sessions. When true, active chat sessions can remain in the background for more than three minutes. See allowBackgroundNotifications for related functionality. Bool: true/YES
allowBackgroundNotifications Indicates whether the session posts local notifications based on chat activity. Requires that allowBackgroundExecution is also set to true. To learn more, see Notifications for Chat Activity. Bool: true/YES

When turning on background execution, be sure that Idle Connection Timeout Duration is set in your org. To learn more, see Chat Deployment Settings.

Note

Table 3. Pre-Chat Configuration Settings
Property Name Description Type & Default Value
prechatEntities Pre-chat fields are always sent to the agent at the start of the session. To fill in fields of a particular record, instantiate an SCSPrechatEntity for each Salesforce object (for example, Case or Contact) and an SCSPrechatEntityField for each field (for example, Subject or LastName). To learn more, see Create or Update Salesforce Records from a Chat Session. SCSPrechatEntity array: nil
prechatFields You can specify both optional and required fields shown to the user before a chat session starts. You can also directly pass data to an agent without requiring any user input. To create pre-chat fields, add SCSPrechatObject instances to the prechatFields property on the SCSChatConfiguration object. To learn more, see Show Pre-Chat Fields to User. SCSPrechatObject array: nil
Table 4. Other Configuration Settings
Property Name Description Type & Default Value
eventList Adds a custom path that displays a custom tile and performs a custom action within your app. To learn more, see Handle Custom URLs in Chat. SCSAppEventList
queueStyle Determines the style of the queue: queue position number (.position), estimated wait time (.estimatedWaitTime), or no queue information (.none). You can subscribe to queue position events using session(didUpdateQueuePosition:estimatedWaitTime:) on SCSChatSessionDelegate. To understand the algorithm used for the estimated wait time, see the estimated wait time documentation in the Chat REST API Developer Guide. SCSChatConfigurationQueueStyle: .position
remoteLoggingEnabled Indicates whether session logs are sent for collection. (Logs sent remotely don't collect personal information. Unique IDs are created for tying logs to sessions and those IDs can't be correlated back to specific users.) Bool: true/YES
visitorName Name of the chat visitor. This value is used by the Service Cloud console and displayed to the agent. String: "Visitor"

When using the estimated wait time, the wait time is shown to the user in minutes. However, you can set the minimum (minimumEstimatedWaitTime) and maximum () wait time values. If the wait time exceeds the maximum value, a generic message appears, which you can customize (using the customizable chat strings in the ServiceCloud.Chat.Status.EstimatedWait namespace).

When using the queue position number, the queue position is 0 if the agent capacity is greater than or equal to the number of customer requests. Otherwise, the position value represents how far the customer is from getting served by an agent.

1q = max(n - c, 0)

Where:

  • q is the queue position
  • n is the position of the customer compared to all waiting customers
  • c is the total capacity of all agents

For example, if the total capacity is 10, the first 10 waiting visitors have a position of 0, the 11th has a position of 1, the 12th has a position of 2, and so on.

Once you've fully configured the SCSChatConfiguration object, you can start the session using the startSession method.

Example

The following example configures a session with one pre-chat field and a visitor name "Jane Doe".

In Swift:

1let config = SCSChatConfiguration(liveAgentPod: "YOUR_POD_NAME",
2                                  orgId: "YOUR_ORG_ID",
3                                  deploymentId: "YOUR_DEPLOYMENT_ID",
4                                  buttonId: "YOUR_BUTTON_ID")
5
6// Set the visitor name
7config?.visitorName = "Jane Doe"
8
9// Change from queue position to estimated wait time
10config?.queueStyle = .estimatedWaitTime
11
12// Add a required email field (with an email keyboard and no auto-correction)
13let emailField = SCSPrechatTextInputObject(label: "Email")
14emailField?.isRequired = true
15emailField?.keyboardType = .emailAddress
16emailField?.autocorrectionType = .no
17config?.prechatFields.append(emailField!)

In Objective-C:

1SCSChatConfiguration *config =
2    [[SCSChatConfiguration alloc] initWithLiveAgentPod:@"YOUR_POD_NAME"
3                                                 orgId:@"YOUR_ORG_ID"
4                                          deploymentId:@"YOUR_DEPLOYMENT_ID"
5                                              buttonId:@"YOUR_BUTTON_ID"];
6
7// Set the visitor name
8config.visitorName = @"Jane Doe";
9
10// Change from queue position to estimated wait time
11config.queueStyle = SCSChatConfigurationQueueStyleEstimatedWaitTime;
12
13// Add a required email field (with an email keyboard and no auto-correction)
14SCSPrechatTextInputObject* emailField = [[SCSPrechatTextInputObject alloc] 
15                                         initWithLabel:@"Email"];
16emailField.required = YES;
17emailField.keyboardType = UIKeyboardTypeEmailAddress;
18emailField.autocorrectionType = UITextAutocorrectionTypeNo;
19[config.prechatFields addObject:emailField];