To build your own UI for Kustomer Chat and the Knowledge Base, you can use the Kustomer Core SDK. The Core SDK gives you access to all the data, events, and methods available for our built-in UI.
The Kustomer Core SDK exposes APIs in the form of provider interfaces that allow you to create your own UI and send information into Kustomer APIs.
This guide shows you how to use the Kustomer Core SDK to build your won mobile chat and knowledge base UI for iOS.
Guide: Access the knowledge base π
Visit [Access the Knowledge Base](πο»Ώ) to learn how to work with the knowledge base with the Kustomer Core SDK.
Guide: Work with conversational assistants π
Visit [Work with conversational assistants (chatbots)](πο»Ώ) to learn how to work with the conversational assistants with the Kustomer Core SDK.
## Prerequisites
Before you get started, you'll need the following:
A valid API key with just the `
org.tracking
` role. See [Requirements](πο»Ώ)ο»ΏChat SDK installation. To learn more, see [Installation](πο»Ώ).
## Overview
To build your own UI with the Kustomer Core SDK, you will need to do the following:
Configure Kustomer in your AppDelegate with options
Access the `Kustomer.chatProvider' instance
Implement listeners with `
KUSChatListener
`
## Step 1: Configure Kustomer Chat in your AppDelegate with options
First, configure Kustomer Chat in your AppDelegate and pass in `enableUI = false
`.
## Step 2: Access the `Kustomer.chatProvider' instance
After you configure Kustomer, create a reference to the `Kustomer.chatProvider
` instance anywhere in your application.
You can call different methods of the `Kustomer.chatProvider
` to receive events, create messages, and more. Also see the [Provider callbacks](πο»Ώ) section.
`
Kustomer.chatProvider
` methodsVisit [the Core API reference](πο»Ώ) for a full list of provider methods.
## Step 3: Implement listeners with `KUSChatListener
`
After you create a `Kustomer.chatProvider
` reference in your application, implement the `KUSChatListener
` protocol in one of your classes. You can pass an instance of this class to the provider to take actions for events such as when users receive messages, conversations close, and more.
### Get recent data
A list of conversations or messages for a given conversation ID can be fetched asynchronously.
We've included an example of how to fetch conversations, and then fetch the messages for the first conversation.
In order to actually receive events in your chat listeners, you need to tell the Kustomer client to start up and go online.
### Receive events in listeners
To receive events in chat listeners, use `Kustomer.start()
` either before or after you attach listeners.
### Stop events
You can stop Kustomer to block network events from listeners or to prevent any internet connection use.
### Restart events
After you stop Kustomer, you can restart Kustomer at any time. Restart Kustomer to replay all chat listener events you missed while offline.
### Automatic retry for events
Kustomer automatically stops when there are internet connection problems. The Core SDK uses an automatic retry scheme (similar to [Alamofire](πο»Ώ)), and Kustomer will not stop right away if the internet connection goes down.
You can attach a listener to receive notifications when Kustomer stops due to internet connection problems.
### Provider callbacks
All `ChatProvider
` provider methods have callbacks that let you know if the request was successful.
You can use `ChatProvider
` to call methods that send data to the Kustomer platform (for example, send a new chat message).
Data only appears in the listeners and data cache after you successfully send data (for example, a new message or a request to close a conversation).
### Suggested pattern
We've provided a suggested pattern that shows how to ensure the variable `data
` always has every chat message for a specific conversation based on the conversation id.
In the code examples below, we use a conversation with a conversation id of `100
`.
**For a listener in a class:**
**For a listener in an AppDelegate class:**
Authentication
If you are using [Kustomer's Authentication](πο»Ώ) it's recommended that you complete the authentication process BEFORE calling the `
Kustomer.start()
` method. This will ensure that the authenticated customer's historical messages are loaded when `Kustomer.start()
` is called.