VOOZH about

URL: https://www.nuget.org/packages/Azure.Communication.CallAutomation

⇱ NuGet Gallery | Azure.Communication.CallAutomation 1.6.0




👁 Image
Azure.Communication.CallAutomation 1.6.0

Prefix Reserved
dotnet add package Azure.Communication.CallAutomation --version 1.6.0
 
 
NuGet\Install-Package Azure.Communication.CallAutomation -Version 1.6.0
 
 
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Azure.Communication.CallAutomation" Version="1.6.0" />
 
 
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Azure.Communication.CallAutomation" Version="1.6.0" />
 
Directory.Packages.props
<PackageReference Include="Azure.Communication.CallAutomation" />
 
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Azure.Communication.CallAutomation --version 1.6.0
 
 
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: Azure.Communication.CallAutomation, 1.6.0"
 
 
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Azure.Communication.CallAutomation@1.6.0
 
 
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Azure.Communication.CallAutomation&version=1.6.0
 
Install as a Cake Addin
#tool nuget:?package=Azure.Communication.CallAutomation&version=1.6.0
 
Install as a Cake Tool
The NuGet Team does not provide support for this client. Please contact its maintainers for support.

Azure Communication CallAutomation client library for .NET

This package contains a C# SDK for Azure Communication Call Automation.

Source code | Product documentation

Getting started

Install the package

Install the Azure Communication CallAutomation client library for .NET with NuGet:

dotnet add package Azure.Communication.CallAutomation

Prerequisites

You need an Azure subscription and a Communication Service Resource to use this package.

To create a new Communication Service, you can use the Azure Portal, the Azure PowerShell, or the .NET management client library.

Key concepts

CallAutomationClient provides the functionality to answer incoming call or initialize an outbound call.

Using statements

using Azure.Communication.CallAutomation;

Authenticate the client

Call Automation client can be authenticated using the connection string acquired from an Azure Communication Resource in the Azure Portal.

var connectionString = "<connection_string>"; // Find your Communication Services resource in the Azure portal
CallAutomationClient callAutomationClient = new CallAutomationClient(connectionString);

Or alternatively using a valid Active Directory token.

var endpoint = new Uri("https://my-resource.communication.azure.com");
TokenCredential tokenCredential = new DefaultAzureCredential();
var client = new CallAutomationClient(endpoint, tokenCredential);

Examples

Make a call to a phone number recipient

To make an outbound call, call the CreateCall or CreateCallAsync function from the CallAutomationClient.

CallInvite callInvite = new CallInvite(
 new PhoneNumberIdentifier("<targets-phone-number>"),
 new PhoneNumberIdentifier("<caller-id-phonenumber>")
 ); // E.164 formatted recipient phone number

// create call with above invitation
createCallResult = await callAutomationClient.CreateCallAsync(
 callInvite,
 new Uri("<YOUR-CALLBACK-URL>")
 );

Console.WriteLine($"Call connection id: {createCallResult.CallConnectionProperties.CallConnectionId}");

Handle Mid-Connection callback events

Your app will receive mid-connection callback events via the callbackEndpoint you provided. You will need to write event handler controller to receive the events and direct your app flow based on your business logic.

/// <summary>
/// Handle call back events.
/// </summary>>
[HttpPost]
[Route("/CallBackEvent")]
public IActionResult OnMidConnectionCallBackEvent([FromBody] CloudEvent[] events)
{
 try
 {
 if (events != null)
 {
 // Helper function to parse CloudEvent to a CallAutomation event.
 CallAutomationEventBase callBackEvent = CallAutomationEventParser.Parse(events.FirstOrDefault());

 switch (callBackEvent)
 {
 case CallConnected ev:
 # logic to handle a CallConnected event
 break;
 case CallDisconnected ev:
 # logic to handle a CallDisConnected event
 break;
 case ParticipantsUpdated ev:
 # cast the event into a ParticipantUpdated event and do something with it. Eg. iterate through the participants
 ParticipantsUpdated updatedEvent = (ParticipantsUpdated)ev;
 break;
 case AddParticipantsSucceeded ev:
 # logic to handle an AddParticipantsSucceeded event
 break;
 case AddParticipantsFailed ev:
 # logic to handle an AddParticipantsFailed event
 break;
 case CallTransferAccepted ev:
 # logic to handle CallTransferAccepted event
 break;
 case CallTransferFailed ev:
 # logic to handle CallTransferFailed event
 break;
 default:
 break;
 }
 }
 }
 catch (Exception ex)
 {
 // handle exception
 }
 return Ok();
}

Handle Mid-Connection events with CallAutomation's EventProcessor

To easily handle mid-connection events, Call Automation's SDK provides easier way to handle these events. Take a look at CallAutomationEventProcessor. this will ensure correlation between call and events more easily.

[HttpPost]
[Route("/CallBackEvent")]
public IActionResult OnMidConnectionCallBackEvent([FromBody] CloudEvent[] events)
{
 try
 {
 // process incoming event for EventProcessor
 _callAutomationClient.GetEventProcessor().ProcessEvents(cloudEvents);
 }
 catch (Exception ex)
 {
 // handle exception
 }
 return Ok();
}

ProcessEvents is required for EventProcessor to work. After event is being consumed by EventProcessor, you can start using its feature.

See below for example: where you are making a call with CreateCall, and wait for CallConnected event of the call.

CallInvite callInvite = new CallInvite(
 new PhoneNumberIdentifier("<targets-phone-number>"),
 new PhoneNumberIdentifier("<caller-id-phonenumber>")
 ); // E.164 formatted recipient phone number

// create call with above invitation
createCallResult = await callAutomationClient.CreateCallAsync(
 callInvite,
 new Uri("<YOUR-CALLBACK-URL>")
 );

// giving 30 seconds timeout for call reciever to answer
CancellationTokenSource cts = new CancellationTokenSource(TimeSpan.FromSeconds(30));
CancellationToken token = cts.Token;

try
{
 // this will wait until CreateCall is completed or Timesout!
 CreateCallEventResult eventResult = await createCallResult.WaitForEventAsync(token);

 // Once this is recieved, you know the call is now connected.
 CallConnected returnedEvent = eventResult.SuccessEvent;

 // ...Do more actions, such as Play or AddParticipant, since the call is established...
}
catch (OperationCanceledException ex)
{
 // Timeout exception happend!
 // Call likely was never answered.
}

If cancellation token was not passed with timeout, the default timeout is 4 minutes.

Troubleshooting

A RequestFailedException is thrown as a service response for any unsuccessful requests. The exception contains information about what response code was returned from the service.

Next steps

Contributing

This project welcomes contributions and suggestions. Most contributions require you to agree to a Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us the rights to use your contribution. For details, visit cla.microsoft.com.

This project has adopted the Microsoft Open Source Code of Conduct. For more information see the Code of Conduct FAQ or contact with any additional questions or comments.

Product Versions Compatible and additional computed target framework versions.
.NET net5.0 net5.0 was computed.  net5.0-windows net5.0-windows was computed.  net6.0 net6.0 was computed.  net6.0-android net6.0-android was computed.  net6.0-ios net6.0-ios was computed.  net6.0-maccatalyst net6.0-maccatalyst was computed.  net6.0-macos net6.0-macos was computed.  net6.0-tvos net6.0-tvos was computed.  net6.0-windows net6.0-windows was computed.  net7.0 net7.0 was computed.  net7.0-android net7.0-android was computed.  net7.0-ios net7.0-ios was computed.  net7.0-maccatalyst net7.0-maccatalyst was computed.  net7.0-macos net7.0-macos was computed.  net7.0-tvos net7.0-tvos was computed.  net7.0-windows net7.0-windows was computed.  net8.0 net8.0 is compatible.  net8.0-android net8.0-android was computed.  net8.0-browser net8.0-browser was computed.  net8.0-ios net8.0-ios was computed.  net8.0-maccatalyst net8.0-maccatalyst was computed.  net8.0-macos net8.0-macos was computed.  net8.0-tvos net8.0-tvos was computed.  net8.0-windows net8.0-windows was computed.  net9.0 net9.0 was computed.  net9.0-android net9.0-android was computed.  net9.0-browser net9.0-browser was computed.  net9.0-ios net9.0-ios was computed.  net9.0-maccatalyst net9.0-maccatalyst was computed.  net9.0-macos net9.0-macos was computed.  net9.0-tvos net9.0-tvos was computed.  net9.0-windows net9.0-windows was computed.  net10.0 net10.0 is compatible.  net10.0-android net10.0-android was computed.  net10.0-browser net10.0-browser was computed.  net10.0-ios net10.0-ios was computed.  net10.0-maccatalyst net10.0-maccatalyst was computed.  net10.0-macos net10.0-macos was computed.  net10.0-tvos net10.0-tvos was computed.  net10.0-windows net10.0-windows was computed. 
.NET Core netcoreapp2.0 netcoreapp2.0 was computed.  netcoreapp2.1 netcoreapp2.1 was computed.  netcoreapp2.2 netcoreapp2.2 was computed.  netcoreapp3.0 netcoreapp3.0 was computed.  netcoreapp3.1 netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 netstandard2.0 is compatible.  netstandard2.1 netstandard2.1 was computed. 
.NET Framework net461 net461 was computed.  net462 net462 was computed.  net463 net463 was computed.  net47 net47 was computed.  net471 net471 was computed.  net472 net472 was computed.  net48 net48 was computed.  net481 net481 was computed. 
MonoAndroid monoandroid monoandroid was computed. 
MonoMac monomac monomac was computed. 
MonoTouch monotouch monotouch was computed. 
Tizen tizen40 tizen40 was computed.  tizen60 tizen60 was computed. 
Xamarin.iOS xamarinios xamarinios was computed. 
Xamarin.Mac xamarinmac xamarinmac was computed. 
Xamarin.TVOS xamarintvos xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories (2)

Showing the top 2 popular GitHub repositories that depend on Azure.Communication.CallAutomation:

Repository Stars
Azure-Samples/communication-services-AI-customer-service-sample
A sample app for the customer support center running in Azure, using Azure Communication Services and Azure OpenAI for text and voice bots.
Azure-Samples/communication-services-dotnet-quickstarts
Sample code for Azure Communication Services .Net quickstarts
Version Downloads Last Updated
1.6.0 0 6/18/2026
1.6.0-beta.2 2,410 2/3/2026
1.6.0-beta.1 2,335 8/26/2025
1.5.1 47,042 1/29/2026
1.5.0 57,165 8/25/2025
1.5.0-beta.1 21,443 5/19/2025
1.4.1 8,525 7/23/2025
1.4.0 38,784 6/4/2025
1.4.0-beta.2 7,251 1/31/2025
1.4.0-beta.1 12,456 11/23/2024
1.3.0 121,821 11/23/2024
1.3.0-beta.2 987 10/28/2024
1.3.0-beta.1 12,119 8/5/2024
1.2.0 79,358 5/1/2024
1.1.0 23,055 11/23/2023
1.1.0-beta.1 22,786 8/17/2023
1.0.0 23,333 6/16/2023
1.0.0-beta.1 8,847 11/5/2022