Skip to content

Latest commit

 

History

History
53 lines (36 loc) · 2.34 KB

README.md

File metadata and controls

53 lines (36 loc) · 2.34 KB

Build Test NuGetV NuGetDownloads

VoiceApiSdk

SDK for use with the CM VoiceAPI

API Documentation

https://docs.cmtelecom.com/voice-api-apps/v2.0

Usage

Instantiate a client

var httpClient = new HttpClient();
var voiceApiClient = new VoiceApiClient(httpClient, myApiKey);

httpClient is requested as a parameter, such that you can use a single instance throughout your application, as is highly recommended. Ideally you would have it injected by Dependency Injection.

myApiKey is your unique api key (or product token) which authorizes you on the CM platform. Always keep this key secret!

Send an instruction

Before we can send an instruction, we need to create one.

var instruction = new NotificationInstruction
{
    Caller = "+1234567890",
    Callee = "+9876543210",
    Prompt = "This is a test call."
};

This is an example Notification instruction, which will simply call the Callee while showing the Caller. When picked up, it will read the prompt using the default voice (en-GB, Female, nr. 1) and hang up.

The other instructions are the OtpInstruction (for sending a One Time Password) and the RequestDtmfInstruction (for calling and requesting numerical input from the callee). More information on the various fields and their uses can be found in the docs (https://docs.cmtelecom.com/voice-api-apps/v2.0), as well as the list of possible voices.

To send the instruction, simply call SendAsync() on the client and the call should take place shortly after.

var result = await voiceApiClient.SendAsync(instruction).ConfigureAwait(false);

Finally, the result will have a HttpStatusCode, Content (as string), a boolean indicating Success and a call DeserializeEvent() to Deserialize the result into a CallQueuedEvent