项目作者: cmdotcom

项目描述 :
SDK for use with the CM VoiceAPI
高级语言: C#
项目地址: git://github.com/cmdotcom/talk-sdk-dotnet.git
创建时间: 2018-06-25T07:01:57Z
项目社区:https://github.com/cmdotcom/talk-sdk-dotnet

开源协议:MIT License

下载


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

  1. var httpClient = new HttpClient();
  2. 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.

  1. var instruction = new NotificationInstruction
  2. {
  3. Caller = "+1234567890",
  4. Callee = "+9876543210",
  5. Prompt = "This is a test call."
  6. };

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.

  1. 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