---
schema_version: "1"
id: 7945d3251d1e0ee71b6ea5b09006f8a3fce7af3d1761db68d0cf42dcc95b6e65
title: BotsAPI
collection: developer
version: current
locale: en-us
portal_url: https://docs.salesforce.com/developer/current/en-us/genai/agentforce-mobile-sdk/references/android/bots-api-android.md
canonical_url: https://developer.salesforce.com/docs/ai/agentforce-mobile-sdk/references/agentforce-mobile-sdk/bots-api-android.html
source_site: developer.salesforce.com
content_type: documentation
content_hash: b76c0d086bc0267681b87f7b735197d91eef362bbbedaf91508fa8f67298cf2e
products:
  - Agentforce Mobile SDK
  - Agentforce and Einstein Generative AI
---
# BotsAPI

`class BotsAPI`

Accesses the Bots API by sending user input and parsing the response.

## Signature

```kotlin
class BotsAPI(
    application: Application? = null,
    network: Network,
    logger: Logger? = null,
    instrumentationHandler: AgentforceInstrumentationHandler?
)
```

## Constructor

| Parameter              | Type                              | Description                              |
| ---------------------- | --------------------------------- | ---------------------------------------- |
| application            | Application?                      | Android application instance for context |
| network                | Network                           | Network interface for API communication  |
| logger                 | Logger?                           | Logging interface implementation         |
| instrumentationHandler | AgentforceInstrumentationHandler? | Analytics and performance monitoring     |

## Properties

| Property   | Type   | Description                 |
| ---------- | ------ | --------------------------- |
| BOT_ID     | String | Bot identifier constant     |
| SESSION_ID | String | Session identifier constant |

## Functions

### buildNetworkRequest

```kotlin
@VisibleForTesting
fun buildNetworkRequest(
    conversationRepresentation: ConversationInputRepresentation,
    queryParams: Map<String, Any> = emptyMap()
): NetworkRequest
```

### getAgents

```kotlin
suspend fun getAgents(mockSettings: MutableStateFlow<MockSettings>): AgentforceIdResponse
```

Retrieve the Bot id

### getFollowUpActions

```kotlin
suspend fun getFollowUpActions(
    followUpActionsListInputRepresentation: FollowUpActionsListInputRepresentation,
    mockSettings: MutableStateFlow<MockSettings>? = null
): FollowUpActionsListRepresentation
```

### getRecommendedUtterances

```kotlin
suspend fun getRecommendedUtterances(
    sessionId: String? = null,
    mockSettings: MutableStateFlow<MockSettings>? = null
): RecommendedUtterancesRepresentation
```

Get recommended utterances

### handleDecodeFailure

```kotlin
@VisibleForTesting
fun handleDecodeFailure(ex: Exception, message: String): Error
```

### handleNoDataFailure

```kotlin
@VisibleForTesting
fun handleNoDataFailure(message: String): Error
```

### logO11yFetchAgents

```kotlin
@VisibleForTesting
fun logO11yFetchAgents(startTime: Long, error: Throwable? = null)
```

Log O11Y_FETCH_AGENTS_MARKER perf o11y.

### logO11yPlannerBot

```kotlin
@VisibleForTesting
fun logO11yPlannerBot(startTime: Long?, error: Throwable? = null)
```

### setAdditionalContext

```kotlin
suspend fun setAdditionalContext(
    botId: String,
    sessionId: String?,
    inputRepresentation: ConversationInputRepresentation
): Result<Int>
```

Sends additional context to the Bots API

**Parameters:**

| Parameter           | Type                            | Description                                             |
| ------------------- | ------------------------------- | ------------------------------------------------------- |
| botId               | String                          | ID of the bot to request a response from                |
| sessionId           | String?                         | ID of the session that is being referenced by the input |
| inputRepresentation | ConversationInputRepresentation | ConversationInputRepresentation payload                 |

## Nested Types

### Companion

```kotlin
object Companion
```

Contains constants for BOT_ID and SESSION_ID.

## Related Documentation

- [AgentforceAPI](https://developer.salesforce.com/docs/ai/agentforce-mobile-sdk/references/android/agentforce-api-android.md) - General API interface for Agentforce services
- [AgentforceService](https://developer.salesforce.com/docs/ai/agentforce-mobile-sdk/references/agentforce-mobile-sdk/agentforce-service-android.md) - High-level service integration
- [AgentforceComponent](https://developer.salesforce.com/docs/ai/agentforce-mobile-sdk/references/android/agentforce-component-android.md) - UI component rendering system
