Skip to content

Commit 613a268

Browse files
committed
Simplify instructions
1 parent cbd9add commit 613a268

File tree

6 files changed

+74
-111
lines changed

6 files changed

+74
-111
lines changed

articles/communication-services/quickstarts/voice-video-calling/callflows-for-customer-interactions.md

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ zone_pivot_groups: acs-csharp-java
2121
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:
2222
- handling the `IncomingCall` event from Event Grid
2323
- answering a call
24-
- playing an audio file
24+
- playing an audio file and recognising input(DTMF) from caller
2525
- 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
2626

2727
::: zone pivot="programming-language-csharp"
@@ -32,13 +32,28 @@ In this quickstart, you'll learn how to build an application that uses the Azure
3232
[!INCLUDE [Call flows for customer interactions with Java](./includes/call-automation/Callflow-for-customer-interactions-java.md)]
3333
::: zone-end
3434

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+
![Screenshot of portal page to create a new event subscription.](./media/call-automation//event-susbcription.png)
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+
3548
## Testing the application
3649

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.
56+
4257

4358
## Clean up resources
4459

articles/communication-services/quickstarts/voice-video-calling/includes/call-automation/callflow-for-customer-interactions-csharp.md

Lines changed: 30 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -15,41 +15,39 @@ ms.author: askaur
1515
## Prerequisites
1616

1717
- 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.
2020
- 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.
2122

2223
## Create a new C# application
2324

2425
In the console window of your operating system, use the `dotnet` command to create a new web application.
25-
2626
```console
2727
dotnet new web -n MyApplication
2828
```
2929

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.
30+
## Install required packages
3731

38-
*Azure.Communication.CallAutomation* - [Package details](https://dev.azure.com/azure-sdk/public/_artifacts/feed/azure-sdk-for-net/NuGet/Azure.Communication.CallAutomation/versions/)
32+
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).
3933

40-
*Azure.Messaging.EventGrid* - [Package details](https://dev.azure.com/azure-sdk/public/_artifacts/feed/azure-sdk-for-net/NuGet/Azure.Messaging.EventGrid/versions/)
34+
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.
35+
```console
36+
dotnet add <path-to-project> package Azure.Communication.CallAutomation --prerelease
37+
dotnet add <path-to-project> package Azure.Messaging.EventGrid --prerelease
38+
```
39+
## Set up a public URI for the local application
4140

42-
## Obtain your connection string and phone number
41+
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.
4342

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":::
4545

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

5048
## Update Program.cs
5149

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`.
5351

5452
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).
5553

@@ -67,8 +65,11 @@ using System.Text.Json.Nodes;
6765

6866
var builder = WebApplication.CreateBuilder(args);
6967

70-
var client = new CallAutomationClient(builder.Configuration["ConnectionString"]);
71-
var callbackUriBase = builder.Configuration["callbackUriBase"]; // i.e. https://someguid.ngrok.io
68+
var client = new CallAutomationClient("<resource_connection_string"); //noted from pre-requisite step
69+
var callbackUriBase = "<public_url_generated_by_ngrok>";
70+
var mediaFileSource = new Uri("<link_to_media_file>");
71+
var applicationPhoneNumber = "<phone_number_acquired_as_prerequisite>";
72+
var phoneNumberToAddToCall = "<phone_number_to_add_to_call>"; //in format of +1...
7273
7374
var app = builder.Build();
7475
app.MapPost("/api/incomingCall", async (
@@ -116,7 +117,7 @@ app.MapPost("/api/calls/{contextId}", async (
116117
InterruptPrompt = true,
117118
InterToneTimeout = TimeSpan.FromSeconds(10),
118119
InitialSilenceTimeout = TimeSpan.FromSeconds(5),
119-
Prompt = new FileSource(new Uri(builder.Configuration["MediaSource"])),
120+
Prompt = new FileSource(mediaFileSource),
120121
StopTones = new[] { DtmfTone.Pound },
121122
OperationContext = "MainMenu"
122123
};
@@ -127,55 +128,21 @@ app.MapPost("/api/calls/{contextId}", async (
127128
if (@event is RecognizeCompleted { OperationContext: "MainMenu" })
128129
{
129130
// this RecognizeCompleted correlates to the previous action as per the OperationContext value
130-
await client.GetCallConnection(@event.CallConnectionId)
131-
.AddParticipantsAsync(new AddParticipantsOptions(
132-
new List<CommunicationIdentifier>()
133-
{
134-
new CommunicationUserIdentifier(builder.Configuration["ParticipantToAdd"])
135-
})
136-
);
131+
var addThisPerson = new PhoneNumberIdentifier(phoneNumberToAddToCall);
132+
var listOfPersonToBeAdded = new List<CommunicationIdentifier>();
133+
listOfPersonToBeAdded.Add(addThisPerson);
134+
var addParticipantsOption = new AddParticipantsOptions(listOfPersonToBeAdded);
135+
addParticipantsOption.SourceCallerId = new PhoneNumberIdentifier(applicationPhoneNumber);
136+
AddParticipantsResult result = await client.GetCallConnection(@event.CallConnectionId).AddParticipantsAsync(addParticipantsOption);
137137
}
138138
}
139139
return Results.Ok();
140140
}).Produces(StatusCodes.Status200OK);
141141

142142
app.Run();
143143
```
144-
145-
## Set up a public URI for the local application
146-
147-
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)
161-
162-
``` json
163-
{
164-
...
165-
"ConnectionString": "Your_ACS_resource_connection_string",
166-
"CallbackUriBase": "Your_Ngrok_FQDN",
167-
"MediaSource": "Link_to_media_file_for_play_prompt",
168-
"ParticipantToAdd": "The_participant_to_be_added_after_recognizing_tones"
169-
...
170-
}
171-
```
172-
173-
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+
175146
## Run the app
176147

177148
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

Comments
 (0)