Interactive Voice Response (IVR)
Graph Communications Calling SDK and Core SDK can be used to make and manage IVR calls.
Features
- Join exiting calls
- Answer incoming calls
- Subscribe to tones
- Transfer call
- Play media
- Record
- Cancel media operations
Calling SDK Snippets
Join Existing Call and Answer Incoming Call
Please refer to the concept articles
Redirect and Transfer
In order to do a redirect or transfer, you need to create an invitation object.
This invitation target is the transferee in blind transfer and the original caller in consultative transfer.
var target = new InvitationParticipantInfo
{
Identity = new IdentitySet
{
User = new Identity {
Id = "**The Target's AAD ID**",
DisplayName = "**(optional) The Target's Display Name**",
}
}
};
ICall call = this.GetIncomingCall();
await call.RedirectAsync(new[] { target }).ConfigureAwait(false);
Blind transfer
To make a blind transfer, only the target needs to be specified.
ICall oritinalCall = this.Client.Calls()["*call id to transfer*"];
await oritinalCall.TransferAsync(target).ConfigureAwait(false);
Consultative transfer
ICall newCall = this.Client.Calls()["*call id of second call*"];
await newCall.TransferAsync(target, "*id of the original call*").ConfigureAwait(false);
Subscribe to tones
ICall call = this.Client.Calls()["*id of the call*"];
await call.SubscribeToToneAsync().ConfigureAwait(false);
Any tones that are received are sent as part of a call update in ToneInfo
property of the call resource.
Play media prompts
ICall call = this.Client.Calls()["*id of the call*"];
await call.PlayPromptAsync(*A list of media prompts to play*).ConfigureAwait(false);
Record
ICall call = this.Client.Calls()["*id of the call*"];
HttpClient httpClient = this.HttpClient;
RecordOperationResult result = await call.RecordAsync(*record options*).ConfigureAwait(false);
string location = result.RecordResourceLocation;
string token = result.RecordResourceAccessToken;
// Stream the content of the recording somewhere.
using (var outputStream = new MemoryStream())
using (var request = new HttpRequestMessage(HttpMethod.Get, new Uri(location)))
{
// Set the authorization header.
request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", token);
using(var response = await httpClient.SendAsync(request).ConfigureAwait(false))
using(var content = await response.Content.ReadAsStreamAsync().ConfigureAwait(false))
{
await content.CopyToAsync(outputStream);
outputStream?.Seek(0, SeekOrigin.Begin);
// Do something with stream.
}
}
Cancel media processing
This API will cancel all prompts that are queued to be played.
ICall call = this.Client.Calls()["*id of the call*"];
await call.CancelMediaProcessingAsync().ConfigureAwait(false);