---
schema_version: "1"
id: 09b0b3b33ecb0934cddbfa48194c7e835022fbdd12ca8e15804ec6457f09ce48
title: Set Up Agentforce Voice for Android
collection: developer
version: current
locale: en-us
portal_url: https://docs.salesforce.com/developer/current/en-us/genai/agentforce-mobile-sdk/guides/android/agentforce-mobile-sdk-android-voice.md
canonical_url: https://developer.salesforce.com/docs/ai/agentforce-mobile-sdk/guide/agentforce-mobile-sdk-android-voice.html
source_site: developer.salesforce.com
content_type: documentation
content_hash: 177babef410608daa38f1eee6719672c90b2d917eb9041e1981b0fb70f75c622
products:
  - Agentforce Mobile SDK
  - Agentforce and Einstein Generative AI
---
# Set Up Agentforce Voice for Android

Agentforce Voice lets you build voice-enabled agents that manage complex conversations in real time. Set up Agentforce Voice for your Android mobile app with these steps.

## Before You Begin

Before you set up Agentforce Voice for your mobile app, create and configure a voice-enabled service agent in Agentforce Studio.

- [Create a Voice-Enabled Service Agent in Agentforce Studio](https://help.salesforce.com/s/articleView?id=ai.service_agent_voice.htm&type=5)

Voice settings are configured at the agent level and apply across all supported connections.

## Choose a Connection Path

The Agentforce Mobile SDK supports two connection paths for voice. Choose based on your requirements. Both paths require `enableVoice: true` in your SDK feature flags, configured in the next section.

|                        | Agent API (Telephony)                           | Enhanced Chat v2 (Service Cloud)                           |
| ---------------------- | ----------------------------------------------- | ---------------------------------------------------------- |
| **Setup**              | Add a Telephony connection in Agentforce Studio | Create an Embedded Service Deployment with an ECv2 channel |
| **Human escalation**   | Not supported                                   | Supported — agent can hand off to a live agent             |
| **Transcript logging** | Not available                                   | Available through Service Cloud                            |
| **Routing**            | Direct to agent                                 | Omni-Channel routing with queue fallback                   |
| **Voice mode UI**      | Always available when voice is enabled          | Appears after the agent joins the session                  |

### Agent API (Telephony Connection)

Use this path for a lightweight integration that gets voice running with minimal server-side configuration. In Agentforce Studio, add a Telephony connection to your service agent to unlock voice settings. This "Agent API" refers to the mobile SDK's internal connection to the agent — it's not the same as the [Agentforce Agent API](/docs/ai/agentforce/guide/agent-api-get-started.html) used for headless server-to-server integrations. This path doesn't require a full Service Cloud Voice telephony setup. It just activates the agent-level voice configuration for use with the mobile SDK.

1. In Agentforce Studio, open your service agent.
2. Go to **Connections** and click **Add**.
3. Select **Telephone** and save.
4. Configure voice settings (voice persona, language) in the agent's voice settings panel.

### Enhanced Chat v2 (Service Cloud Connection)

This path enables richer capabilities including human escalation and transcript logging. It requires an Embedded Service Deployment with an ECv2 channel that has voice enabled.

1. In Agentforce Studio, open your service agent.
2. Go to **Connections** and click **Add**.
3. Select **Enhanced Chat V2**, then save and activate.
4. Go to the ECv2 connection's **Routing** section and create a new channel.
5. In the channel settings, select **Allow Voice in Enhanced Chat** and publish.
6. Create a Mobile Embedded Service Deployment using that channel.

For the ECv2 path, use the Service API URL and ES Developer Name from your Embedded Service Deployment when configuring the SDK. See [Before You Begin](https://developer.salesforce.com/docs/ai/agentforce-mobile-sdk/agentforce-mobile-sdk-before-you-begin.md#configure-for-service-agent) for where to find these values.

For more information, see [Connect a Service Agent to Enhanced Chat v2](https://help.salesforce.com/s/articleView?id=release-notes.rn_einstein_agentforce_ecv2_voice.htm&release=262&type=5).

After configuring your connection path, install the voice module and set up the client below. The SDK configuration is the same regardless of which path you chose.

## Install the Agentforce Voice Module

Starting with SDK version 260.4, Agentforce Voice is a separate optional module. To use Agentforce Voice, add the `agentforce-sdk-voice` dependency to your `build.gradle` file alongside the core SDK.

```groovy
// Core SDK (required)
implementation("com.salesforce.android:agentforce-sdk:15.x.x")

// Voice support (optional) — includes Agentforce Voice native libs
implementation("com.salesforce.android:agentforce-sdk-voice:15.x.x")
```

Then, register the voice module in your configuration:

```kotlin
.setAgentforceVoiceModule(AgentforceVoiceProviderFactory(), AgentforceVoiceUIProvider())
```

If you don't use Agentforce Voice, no changes are needed — voice is no longer bundled with the core SDK by default.

## Create the AgentforceClient

To enable Agentforce Voice for Android in your `AgentforceConfiguration`, use `setFeatureFlagSettings`.

```kotlin
// Sample configuration
val agentforceConfiguration = AgentforceConfiguration.builder(
    authCredentialProvider = object : AgentforceAuthCredentialProvider {
        override fun getAuthCredentials(): AgentforceAuthCredentials {
            return AgentforceAuthCredentials.Guest(
                settingsManager.voiceForceConfigEndpoint.value
            )
        }
    }
)
.setApplication(this.application)

// Set Connection Info
.setConnectionInfo(
    AgentforceConnectionInfo(
        sfapUrl = settingsManager.voiceSfapURL.value
    )
)

// Enable the Voice feature flag(s)
.setFeatureFlagSettings(
    AgentforceFeatureFlagSettings.builder()
        .enableVoice(true) // Enable the voice flag
        .enableMultiModalInput(enableMultiModal) // Optional flags
        .build()
)
```

To set your permissions manager, use `setPermission`.

```kotlin
.setPermission(AgentforceDefaultPermissions(this.activity))
```

To set your voice manager, use `setVoiceManaging`.

```kotlin
.setVoiceManaging(AgentforceVoiceManaging())
.build()
```

To initialize the AgentforceClient, use the configuration object you created.

```kotlin
// Create your client object
val agentforceClient = AgentforceClient()

// Initialize the client
agentforceClient.init(
    authCredentialProvider =
        agentforceConfiguration.authCredentialProvider,
    agentforceMode =
        AgentforceMode.FullConfig(agentforceConfiguration),
    application = this.application
)

// Get the AgentforceConversation
val agentforceConversation =
    agentforceClient.startAgentforceConversation(agentId)
```

To wire the permission manager in your app, add `handlePermissionResult` from `AgentforceDefaultPermissions`.

```kotlin
// In your activity, add handlePermissionResult
// from AgentforceDefaultPermissions

override fun onRequestPermissionsResult(
    requestCode: Int,
    permissions: Array<out String?>,
    grantResults: IntArray,
    deviceId: Int
) {
   super.onRequestPermissionsResult(
       requestCode, permissions, grantResults, deviceId
   )
   AgentforceDefaultPermissions.handlePermissionResult(
       requestCode, permissions, grantResults
   )
}
```

## Create a Voice-Enabled Chat Container

To create a chat container with voice enabled, pass `agentforceConversation` into the `AgentforceConversationContainer`.

```kotlin
agentforceClient.AgentforceConversationContainer(agentforceConversation)
```

## Closed Captions and Agent Responses

In voice mode, the agent responds audibly, and the written response is intentionally hidden when closed captions are off. Turning closed captions on displays the live transcript of the agent's response. Closed captions default to off, so users tap the closed-caption control to turn them on.

**note:** If the agent's written response appears to be missing during a voice conversation, that's expected behavior when closed captions are off—it's not a bug. The response is still delivered audibly, and enabling closed captions shows the transcript. Agent responses always remain visible in the standard chat interface.
