C# / .NET SDK
The official C# SDK for the Vobiz Voice API. Make outbound calls, manage SIP trunks, handle phone numbers, and construct programmatic XML workflows natively within .NET Core / .NET 8 applications.
Source Code: vobiz-ai/Vobiz-Csharp-sdk
Installation
Clone the SDK source into your solution directly:
git clone https://github.com/vobiz-ai/Vobiz-Csharp-sdk.git
cd Vobiz-Csharp-sdk
dotnet buildAuthentication
The .NET SDK utilizes standard Dependency Injection (DI) to map your Auth credentials properly into the container host.
using Microsoft.Extensions.Hosting;
using Vobiz.Client;
using Vobiz.Extensions;
var host = Host.CreateDefaultBuilder(args)
.ConfigureApi((context, services, options) =>
{
options.AddTokens(new ApiKeyToken("YOUR_AUTH_ID", ClientUtils.ApiKeyHeader.X_Auth_ID, ""));
options.AddTokens(new ApiKeyToken("YOUR_AUTH_TOKEN", ClientUtils.ApiKeyHeader.X_Auth_Token, ""));
})
.Build();Quick Start (Account Fetching)
Interacting with resources natively requires requesting instances from the host.Services component map. The example below demonstrates fetching your platform limits and details. For real-time call controls, you would inject the ICallApi interface instead, passing your webhook URLs to orchestrate outbound dial states.
using Microsoft.Extensions.DependencyInjection;
using Vobiz.Api;
var accountApi = host.Services.GetRequiredService<IAccountApi>();
var me = await accountApi.ApiV1AuthMeGetAsync(
xAuthID: "YOUR_AUTH_ID",
xAuthToken: "YOUR_AUTH_TOKEN",
contentType: "application/json"
);
Console.WriteLine(me.StatusCode);VobizXML Module
The SDK includes a fluent XML builder under Vobiz.Xml natively mapped to our official schema types. Because it uses a fluent syntax, you can cleanly chain together complex multi-step responses (like answering > prompting > collecting digits > hanging up) seamlessly within your API controllers and return the generated ToString() payload.
using Vobiz.Xml;
var response = new ResponseElement()
.AddSpeak("Welcome to Vobiz.", voice: "WOMAN", language: "en-US")
.AddWait(length: 2)
.AddHangup();
var xml = response.ToString(pretty: true);
Console.WriteLine(xml);Core Resources
The C# mappings utilize rigorous `host.Services` injections to navigate discrete resources efficiently across ASP.NET Core environments, ensuring strongly-typed safety natively.
Queued Network Polling
var callApi = host.Services.GetRequiredService<ICallApi>();
// Await the queued outbound limits natively resolving as strong typed lists
var response = await callApi.ApiV1AccountAuthIdCallGetAsync(
authId: "YOUR_AUTH_ID",
xAuthID: "YOUR_AUTH_ID",
xAuthToken: "YOUR_AUTH_TOKEN",
contentType: "application/json",
status: "queued"
);
Console.WriteLine(response.StatusCode);Gather Input Orchestration
using Vobiz.Xml;
var gather = new GatherElement(
action: "https://example.com/gather",
method: "POST",
inputType: "speech",
executionTimeout: 15
).AddSpeak("Say sales or support").AddPlay("https://example.com/menu.mp3");
var response = new ResponseElement().Add(gather);
Console.WriteLine(response.ToString(false));