---
schema_version: "1"
id: 2c91502331f44d748b3f9f58e93ad7aff547c9fa30e06a40e2ba747de45dcae5
title: Build Your Own UI with the Chat Core API
collection: developer
version: current
locale: en-us
portal_url: https://docs.salesforce.com/developer/current/en-us/service-cloud/service-sdk-ios/guides/live-agent-chat-core-api.md
canonical_url: https://developer.salesforce.com/docs/service/service-sdk-ios/guide/live-agent-chat-core-api.html
source_site: developer.salesforce.com
content_type: documentation
content_hash: d3f24488ec07de12301d6dd4b5ea21c3ed43a796ddb5d2eb1d326b9fc902d977
products:
  - Embedded Service Chat SDK for iOS Developer Guide
  - Service Cloud Developer Content
---

# Build Your Own UI with the Chat Core API

With the Chat Core API, you can access the functionality of Chat without a UI. This API is useful if you want to build your own UI and not use the default.

## Before You Begin

**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) before that date. Messaging offers many of the [chat features](https://help.salesforce.com/s/articleView?id=service.miaw_chat_vs_messaging.htm&type=5) that you 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).

Before running through these steps, be sure you’ve already:

- Set up Service Cloud to work with Chat. To learn more, see [Org Setup for Chat in Lightning Experience with a Guided Flow](https://developer.salesforce.com/docs/service/service-sdk-android/guides/shared/live-agent-cloud-setup.md).
- Installed the SDK. To learn more, see [Install the Service Chat SDK for iOS](https://developer.salesforce.com/docs/service/service-sdk-ios/guide/ios-sdk-install-overview.md).

Once you’ve reviewed these prerequisites, you’re ready to begin.

These steps describe how to use the Chat Core API with your own custom UI. To use the default UI, see [Quick Setup: Chat in the Service Chat SDK](https://developer.salesforce.com/docs/service/service-sdk-ios/guide/live-agent-basic-setup.md).

1.  Import the SDK. Wherever you intend to use the Chat SDK, be sure to import the ServiceCore framework and the ServiceChat framework.

    In Swift:

    ```java
    import ServiceCore
    import ServiceChat
    ```

    In Objective-C:

    ```java
    @import ServiceCore;
    @import ServiceChat;
    ```

2.  Create an [`SCSChatConfiguration`](https://forcedotcom.github.io/ServiceSDK-iOS/releases/api/234.1/Classes/SCSChatConfiguration.html) object.

    In Swift:

    ```java
    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:

    ```java
    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"
    ```

    See [Configure a Chat Session](https://developer.salesforce.com/docs/service/service-sdk-ios/guide/configure-lac-session.md) on how to configure a chat session.

3.  Implement [`SCSChatSessionDelegate`](https://forcedotcom.github.io/ServiceSDK-iOS/releases/api/234.1/Protocols/SCSChatSessionDelegate.html) and handle the relevant session-related methods.

    Using this delegate, you can:

    - Detect state transitions with [`session(didTransitionFrom:to:)`](https://developer.salesforce.com/docs/service/service-sdk-ios/guide/%3Chttps://forcedotcom.github.io/ServiceSDK-iOS/releases/api/234.1/Protocols/SCSChatSessionDelegate.html#/c:objc(pl)SCSChatSessionDelegate(im)session:didTransitionFromState:toState:>).
    - Detect the end of the session with [`session(didEnd:)`](https://developer.salesforce.com/docs/service/service-sdk-ios/guide/%3Chttps://forcedotcom.github.io/ServiceSDK-iOS/releases/api/234.1/Protocols/SCSChatSessionDelegate.html#/c:objc(pl)SCSChatSessionDelegate(im)session:didEnd:>).
    - Detect error conditions with [`session(didError:fatal:)`](https://developer.salesforce.com/docs/service/service-sdk-ios/guide/%3Chttps://forcedotcom.github.io/ServiceSDK-iOS/releases/api/234.1/Protocols/SCSChatSessionDelegate.html#/c:objc(pl)SCSChatSessionDelegate(im)session:didError:fatal:>).
    - Detect queue state changes with [`session(didUpdateQueuePosition:estimatedWaitTime:)`](https://developer.salesforce.com/docs/service/service-sdk-ios/guide/%3Chttps://forcedotcom.github.io/ServiceSDK-iOS/releases/api/234.1/Protocols/SCSChatSessionDelegate.html#/c:objc(pl)SCSChatSessionDelegate(im)session:didUpdateQueuePosition:estimatedWaitTime:>).
      Pass your implementation to the [`SCSChat`](https://forcedotcom.github.io/ServiceSDK-iOS/releases/api/234.1/Classes/SCSChat.html) instance.

    In Swift:

    ```java
    ServiceCloud.shared().chatCore.add(delegate: mySessionDelegate)
    ```

    In Objective-C:

    ```java
    [[SCServiceCloud sharedInstance].chatCore addDelegate:mySessionDelegate];
    ```

    To learn more, see [Listen for State Changes and Events](https://developer.salesforce.com/docs/service/service-sdk-ios/guide/live-agent-listen-to-events.md).

4.  Implement [`SCSChatEventDelegate`](https://forcedotcom.github.io/ServiceSDK-iOS/releases/api/234.1/Protocols/SCSChatEventDelegate.html) and handle the relevant event-related methods.

    Using this delegate, you can:

    - Detect when an agent joins with [`session(agentJoined:)`](https://developer.salesforce.com/docs/service/service-sdk-ios/guide/%3Chttps://forcedotcom.github.io/ServiceSDK-iOS/releases/api/234.1/Protocols/SCSChatEventDelegate.html#/c:objc(pl)SCSChatEventDelegate(im)session:agentJoined:>).
    - Detect when an agent leaves with [`session(agentLeftConference:)`](https://developer.salesforce.com/docs/service/service-sdk-ios/guide/%3Chttps://forcedotcom.github.io/ServiceSDK-iOS/releases/api/234.1/Protocols/SCSChatEventDelegate.html#/c:objc(pl)SCSChatEventDelegate(im)session:agentLeftConference:>).
    - Detect when an outgoing message is sent with [`session(processedOutgoingMessage:)`](https://developer.salesforce.com/docs/service/service-sdk-ios/guide/%3Chttps://forcedotcom.github.io/ServiceSDK-iOS/releases/api/234.1/Protocols/SCSChatEventDelegate.html#/c:objc(pl)SCSChatEventDelegate(im)session:processedOutgoingMessage:>).
    - Detect when the delivery status of a message has been updated with [`session(didUpdateOutgoingMessageDeliveryStatus:)`](https://developer.salesforce.com/docs/service/service-sdk-ios/guide/%3Chttps://forcedotcom.github.io/ServiceSDK-iOS/releases/api/234.1/Protocols/SCSChatEventDelegate.html#/c:objc(pl)SCSChatEventDelegate(im)session:didUpdateOutgoingMessageDeliveryStatus:>).
    - Detect when an incoming message arrives with [`session(didReceiveMessage:)`](https://developer.salesforce.com/docs/service/service-sdk-ios/guide/%3Chttps://forcedotcom.github.io/ServiceSDK-iOS/releases/api/234.1/Protocols/SCSChatEventDelegate.html#/c:objc(pl)SCSChatEventDelegate(im)session:didReceiveMessage:>).
    - Detects when a URL is found in an message with [`session(didReceiveURL:)`](https://developer.salesforce.com/docs/service/service-sdk-ios/guide/%3Chttps://forcedotcom.github.io/ServiceSDK-iOS/releases/api/234.1/Protocols/SCSChatEventDelegate.html#/c:objc(pl)SCSChatEventDelegate(im)session:didReceiveURL:>).
    - Detect when a chat bot menu arrives with [`session(didReceiveChatBotMenu:)`](https://developer.salesforce.com/docs/service/service-sdk-ios/guide/%3Chttps://forcedotcom.github.io/ServiceSDK-iOS/releases/api/234.1/Protocols/SCSChatEventDelegate.html#/c:objc(pl)SCSChatEventDelegate(im)session:didReceiveChatBotMenu:>).
    - Detect when a chat bot menu item is selected with [`session(didSelectMenuItem:)`](https://developer.salesforce.com/docs/service/service-sdk-ios/guide/%3Chttps://forcedotcom.github.io/ServiceSDK-iOS/releases/api/234.1/Protocols/SCSChatEventDelegate.html#/c:objc(pl)SCSChatEventDelegate(im)session:didSelectMenuItem:>).
    - Detect when the agent starts and finishes typing.
    - Detect events related to the file transfer process.
    - Detects when the user is transferred to an agent from a chat bot.
      Pass your implementation to the [`SCSChat`](https://forcedotcom.github.io/ServiceSDK-iOS/releases/api/234.1/Classes/SCSChat.html) instance.

    In Swift:

    ```java
    ServiceCloud.shared().chatCore.addEvent(delegate: myEventDelegate)
    ```

    In Objective-C:

    ```java
    [[SCServiceCloud sharedInstance].chatCore addEventDelegate:myEventDelegate];
    ```

5.  Start the session using `startSession(with:)` on [`SCSChat`](https://forcedotcom.github.io/ServiceSDK-iOS/releases/api/234.1/Classes/SCSChat.html).

    In Swift:

    ```java
    ServiceCloud.shared().chatCore.startSession(config)
    ```

    In Objective-C:

    ```java
    [[SCServiceCloud sharedInstance].chatCore startSessionWithConfiguration:config];
    ```

6.  Send activity to the [`SCSChatSession`](https://forcedotcom.github.io/ServiceSDK-iOS/releases/api/234.1/Protocols/SCSChatSession.html) object found in [`SCSChat`](https://forcedotcom.github.io/ServiceSDK-iOS/releases/api/234.1/Classes/SCSChat.html).

    You can access the session object either from the `SCSChat.session` property, or from any of your delegate event methods that the SDK calls.

    With this session object, you can:

    - Send sneak peek data about the user's message to the agent with `sendSneakPeek`.
    - Send a message to the agent with `sendMessage`.
    - Get or set the user's typing status with `userTyping`.
    - Get information about the actors in the chat session with `actors`.
    - Get the history of all events from the chat session with `allEvents`.
    - Get the current queue position when the user is waiting for an agent with `queuePosition`.
