Table of Contents

Class Voice

Namespace
Vonage.Applications.Capabilities
Assembly
Vonage.dll

Represents Voice capabilities.

public class Voice
Inheritance
Voice
Inherited Members

Constructors

Voice()

Initializes a new instance of the Voice capability.

public Voice()

Properties

ConversationsTimeToLive

The length of time named conversations will remain active for after creation, in hours. 0 means infinite. Maximum value is 744 (i.e. 31 days).

[JsonProperty("conversations_ttl", Order = 2)]
public int ConversationsTimeToLive { get; set; }

Property Value

int

LegPersistenceTime

The persistence duration for legs, in days. Maximum value is 31.

[JsonProperty("leg_persistence_time", Order = 4)]
public int LegPersistenceTime { get; set; }

Property Value

int

Region

Selecting a region means all inbound, programmable SIP and SIP connect calls will be sent to the selected region unless the call is sent to a regional endpoint, if the call is using a regional endpoint this will override the application setting.

[JsonProperty("region", Order = 3)]
public string Region { get; set; }

Property Value

string

SignedCallbacks

Whether to use signed webhooks. This is a way of verifying that the request is coming from Vonage. Refer to the Webhooks documentation for more information.

[JsonProperty("signed_callbacks", Order = 1)]
public bool SignedCallbacks { get; set; }

Property Value

bool

Webhooks

Represents the collection of Webhook URLs with their configuration.

[JsonProperty("webhooks")]
public IDictionary<VoiceWebhookType, Voice.VoiceWebhook> Webhooks { get; set; }

Property Value

IDictionary<VoiceWebhookType, Voice.VoiceWebhook>

Methods

Build()

Creates a new Voice capability builder for fluent configuration.

public static Voice Build()

Returns

Voice

A new Voice capability instance.

Examples

var voiceCapability = Voice.Build()
    .WithAnswerUrl("https://example.com/webhooks/answer", WebhookHttpMethod.Post)
    .WithEventUrl("https://example.com/webhooks/event", WebhookHttpMethod.Post);

DisableSignedCallbacks()

Disables signed callbacks.

public Voice DisableSignedCallbacks()

Returns

Voice

The Voice capability instance for fluent chaining.

Examples

var voice = Voice.Build().DisableSignedCallbacks();

EnableSignedCallbacks()

Enables signed callbacks to verify webhook requests are from Vonage.

public Voice EnableSignedCallbacks()

Returns

Voice

The Voice capability instance for fluent chaining.

Examples

var voice = Voice.Build().EnableSignedCallbacks();

WithAnswerUrl(string, WebhookHttpMethod, int, int)

Sets the answer URL webhook. Vonage makes a request to this URL when a call is placed or received. Must return an NCCO (Nexmo Call Control Object).

public Voice WithAnswerUrl(string url, WebhookHttpMethod method, int connectionTimeout = 1000, int socketTimeout = 500)

Parameters

url string

The webhook URL that will return the NCCO.

method WebhookHttpMethod

The HTTP method (GET or POST).

connectionTimeout int

Connection timeout in milliseconds (300-1000, default 1000).

socketTimeout int

Socket timeout in milliseconds (1000-5000, default 5000).

Returns

Voice

The Voice capability instance for fluent chaining.

Examples

var voice = Voice.Build()
    .WithAnswerUrl("https://example.com/webhooks/answer", WebhookHttpMethod.Get);

WithConversationsTimeToLive(int)

Sets the conversations time-to-live of a Voice application.

public Voice WithConversationsTimeToLive(int conversationTtl)

Parameters

conversationTtl int

The length of time named conversations will remain active for after creation, in hours. Maximum value is 9000 (i.e. 365 days).

Returns

Voice

The Voice capability instance for fluent chaining.

Examples

var voice = Voice.Build().WithConversationsTimeToLive(12);

WithEventUrl(string, WebhookHttpMethod, int, int)

Sets the event URL webhook. Vonage sends call events (e.g. ringing, answered) to this URL.

public Voice WithEventUrl(string url, WebhookHttpMethod method, int connectionTimeout = 1000, int socketTimeout = 500)

Parameters

url string

The webhook URL that will receive call events.

method WebhookHttpMethod

The HTTP method (GET or POST).

connectionTimeout int

Connection timeout in milliseconds (300-1000, default 1000).

socketTimeout int

Socket timeout in milliseconds (1000-10000, default 10000).

Returns

Voice

The Voice capability instance for fluent chaining.

Examples

var voice = Voice.Build()
    .WithEventUrl("https://example.com/webhooks/event", WebhookHttpMethod.Post);

WithFallbackAnswerUrl(string, WebhookHttpMethod, int, int)

Sets the fallback answer URL webhook. If the answer URL is offline or returns an HTTP error code, Vonage will make a request to this URL instead. Must return an NCCO.

public Voice WithFallbackAnswerUrl(string url, WebhookHttpMethod method, int connectionTimeout = 1000, int socketTimeout = 500)

Parameters

url string

The fallback webhook URL that will return the NCCO.

method WebhookHttpMethod

The HTTP method (GET or POST).

connectionTimeout int

Connection timeout in milliseconds (300-1000, default 1000).

socketTimeout int

Socket timeout in milliseconds (1000-5000, default 5000).

Returns

Voice

The Voice capability instance for fluent chaining.

Examples

var voice = Voice.Build()
    .WithAnswerUrl("https://example.com/webhooks/answer", WebhookHttpMethod.Get)
    .WithFallbackAnswerUrl("https://fallback.example.com/webhooks/answer", WebhookHttpMethod.Get);

WithLegPersistenceTime(int)

Sets the leg persistence time of a Voice application.

public Voice WithLegPersistenceTime(int legPersistenceTime)

Parameters

legPersistenceTime int

The persistence duration for legs, in days. Maximum value is 31.

Returns

Voice

The Voice capability instance for fluent chaining.

Examples

var voice = Voice.Build().WithLegPersistenceTime(10);

WithRegion(string)

Sets the region of a Voice application.

public Voice WithRegion(string region)

Parameters

region string

Selecting a region means all inbound, programmable SIP and SIP connect calls will be sent to the selected region unless the call is sent to a regional endpoint, if the call is using a regional endpoint this will override the application settings.

Returns

Voice

The Voice capability instance for fluent chaining.

Examples

var voice = Voice.Build().WithRegion("eu-west");