---
schema_version: "1"
id: f0f3ca62000745f3176e41ec53fb09a6818eae507624a47aa204ac7aaffcc9eb
title: Configure a Chat Session
collection: legacydeveloper
version: current
locale: en-us
portal_url: https://docs.salesforce.com/legacydeveloper/current/en-us/service_sdk_ios/configure_lac_session.md
canonical_url: https://developer.salesforce.com/docs/atlas.en-us.service_sdk_ios.meta/service_sdk_ios/configure_lac_session.htm
source_site: developer.salesforce.com
content_type: documentation
content_hash: d41371886f2ca020ef092857a5290fae480ebefe19caae383ec0f335ce75257b
description: 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.
---
# 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.

![Important](https://developer.salesforce.com/docs/atlas.en-us.service_sdk_ios.meta/service_sdk_ios/images/icon_note_important.png)

#### Important

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](https://help.salesforce.com/s/articleView?id=service.miaw_intro_landing.htm&type=5&language=en_US) before that date. Messaging offers many of the [chat features that you](https://help.salesforce.com/s/articleView?id=service.miaw_chat_vs_messaging.htm&type=5&language=en_US) love plus asynchronous conversations that can be picked back up at any time. Learn about chat retirement in [Help](https://help.salesforce.com/s/articleView?id=001790618&type=1&language=en_US).

When you start a chat session, you specify an [SCSChatConfiguration](https://forcedotcom.github.io/ServiceSDK-iOS/releases/api/234.1/Classes/SCSChatConfiguration.html) object as one of the arguments. This object contains all the configuration settings necessary for Chat to start a session. To create an [SCSChatConfiguration](https://forcedotcom.github.io/ServiceSDK-iOS/releases/api/234.1/Classes/SCSChatConfiguration.html) object, you specify information about your org and deployment.

In Swift:

let config = SCSChatConfiguration(liveAgentPod: "TO\_DO\_POD\_NAME",
                                  // e.g. "d.gla5.gus.salesforce.com"
                                  orgId: "TO\_DO\_ORG\_ID",
                                  // e.g. "00DB00000003Rxz"
                                  deploymentId: "TO\_DO\_DEPLOYMENT\_ID",
                                  // e.g. "573B00000005KXz"
                                  buttonId: "TO\_DO\_BUTTON\_ID")
                                  // e.g. "575C00000004h3m"

In Objective-C:

SCSChatConfiguration \*config =
  \[\[SCSChatConfiguration alloc\] initWithLiveAgentPod:@"TO\_DO\_POD\_NAME"
                                              // e.g. "d.gla5.gus.salesforce.com"
                                               orgId:@"TO\_DO\_ORG\_ID"
                                              // e.g. "00DB00000003Rxz"
                                        deploymentId:@"TO\_DO\_DEPLOYMENT\_ID"
                                              // e.g. "573B00000005KXz"
                                            buttonId:@"TO\_DO\_BUTTON\_ID"\];
                                              // e.g. "575C00000004h3m"

![Note](https://developer.salesforce.com/docs/atlas.en-us.service_sdk_ios.meta/service_sdk_ios/images/icon_note.png)

#### Note

You can get the required parameters for this method from your Salesforce org. See [Get Chat Settings from Your Org](https://developer.salesforce.com/docs/atlas.en-us.service_sdk_ios.meta/service_sdk_ios/live_agent_cloud_setup_get_settings.htm#live_agent_cloud_setup_get_settings "After you’ve set up chat in the console, supply your app developer with four values: the chat endpoint hostname, the organization ID, the deployment ID, and the button ID. You can get this information from your org’s setup."). 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](https://developer.salesforce.com/docs/atlas.en-us.service_sdk_ios.meta/service_sdk_ios/live_agent_cloud_setup.htm "Use the guided setup flow in Lightning Experience to add chat to your org.").

However, there are other options you can set using [SCSChatConfiguration](https://forcedotcom.github.io/ServiceSDK-iOS/releases/api/234.1/Classes/SCSChatConfiguration.html) 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 |

![Note](https://developer.salesforce.com/docs/atlas.en-us.service_sdk_ios.meta/service_sdk_ios/images/icon_note.png)

#### Note

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.

<table class="featureTable sort_table" summary="">
          <caption><span class="tablecap">Table 2. Background Configuration Settings</span></caption>



          <thead class="thead sorted" align="left">
            <tr>
              <th class="featureTableHeader  " id="d338e240">Property Name</th>

              <th class="featureTableHeader  " id="d338e243">Description</th>

              <th class="featureTableHeader  " id="d338e246">Type &amp; Default Value</th>

            </tr>

          </thead>

          <tbody class="tbody">
            <tr>
              <td class="entry" headers="d338e240" data-title="Property Name"><samp class="codeph java">allowBackgroundExecution</samp></td>

              <td class="entry" headers="d338e243" data-title="Description">Indicates whether to allow extended background execution to support active chat
                sessions. When <samp class="codeph java">true</samp>, active chat sessions can
                remain in the background for more than three minutes. See <samp class="codeph java">allowBackgroundNotifications</samp> for related functionality.</td>

              <td class="entry" headers="d338e246" data-title="Type &amp; Default Value">
                <samp class="codeph java">Bool</samp>: <samp class="codeph java">true</samp>/<samp class="codeph java">YES</samp>
              </td>

            </tr>

            <tr>
              <td class="entry" headers="d338e240" data-title="Property Name"><samp class="codeph java">allowBackgroundNotifications</samp></td>

              <td class="entry" headers="d338e243" data-title="Description">
                <p class="p">Indicates whether the session posts local notifications based on chat activity.
                  Requires that <samp class="codeph java">allowBackgroundExecution</samp> is also
                  set to <samp class="codeph java">true</samp>. To learn more, see <a class="xref" href="https://developer.salesforce.com/docs/atlas.en-us.service_sdk_ios.meta/service_sdk_ios/live_agent_notifications.htm#live_agent_notifications" title="If there's chat activity when the user is not viewing the chat session, you can present that information to them using the iOS notification system.">Notifications for Chat Activity</a>.</p>

              </td>

              <td class="entry" headers="d338e246" data-title="Type &amp; Default Value">
                <samp class="codeph java">Bool</samp>: <samp class="codeph java">true</samp>/<samp class="codeph java">YES</samp>
              </td>

            </tr>

          </tbody>

        </table>

![Note](https://developer.salesforce.com/docs/atlas.en-us.service_sdk_ios.meta/service_sdk_ios/images/icon_note.png)

#### Note

When turning on background execution, be sure that Idle Connection Timeout Duration is set in your org. To learn more, see [Chat Deployment Settings](https://help.salesforce.com/articleView?id=service.live_agent_deployment_settings.htm&type=5&language=en_US).

<table class="featureTable sort_table" summary="">
          <caption><span class="tablecap">Table 3. Pre-Chat Configuration Settings</span></caption>



          <thead class="thead sorted" align="left">
            <tr>
              <th class="featureTableHeader  " id="d338e351">Property Name</th>

              <th class="featureTableHeader  " id="d338e354">Description</th>

              <th class="featureTableHeader  " id="d338e357">Type &amp; Default Value</th>

            </tr>

          </thead>

          <tbody class="tbody">
            <tr>
              <td class="entry" headers="d338e351" data-title="Property Name"><a class="xref" href="https://forcedotcom.github.io/ServiceSDK-iOS/releases/api/234.1/Classes/SCSChatConfiguration.html#/c:objc(cs)SCSChatConfiguration(py)prechatEntities" target="_blank"><samp class="codeph java">prechatEntities</samp></a></td>

              <td class="entry" headers="d338e354" data-title="Description">
                <p class="p">Pre-chat fields are always sent to the agent at the start of the session. But if
                  you want to fill in fields of a particular record, instantiate an <a class="xref" href="https://forcedotcom.github.io/ServiceSDK-iOS/releases/api/234.1/Classes/SCSPrechatEntity.html" target="_blank"><samp class="codeph java">SCSPrechatEntity</samp></a> for each Salesforce object (for example,
                  <samp class="codeph java">Case</samp> or <samp class="codeph java">Contact</samp>) and instantiate an <a class="xref" href="https://forcedotcom.github.io/ServiceSDK-iOS/releases/api/234.1/Classes/SCSPrechatEntityField.html" target="_blank"><samp class="codeph java">SCSPrechatEntityField</samp></a> for each field association within that
                  Salesforce object (for example, <samp class="codeph java">Subject</samp> or
                  <samp class="codeph java">LastName</samp>).
                </p>

                <p class="p">To learn more, see <a class="xref" href="https://developer.salesforce.com/docs/atlas.en-us.service_sdk_ios.meta/service_sdk_ios/live_agent_send_custom_data.htm" title="When a chat session begins, you can create or find records within your org and pass this information to the agent. Using this technique, your agent can immediately have all the context they need for an effective chat session.">Create or Update Salesforce Records from a Chat Session</a>.</p>

              </td>

              <td class="entry" headers="d338e357" data-title="Type &amp; Default Value">
                <a class="xref" href="https://forcedotcom.github.io/ServiceSDK-iOS/releases/api/234.1/Classes/SCSPrechatEntity.html" target="_blank"><samp class="codeph java">SCSPrechatEntity</samp></a> array: <samp class="codeph java">nil</samp>
              </td>

            </tr>

            <tr>
              <td class="entry" headers="d338e351" data-title="Property Name">
                <p class="p"><a class="xref" href="https://forcedotcom.github.io/ServiceSDK-iOS/releases/api/234.1/Classes/SCSChatConfiguration.html#/c:objc(cs)SCSChatConfiguration(py)prechatFields" target="_blank"><samp class="codeph java">prechatFields</samp></a></p>

              </td>

              <td class="entry" headers="d338e354" data-title="Description">
                <p class="p"><span class="ph" id="prechat-description"><a name="prechat-description"><!-- --></a>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.</span></p>

                <p class="p">To create pre-chat fields, add <a class="xref" href="https://forcedotcom.github.io/ServiceSDK-iOS/releases/api/234.1/Classes/SCSPrechatObject.html" target="_blank"><samp class="codeph java">SCSPrechatObject</samp></a> instances to the <a class="xref" href="https://forcedotcom.github.io/ServiceSDK-iOS/releases/api/234.1/Classes/SCSChatConfiguration.html#/c:objc(cs)SCSChatConfiguration(py)prechatFields" target="_blank"><samp class="codeph java">prechatFields</samp></a> property on the <a class="xref" href="https://forcedotcom.github.io/ServiceSDK-iOS/releases/api/234.1/Classes/SCSChatConfiguration.html" target="_blank"><samp class="codeph java">SCSChatConfiguration</samp></a> object.</p>

                <p class="p">To learn more, see <a class="xref" href="https://developer.salesforce.com/docs/atlas.en-us.service_sdk_ios.meta/service_sdk_ios/live_agent_prechat_fields.htm#live_agent_prechat_fields" title="Before a chat session begins, you can request that the user enter pre-chat fields that are sent to the agent at the start of the session.">Show Pre-Chat Fields to User</a>.</p>

              </td>

              <td class="entry" headers="d338e357" data-title="Type &amp; Default Value">
                <a class="xref" href="https://forcedotcom.github.io/ServiceSDK-iOS/releases/api/234.1/Classes/SCSPrechatObject.html" target="_blank"><samp class="codeph java">SCSPrechatObject</samp></a> array: <samp class="codeph java">nil</samp>
              </td>

            </tr>

          </tbody>

        </table>

<table class="featureTable sort_table" summary="">
        <caption><span class="tablecap">Table 4. Other Configuration Settings</span></caption>



        <thead class="thead sorted" align="left">
          <tr>
            <th class="featureTableHeader  " id="d338e503">Property Name</th>

            <th class="featureTableHeader  " id="d338e506">Description</th>

            <th class="featureTableHeader  " id="d338e509">Type &amp; Default Value</th>

          </tr>

        </thead>

        <tbody class="tbody">
          <tr>
            <td class="entry" headers="d338e503" data-title="Property Name"><samp class="codeph nolang">eventList</samp></td>

            <td class="entry" headers="d338e506" data-title="Description">Adds a custom path that displays a custom tile and performs a custom action
              within your app. To learn more, see <a class="xref" href="https://developer.salesforce.com/docs/atlas.en-us.service_sdk_ios.meta/service_sdk_ios/chat_url_event.htm" title="Have your agents pass along custom URLs to perform specific actions in your mobile app.">Handle Custom URLs in Chat</a>.</td>

            <td class="entry" headers="d338e509" data-title="Type &amp; Default Value"><samp class="codeph java">SCSAppEventList</samp></td>

          </tr>

          <tr>
            <td class="entry" headers="d338e503" data-title="Property Name"><a class="xref" href="https://forcedotcom.github.io/ServiceSDK-iOS/releases/api/234.1/Classes/SCSChatConfiguration.html#/c:objc(cs)SCSChatConfiguration(py)queueStyle" target="_blank"><samp class="codeph java">queueStyle</samp></a></td>

            <td class="entry" headers="d338e506" data-title="Description">
              <p class="p">Determines the style of the queue. The queue can either display the queue position
                number (<samp class="codeph nolang">.position</samp>), the estimated wait time
                (<samp class="codeph nolang">.estimatedWaitTime</samp>), or no queue information
                at all (<samp class="codeph nolang">.none</samp>).</p>

              <p class="p">You can subscribe to queue position events using <a class="xref" href="https://forcedotcom.github.io/ServiceSDK-iOS/releases/api/234.1/Protocols/SCSChatSessionDelegate.html#/c:objc(pl)SCSChatSessionDelegate(im)session:didUpdateQueuePosition:estimatedWaitTime:" target="_blank"><samp class="codeph java">session(didUpdateQueuePosition:estimatedWaitTime:)</samp></a> on <a class="xref" href="https://forcedotcom.github.io/ServiceSDK-iOS/releases/api/234.1/Protocols/SCSChatSessionDelegate.html" target="_blank"><samp class="codeph java">SCSChatSessionDelegate</samp></a>. </p>

              <p class="p">When using the estimated wait time, the wait time is shown to the user in minutes.
                However, you can set the minimum (<a class="xref" href="https://forcedotcom.github.io/ServiceSDK-iOS/releases/api/234.1/Classes/SCSChatConfiguration.html#/c:objc(cs)SCSChatConfiguration(py)minimumEstimatedWaitTime" target="_blank"><samp class="codeph java">minimumEstimatedWaitTime</samp></a>) and maximum () wait time values. If
                the wait time exceeds the maximum value, a generic message appears, which <a class="xref" href="https://developer.salesforce.com/docs/atlas.en-us.service_sdk_ios.meta/service_sdk_ios/localization.htm" title="You can change the text used throughout the user interface. To customize text, create string resource values in a Localizable.strings file in the Localization bundle for the languages you want to update. Create string tokens that match the tokens you intend to override.">you can
                  customize</a> (using the customizable chat strings in the <samp class="codeph nolang">ServiceCloud.Chat.Status.EstimatedWait</samp> namespace).
                <span class="ph" id="ewt-xref"><a name="ewt-xref"><!-- --></a>To understand the algorithm used for the estimated wait time,
                  see the estimated wait time documentation in the <a class="xref" href="https://developer.salesforce.com/docs/atlas.en-us.260.0.live_agent_rest.meta/live_agent_rest/live_agent_rest_estimated_wait_time.htm" target="_blank">Chat REST API Developer Guide</a>.</span>
              </p>

              <p class="p" id="q-description-1"><a name="q-description-1"><!-- --></a>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.</p>

              <div class="p" id="q-description-2">
                <a name="q-description-2"><!-- --></a>
                <div class="codeSection java">
                  <pre class="codeblock java">q = max(n - c, <span class="number">0</span>)</pre>
                </div>

              </div>

              <p class="p" id="q-description-3"><a name="q-description-3"><!-- --></a>Where:</p>

              <div class="p" id="q-description-4">
                <a name="q-description-4"><!-- --></a>
                <ul class="ul bulletList">
                  <li class="li">q is the queue position</li>

                  <li class="li">n is the position of the customer compared to all waiting customers</li>

                  <li class="li">c is the total capacity of all agents</li>

                </ul>

              </div>

              <p class="p" id="q-description-5"><a name="q-description-5"><!-- --></a>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.</p>

            </td>

            <td class="entry" headers="d338e509" data-title="Type &amp; Default Value">
              <p class="p"><samp class="codeph java">SCSChatConfiguration</samp></p>

              <p class="p"><samp class="codeph java">QueueStyle</samp>: <samp class="codeph nolang">.position</samp></p>

            </td>

          </tr>

          <tr>
            <td class="entry" headers="d338e503" data-title="Property Name"><samp class="codeph java">remoteLoggingEnabled</samp></td>

            <td class="entry" headers="d338e506" data-title="Description">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.)</td>

            <td class="entry" headers="d338e509" data-title="Type &amp; Default Value">
              <samp class="codeph java">Bool</samp>: <samp class="codeph java">true</samp>/<samp class="codeph java">YES</samp>
            </td>

          </tr>

          <tr>
            <td class="entry" headers="d338e503" data-title="Property Name"><samp class="codeph java">visitorName</samp></td>

            <td class="entry" headers="d338e506" data-title="Description">Name of the chat visitor. This value is used by the Service Cloud console and
              displayed to the agent.</td>

            <td class="entry" headers="d338e509" data-title="Type &amp; Default Value">
              <samp class="codeph java">String</samp>: "<samp class="codeph java">Visitor</samp>"
            </td>

          </tr>

        </tbody>

      </table>

Once you've fully configured the [SCSChatConfiguration](https://forcedotcom.github.io/ServiceSDK-iOS/releases/api/234.1/Classes/SCSChatConfiguration.html) 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:

let config = SCSChatConfiguration(liveAgentPod: "YOUR\_POD\_NAME",
                                  orgId: "YOUR\_ORG\_ID",
                                  deploymentId: "YOUR\_DEPLOYMENT\_ID",
                                  buttonId: "YOUR\_BUTTON\_ID")

// Set the visitor name
config?.visitorName = "Jane Doe"

// Change from queue position to estimated wait time
config?.queueStyle = .estimatedWaitTime

// Add a required email field (with an email keyboard and no auto-correction)
let emailField = SCSPrechatTextInputObject(label: "Email")
emailField?.isRequired = true
emailField?.keyboardType = .emailAddress
emailField?.autocorrectionType = .no
config?.prechatFields.append(emailField!)

In Objective-C:

SCSChatConfiguration \*config =
    \[\[SCSChatConfiguration alloc\] initWithLiveAgentPod:@"YOUR\_POD\_NAME"
                                                 orgId:@"YOUR\_ORG\_ID"
                                          deploymentId:@"YOUR\_DEPLOYMENT\_ID"
                                              buttonId:@"YOUR\_BUTTON\_ID"\];

// Set the visitor name
config.visitorName = @"Jane Doe";

// Change from queue position to estimated wait time
config.queueStyle = SCSChatConfigurationQueueStyleEstimatedWaitTime;

// Add a required email field (with an email keyboard and no auto-correction)
SCSPrechatTextInputObject\* emailField = \[\[SCSPrechatTextInputObject alloc\] 
                                         initWithLabel:@"Email"\];
emailField.required = YES;
emailField.keyboardType = UIKeyboardTypeEmailAddress;
emailField.autocorrectionType = UITextAutocorrectionTypeNo;
\[config.prechatFields addObject:emailField\];