You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In this quickstart, you'll learn how to build an application that uses the Azure Communication Services Call Automation SDK to handle the following scenario:
22
22
- handling the `IncomingCall` event from Event Grid
23
23
- answering a call
24
-
- playing an audio file
24
+
- playing an audio file and recognising input(DTMF) from caller
25
25
- adding a communication user to the call such as a customer service agent who uses a web application built using Calling SDKs to connect to Azure Communication Services
26
26
27
27
::: zone pivot="programming-language-csharp"
@@ -32,13 +32,28 @@ In this quickstart, you'll learn how to build an application that uses the Azure
32
32
[!INCLUDE [Call flows for customer interactions with Java](./includes/call-automation/Callflow-for-customer-interactions-java.md)]
33
33
::: zone-end
34
34
35
+
# Subscribe to IncomingCall event
36
+
37
+
IncomingCall is an Azure Event Grid event for notifying incoming calls to your Communication Services resource. To learn more about it, see [this guide](../../concepts/voice-video-calling/incoming-call-notification.md).
38
+
1. Navigate to your resource on Azure portal and select `Events` from the left side menu.
39
+
1. Select `+ Event Subscription` to create a new subscription.
40
+
1. Filter for Incoming Call event.
41
+
1. Choose endpoint type as web hook and provide the public url generated for your application by ngrok. Make sure to provide the exact api route that you programmed to receive the event previously. In this case, it would be <ngrok_url>/api/incomingCall.
42
+

43
+
44
+
1. Select create to start the creation of subscription and validation of your endpoint as mentioned previously. The subscription is ready when the provisioning status is marked as succeeded.
45
+
46
+
This subscription currently has no filters and hence all incoming calls will be sent to your application. To filter for specific phone number or a communication user, use the Filters tab.
47
+
35
48
## Testing the application
36
49
37
-
1. Place a call to the number you acquired in the Azure portal (see prerequisites above).
38
-
2. Your Event Grid subscription to the `IncomingCall` should execute and call your web server.
39
-
3. The call will be answered, and an asynchronous web hook callback will be sent to the NGROK callback URI.
40
-
4. When the call is connected, a `CallConnected` event will be sent to your web server, wrapped in a `CloudEvent` schema and can be easily deserialized using the Call Automation SDK parser. At this point, the application will request audio to be played and input from a targeted phone number.
41
-
5. When the input has been received and recognized, the web server will make a request to add a participant to the call.
50
+
1. Place a call to the number you acquired in the Azure portal.
51
+
2. Your Event Grid subscription to the `IncomingCall` should execute and call your application which will request to answer the call.
52
+
3. When the call is connected, a `CallConnected` event will be sent to your application's callback url. At this point, the application will request audio to be played and to receive input from the caller.
53
+
4. From your phone, press any 3 number keys, or press one number key and then # key.
54
+
5. When the input has been received and recognized, the application will make a request to add a participant to the call.
55
+
6. Once the added user answers, you can talk to them.
Copy file name to clipboardExpand all lines: articles/communication-services/quickstarts/voice-video-calling/includes/call-automation/callflow-for-customer-interactions-csharp.md
+30-63Lines changed: 30 additions & 63 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -15,41 +15,39 @@ ms.author: askaur
15
15
## Prerequisites
16
16
17
17
- An Azure account with an active subscription.
18
-
-A Communication Service resource.
19
-
-[Acquire a phone number for your Communication Service resource](../../../telephony/get-phone-number.md?pivots=programming-language-csharp).
18
+
-Azure Communication Services resource. See [Create an Azure Communication Services resource](../../../create-communication-resource.md?tabs=windows&pivots=platform-azp). Note the resource connection string for this quickstart by navigating to your resource selecting 'Keys' from the left side menu.
19
+
-[Acquire a phone number for your Communication Service resource](../../../telephony/get-phone-number.md?pivots=programming-language-csharp). Note the phone number you acquired for use in this quickstart.
20
20
- The latest [.NET library](https://dotnet.microsoft.com/download/dotnet-core) for your operating system. .NET 6.0 or higher is recommended as this quickstart uses the minimal API feature.
21
+
- An audio file for the message you want to play in the call. This audio should be accessible via a url.
21
22
22
23
## Create a new C# application
23
24
24
25
In the console window of your operating system, use the `dotnet` command to create a new web application.
25
-
26
26
```console
27
27
dotnet new web -n MyApplication
28
28
```
29
29
30
-
## Configure NuGet package manager
31
-
32
-
During the preview phase, the `Azure.Communication.CallAutomation` NuGet package can be obtained by configuring your package manager to use the Azure SDK Dev Feed from [here](https://github.com/Azure/azure-sdk-for-net/blob/main/CONTRIBUTING.md#nuget-package-dev-feed)
33
-
34
-
## Install required NuGet packages
35
-
36
-
Install the following NuGet packages to your project using the `dotnot add <package>` command.
1. Configure NuGet Package Manager to use dev feed: During the preview phase, the CallAutomation package is published to the dev feed. Configure your package manager to use the Azure SDK Dev Feed from [here](https://github.com/Azure/azure-sdk-for-net/blob/main/CONTRIBUTING.md#nuget-package-dev-feed).
2. Install the NuGet packages: [Azure.Communication.CallAutomation](https://dev.azure.com/azure-sdk/public/_artifacts/feed/azure-sdk-for-net/NuGet/Azure.Communication.CallAutomation/versions/) and [Azure.Messaging.EventGrid](https://dev.azure.com/azure-sdk/public/_artifacts/feed/azure-sdk-for-net/NuGet/Azure.Messaging.EventGrid/versions/) to your project.
In this quick-start, you'll use [Ngrok tool](https://ngrok.com/) to project a public URI to the local port so that your local application can be visited by the internet. The public URI is needed to receive the Event Grid `IncomingCall` event and Call Automation events using webhooks.
43
42
44
-
From the Azure portal, locate your Communication Service resource.
43
+
First, determine the port of the .NET application. Minimal API dynamically allocates a port for the project at the time of creation. Find out the http port in <PROJECT_ROOT>\Properties\launchSettings.json.
44
+
:::image type="content" source="./../../media/call-automation/dotnet-application-port.jpg" alt-text="Screenshot of demo application's launchsetting.json file":::
45
45
46
-
1. Select on the Keys section to obtain your connection string.
47
-
:::image type="content" source="./../../media/call-automation/Key.png" alt-text="Screenshot of Communication Services resource page on portal to access keys":::
48
-
2. Then select on the Phone numbers section to obtain your ACS phone number.
46
+
Then, [install Ngrok](https://ngrok.com/download) and run Ngrok with the following command: `ngrok http <port>`. This command will create a public URI like `https://ff2f-75-155-253-232.ngrok.io/`, and it is your Ngrok Fully Qualified Domain Name(Ngrok_FQDN). Keep Ngrok running while following the rest of this quick-start.
49
47
50
48
## Update Program.cs
51
49
52
-
Using the minimal API feature in .NET 6, we can easily add an HTTP POST map and answer the call. A callback URI is required so the service knows how to contact your web server for subsequent calls state events such as `CallConnected` and `PlayCompleted`.
50
+
Using the minimal API feature in .NET 6, we can easily add an HTTP POST map and answer the call. A callback URI is required so the service knows how to contact your application for subsequent calls state events such as `CallConnected` and `PlayCompleted`.
53
51
54
52
In this code snippet, /api/incomingCall is the default route that will be used to listen for and answer incoming calls. At a later step, you'll register this url with Event Grid. Since Event Grid requires you to prove ownership of your Webhook endpoint before it starts delivering events to that endpoint, the code sample also handles this one time validation by processing SubscriptionValidationEvent. This requirement prevents a malicious user from flooding your endpoint with events. For more information, see this [guide](../../../../../event-grid/webhook-event-delivery.md).
In this quick-start, you'll use [Ngrok tool](https://ngrok.com/) to project a public URI to the local port so that your local application can be visited by the internet. The public URI is needed to receive the Event Grid `IncomingCall` event and Call Automation events using webhooks.
148
-
149
-
First, determine the port of the .NET application. Minimal API dynamically allocates a port for the project at the time of creation. Find out the http port in <PROJECT_ROOT>\Properties\launchSettings.json.
150
-
:::image type="content" source="./../../media/call-automation/dotnet-application-port.jpg" alt-text="Screenshot of demo application's launchsetting.json file":::
151
-
152
-
Then, [install Ngrok](https://ngrok.com/download) and run Ngrok with the following command: `ngrok http <port>`. This command will create a public URI like `https://ff2f-75-155-253-232.ngrok.io/`, and it is your Ngrok Fully Qualified Domain Name(Ngrok_FQDN). Keep Ngrok running while following the rest of this quick-start.
153
-
154
-
## Set up environment variables
155
-
156
-
In Visual Studio, right click at your project and then select "Manage User Secrets" to configure confidential environment variables.
157
-
158
-
:::image type="content" source="./../../media/call-automation/dotnet-user-secret.jpg" alt-text="Screenshot of how to find out 'Manage User Secrets'":::
159
-
160
-
Read more about Secret Manager at [Safe storage of app secrets in development in ASP.NET Core](https://learn.microsoft.com/aspnet/core/security/app-secrets)
ParticipantToAdd used in the code snippet is assumed to be an ACS User MRI.
174
-
144
+
Replace the placeholders with the actual values in lines 12-16. In your production code, we recommend using [Secret Manager](https://learn.microsoft.com/aspnet/core/security/app-secrets) for storing sensitive information like this.
145
+
175
146
## Run the app
176
147
177
148
Open Your_Project_Name.csproj file in your project with Visual Studio, and then select Run button or press F5 on your keyboard.
178
-
179
-
## Set up IncomingCall event
180
-
181
-
IncomingCall is an Azure Event Grid event for notifying incoming calls to your Communication Services resource, like the phone number purchased in pre-requisites. Follow [this guide](../../../../how-tos/call-automation-sdk/subscribe-to-incoming-call.md) to set up your IncomingCall event.
0 commit comments