# VoiceConversationBuilderExtensions

> Tracon documentation. Tracon is a .NET package family that adds a control
> plane on Microsoft Agent Framework, published as NuGet packages that run
> inside your own ASP.NET Core application.
>
> Page: https://tracon.dev/api/tracon.voiceconversationbuilderextensions/
> Summary: VoiceConversationBuilderExtensions: Extensions that enable the real-time voice conversation layer.

<div class="api-provenance">Namespace Tracon · Assembly <code>Tracon.Core.dll</code></div>

Extensions that enable the real-time voice conversation layer.

```csharp
public static class VoiceConversationBuilderExtensions
```

<dl class="api-relations"><dt>Inheritance</dt><dd><a href="https://learn.microsoft.com/dotnet/api/system.object">object</a> ← <a href="/api/tracon.voiceconversationbuilderextensions/">VoiceConversationBuilderExtensions</a></dd><dt>Inherited Members</dt><dd><a href="https://learn.microsoft.com/dotnet/api/system.object.gettype">object.GetType()</a>, <a href="https://learn.microsoft.com/dotnet/api/system.object.memberwiseclone">object.MemberwiseClone()</a>, <a href="https://learn.microsoft.com/dotnet/api/system.object.tostring">object.ToString()</a>, <a href="https://learn.microsoft.com/dotnet/api/system.object.equals#system-object-equals(system-object)">object.Equals(object?)</a>, <a href="https://learn.microsoft.com/dotnet/api/system.object.equals#system-object-equals(system-object-system-object)">object.Equals(object?, object?)</a>, <a href="https://learn.microsoft.com/dotnet/api/system.object.referenceequals">object.ReferenceEquals(object?, object?)</a>, <a href="https://learn.microsoft.com/dotnet/api/system.object.gethashcode">object.GetHashCode()</a></dd></dl>

## Remarks

**This call changes the hosting model.** A voice
connection stays open for minutes and binds to *one* server
instance; a multi-instance deployment requires sticky sessions, and the
reverse proxy must allow WebSocket passthrough. For this reason the
feature is opt-in: if the call is not made, no WebSocket endpoint is
opened and behavior does not change.

The layer is **provider-agnostic**: it uses only the
[ISpeechTranscriber](/api/tracon.ispeechtranscriber/) and [ISpeechSynthesizer](/api/tracon.ispeechsynthesizer/)
abstractions. This call does *not* register them — a voice
provider must be enabled separately (e.g. `UseVoice(...)`).

## Methods

### <a id="Tracon_VoiceConversationBuilderExtensions_UseVoiceConversation_Tracon_ITraconBuilder_Microsoft_Extensions_Configuration_IConfiguration_"></a> UseVoiceConversation\(ITraconBuilder, IConfiguration\)

Enables the conversation layer, reading its settings from configuration.

```csharp
public static ITraconBuilder UseVoiceConversation(this ITraconBuilder builder, IConfiguration configurationSection)
```

#### Parameters

`builder` [ITraconBuilder](/api/tracon.itraconbuilder/)

The Tracon chain.

`configurationSection` [IConfiguration](https://learn.microsoft.com/dotnet/api/microsoft.extensions.configuration.iconfiguration)

The `Tracon:Voice:Conversation` section.

#### Returns

 [ITraconBuilder](/api/tracon.itraconbuilder/)

The continuation of the chain.

#### Remarks

A speech provider is registered separately; this call only opens the
conversation layer over it.

```csharp
builder.AddTracon()
       .UseVoice(builder.Configuration.GetSection("Tracon:Voice"))
       .UseVoiceConversation(builder.Configuration.GetSection("Tracon:Voice:Conversation"));
```

#### Exceptions

 [ArgumentNullException](https://learn.microsoft.com/dotnet/api/system.argumentnullexception)

One of the dependencies is [null](https://learn.microsoft.com/dotnet/csharp/language-reference/keywords/null).

### <a id="Tracon_VoiceConversationBuilderExtensions_UseVoiceConversation_Tracon_ITraconBuilder_"></a> UseVoiceConversation\(ITraconBuilder\)

Enables the conversation layer with default settings.

```csharp
public static ITraconBuilder UseVoiceConversation(this ITraconBuilder builder)
```

#### Parameters

`builder` [ITraconBuilder](/api/tracon.itraconbuilder/)

The Tracon chain.

#### Returns

 [ITraconBuilder](/api/tracon.itraconbuilder/)

The continuation of the chain.

#### Remarks

Registrations are made with `TryAdd*`: if the consumer registered
its own [IVoiceSessionStore](/api/tracon.ivoicesessionstore/) implementation before this
call, theirs is preserved.

The transcription and synthesis providers are resolved *optionally*
with ``ServiceProviderServiceExtensions.GetService```.
Requesting a nullable dependency through constructor injection is not
enough: the built-in DI container can treat an unregistered type as
required even when a C# default value exists.
This is why a factory is used.

#### Exceptions

 [ArgumentNullException](https://learn.microsoft.com/dotnet/api/system.argumentnullexception)

`builder` is [null](https://learn.microsoft.com/dotnet/csharp/language-reference/keywords/null).

### <a id="Tracon_VoiceConversationBuilderExtensions_UseVoiceConversation_Tracon_ITraconBuilder_System_Action_Tracon_VoiceConversationOptions__"></a> UseVoiceConversation\(ITraconBuilder, Action<VoiceConversationOptions\>\)

Enables the conversation layer with settings given in code.

```csharp
public static ITraconBuilder UseVoiceConversation(this ITraconBuilder builder, Action<VoiceConversationOptions> configure)
```

#### Parameters

`builder` [ITraconBuilder](/api/tracon.itraconbuilder/)

The Tracon chain.

`configure` [Action](https://learn.microsoft.com/dotnet/api/system.action\-1)<[VoiceConversationOptions](/api/tracon.voiceconversationoptions/)\>

The settings.

#### Returns

 [ITraconBuilder](/api/tracon.itraconbuilder/)

The continuation of the chain.

#### Exceptions

 [ArgumentNullException](https://learn.microsoft.com/dotnet/api/system.argumentnullexception)

One of the parameters is [null](https://learn.microsoft.com/dotnet/csharp/language-reference/keywords/null).
