---
schema_version: "1"
id: bdcbe15a31e95de83f790ff25166b43585f4b48b81954a961e12465555435e5f
title: Understand the Structure of the Bot Client Interfaces
collection: developer
version: current
locale: en-us
portal_url: https://docs.salesforce.com/developer/current/en-us/bot-api/einstein-bot/guides/sdk/sdk-understand-the-structure.md
canonical_url: https://developer.salesforce.com/docs/service/einstein-bot-api/guide/sdk-understand-the-structure.html
source_site: developer.salesforce.com
content_type: documentation
content_hash: 00c7faa3dfc376ebb3e0de0985a7e08d7a0b106122c3e364df612a3c863f21ec
products:
  - Einstein Bots API and SDK
  - Enstein Bot API and SDK
---
# Understand the Structure of the Bot Client Interfaces

There are two interfaces of the bot client: `BasicChatbotClient` and `SessionManagedChatbotClient`.

With the `BasicChatbotClient` interface, there’s a separate method to start and continue the session. You track the session using the bot’s runtime session ID. To start a session, you provide an `ExternalSessionId` of an external channel, such as a Slack or Twitter thread, to `startChatSession()`. Then the bot generates a unique internal session ID, which you use as the `RuntimeSessionId`, to send subsequent messages or end the active session.

```java
// The basic bot client
public interface BasicChatbotClient {

  BotResponse startChatSession(RequestConfig config,
                               ExternalSessionId sessionId,
                               BotSendMessageRequest requestEnvelope);

  BotResponse sendMessage(RequestConfig config,
                          RuntimeSessionId sessionId,
                          BotSendMessageRequest requestEnvelope);

  BotResponse endChatSession(RequestConfig config,
                             RuntimeSessionId sessionId,
                             BotEndSessionRequest requestEnvelope);

  Status getHealthStatus()
}
```

The `SessionManagedChatbotClient` interface adds session management capabilities to the basic bot client. With the session-managed client, there’s no `startChatSession()` method and `RuntimeSessionId`. You start the session and send subsequent messages using the same method `sendMessage()`. You only need the `ExternalSessionId` since the client maps the external session ID to the internal one in the cache. For example, you could use a Slack thread ID to track all bot messages in a session without knowing the bot’s internal session ID.

```java

// The session-managed bot client
public interface SessionManagedChatbotClient {

  BotResponse sendMessage(RequestConfig config,
                          ExternalSessionId sessionId,
                          BotSendMessageRequest requestEnvelope);

  BotResponse endChatSession(RequestConfig config,
                             ExternalSessionId sessionId,
                             BotEndSessionRequest requestEnvelope);

  Status getHealthStatus()
}
```

Here are the features that both basic bot and session-managed clients share.

- The `RequestConfig` object contains the bot configuration variables.
- The `BotSendMessageRequest` object contains the message and message options to start and continue a session.
- The `BotEndSessionRequest` object contains the message to end the session.
- The return type is `BotResponse` for all session requests.
- The `getHealthStatus()` method returns the health status of the bot.
- To create an instance of either client, you require a runtime URL and authentication mechanism.

```java
// Create a basic bot client.
BasicChatbotClient client = ChatbotClients.basic()
    .basePath(YOUR_RUNTIME_URL)
    .authMechanism(YOUR_OAUTH_MECHANISM)
    .build();

// Create a session-managed client.
SessionManagedChatbotClient client = ChatbotClients
    .sessionManaged()
    .basicClient(ChatbotClients.basic()
        .basePath(YOUR_RUNTIME_URL)
        .authMechanism(YOUR_OAUTH_MECHANISM)
        .build())
    .cache(new RedisCache(YOUR_TTL_SECONDS,YOUR_REDIS_URL))
    .build();
```
