Skip to content

Commit 1619f88

Browse files
authored
Merge pull request #14 from valindrae/ca-ai-1
tidy up docs
2 parents fc1e988 + d487dfb commit 1619f88

11 files changed

+97
-341
lines changed

articles/communication-services/concepts/call-automation/azure-communication-services-azure-cognitive-services-integration.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ ms.subservice: call-automation
88
ms.topic: include
99
ms.date: 02/15/2023
1010
ms.author: kpunjabi
11-
ms.custom: private_preview
1211
ms.custom: references_regions
1312
services: azure-communication-services
1413
---
-55.4 KB
Loading
-25 KB
Loading
-56.6 KB
Loading
-27.4 KB
Loading

articles/communication-services/how-tos/call-automation/includes/play-audio-with-ai-csharp.md

Lines changed: 43 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -150,27 +150,36 @@ Assert.AreEqual(202, playResponse.Status) // The request was accepted.
150150

151151
Your application receives action lifecycle event updates on the callback URL that was provided to Call Automation service at the time of answering the call. An example of a successful play event update.
152152

153-
```json
154-
[{
155-
"id": "704a7a96-4d74-4ebe-9cd0-b7cc39c3d7b1",
156-
"source": "calling/callConnections/<callConnectionId>/PlayCompleted",
157-
"type": "Microsoft.Communication.PlayCompleted",
158-
"data": {
159-
"resultInfo": {
160-
"code": 200,
161-
"subCode": 0,
162-
"message": "Action completed successfully."
163-
},
164-
"type": "playCompleted",
165-
"callConnectionId": "<callConnectionId>",
166-
"serverCallId": "<serverCallId>",
167-
"correlationId": "<correlationId>"
168-
},
169-
"time": "2022-08-12T03:13:25.0252763+00:00",
170-
"specversion": "1.0",
171-
"datacontenttype": "application/json",
172-
"subject": "calling/callConnections/<callConnectionId>/PlayCompleted"
173-
}]
153+
### Example of how you can deserialize the *PlayCompleted* event:
154+
155+
``` csharp
156+
if (@event is PlayCompleted { OperationContext: "PlayAudio" })
157+
{
158+
var playCompletedEvent = (PlayCompleted)@event;
159+
160+
if (ReasonCode.CompletedSuccessfully.Equals(playCompletedEvent.ReasonCode))
161+
{
162+
//Play audio succeeded, take action on success.
163+
await callConnection.HangUpAsync(forEveryone: true);
164+
}
165+
}
166+
```
167+
168+
### Example of how you can deserialize the *PlayFailed* event:
169+
170+
``` csharp
171+
if (@event is PlayFailed { OperationContext: "PlayAudio" })
172+
{
173+
var playFailedEvent = (PlayFailed)@event;
174+
175+
if (ReasonCode.PlayDownloadFailed.Equals(playFailedEvent.ReasonCode) ||
176+
ReasonCode.PlayInvalidFileFormat.Equals(playFailedEvent.ReasonCode))
177+
{
178+
//Play audio failed, Take some action on failed event.
179+
logger.LogInformation($"PlayFailed event received for call connection id: {@event.CallConnectionId}");
180+
await callConnection.HangUpAsync(forEveryone: true);
181+
}
182+
}
174183
```
175184

176185
To learn more about other supported events, visit the [Call Automation overview document](../../../concepts/call-automation/call-automation.md#call-automation-webhook-events).
@@ -184,3 +193,16 @@ var callMedia = callAutomationClient.GetCallConnection(<callConnectionId>).GetCa
184193
var cancelResponse = await callMedia.CancelAllMediaOperations();
185194
Assert.AreEqual(202, cancelResponse.Status) // The request was accepted.
186195
```
196+
197+
### Example of how you can deserialize the *PlayCanceled* event:
198+
199+
``` csharp
200+
if (@event is PlayCanceled { OperationContext: "PlayAudio" })
201+
{
202+
var playFailedEvent = (PlayCanceled)@event;
203+
204+
logger.LogInformation($"PlayCanceled event received for call connection id: {@event.CallConnectionId}");
205+
//Take action on recognize canceled operation
206+
await callConnection.HangUpAsync(forEveryone: true);
207+
}
208+
```

articles/communication-services/how-tos/call-automation/includes/play-audio-with-ai-java.md

Lines changed: 38 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -71,12 +71,7 @@ You can test creating your own audio file using our [Speech synthesis with Audio
7171

7272
## (Optional) Connect your Azure Cognitive Service to your Azure Communication Service
7373

74-
If you would like to use Text-To-Speech capabilities, then it's required for you to connect your Azure Cognitive Service to your Azure Communication Service.
75-
76-
``` code
77-
az communication bind-cognitive-service --name “{Azure Communication resource name}” --resource-group “{Azure Communication resource group}” --resource-id “{Cognitive service resource id}” --subscription{subscription Name of Cognitive service} –identity{Cognitive Services Identity}
78-
79-
```
74+
If you would like to use Text-To-Speech capabilities, then it's required for you to connect your [Azure Cognitive Service to your Azure Communication Service](../../../concepts/call-automation/azure-communication-services-azure-cognitive-services-integration.md).
8075

8176
## Update App.java with code
8277

@@ -171,27 +166,30 @@ assertEquals(202, playResponse.getStatusCode()); // The request was accepted
171166

172167
Your application receives action lifecycle event updates on the callback URL that was provided to Call Automation service at the time of answering the call. An example of a successful play event update.
173168

174-
```json
175-
[{
176-
"id": "704a7a96-4d74-4ebe-9cd0-b7cc39c3d7b1",
177-
"source": "calling/callConnections/<callConnectionId>/PlayCompleted",
178-
"type": "Microsoft.Communication.PlayCompleted",
179-
"data": {
180-
"resultInfo": {
181-
"code": 200,
182-
"subCode": 0,
183-
"message": "Action completed successfully."
184-
},
185-
"type": "playCompleted",
186-
"callConnectionId": "<callConnectionId>",
187-
"serverCallId": "<serverCallId>",
188-
"correlationId": "<correlationId>"
189-
},
190-
"time": "2022-08-12T03:13:25.0252763+00:00",
191-
"specversion": "1.0",
192-
"datacontenttype": "application/json",
193-
"subject": "calling/callConnections/<callConnectionId>/PlayCompleted"
194-
}]
169+
### Example of how you can deserialize the *PlayCompleted* event:
170+
171+
``` java
172+
if (callEvent instanceof PlayCompleted) {
173+
CallAutomationEventWithReasonCodeBase playCompleted= (CallAutomationEventWithReasonCodeBase) callEvent;
174+
Reasoncode reasonCode = playCompleted.getReasonCode();
175+
ResultInformation = playCompleted.getResultInformation();
176+
//Play audio completed, Take some action on completed event.
177+
// Hang up call
178+
callConnection.hangUp(true);
179+
}
180+
```
181+
182+
### Example of how you can deserialize the *PlayFailed* event:
183+
184+
``` java
185+
if (callEvent instanceof PlayFailed) {
186+
CallAutomationEventWithReasonCodeBase playFailed = (CallAutomationEventWithReasonCodeBase) callEvent;
187+
Reasoncode reasonCode = playFailed.getReasonCode();
188+
ResultInformation = playFailed.getResultInformation();
189+
//Play audio failed, Take some action on failed event.
190+
// Hang up call
191+
callConnection.hangUp(true);
192+
}
195193
```
196194

197195
To learn more about other supported events, visit the [Call Automation overview document](../../../concepts/call-automation/call-automation.md#call-automation-webhook-events).
@@ -205,3 +203,16 @@ var callConnection = callAutomationAsyncClient.getCallConnectionAsync(<callConne
205203
var cancelResponse = callConnection.getCallMediaAsync().cancelAllMediaOperationsWithResponse().block();
206204
assertEquals(202, cancelResponse.getStatusCode()); // The request was accepted
207205
```
206+
207+
### Example of how you can deserialize the *PlayCanceled* event:
208+
209+
``` java
210+
if (callEvent instanceof PlayCanceled {
211+
CallAutomationEventWithReasonCodeBase playCanceled= (CallAutomationEventWithReasonCodeBase) callEvent;
212+
Reasoncode reasonCode = playCanceled.getReasonCode();
213+
ResultInformation = playCanceled.getResultInformation();
214+
//Play audio completed, Take some action on canceled event.
215+
// Hang up call
216+
callConnection.hangUp(true);
217+
}
218+
```

articles/communication-services/how-tos/call-automation/includes/recognize-ai-action-how-to-csharp.md

Lines changed: 1 addition & 145 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ The following parameters are available to customize the Recognize function:
3030
| InterToneTimeout | TimeSpan | 2 seconds <br/><br/>**Min:** 1 second <br/>**Max:** 60 seconds | Limit in seconds that ACS will wait for the caller to press another digit (inter-digit timeout). | Optional |
3131
| InitialSegmentationSilenceTimeoutInSeconds | Integer | 0.5 seconds | How long recognize action will wait for input before considering it a timeout. [Read more here](../../../../../articles/cognitive-services/Speech-Service/how-to-recognize-speech.md). | Optional |
3232
| RecognizeInputsType | Enum | dtmf | Type of input that will be recognized. Options will be dtmf and choices. | Required |
33-
| InitialSilenceTimeout | TimeSpan | 5 seconds<br/><br/>**Min:** 0 seconds <br/>**Max:** 300 seconds | Initial silence timeout adjusts how much non-speech audio is allowed before a phrase before the recognition attempt ends in a "no match" result. [Read more here](../../../../../articles/cognitive-services/Speech-Service/how-to-recognize-speech.md). | Optional |
33+
| InitialSilenceTimeout | TimeSpan | 5 seconds<br/><br/>**Min:** 0 seconds <br/>**Max:** 300 seconds (DTMF) <br/>**Max:** 20 seconds (Choices)| Initial silence timeout adjusts how much non-speech audio is allowed before a phrase before the recognition attempt ends in a "no match" result. [Read more here](../../../../../articles/cognitive-services/Speech-Service/how-to-recognize-speech.md). | Optional |
3434
| MaxTonesToCollect | Integer | No default<br/><br/>**Min:** 1|Number of digits a developer expects as input from the participant.| Required |
3535
| StopTones |IEnumeration\<DtmfTone\> | Not set | The digit participants can press to escape out of a batch DTMF event. | Optional |
3636
| InterruptPrompt | Bool | True | If the participant has the ability to interrupt the playMessage by pressing a digit. | Optional |
@@ -128,74 +128,6 @@ var targetParticipant = new PhoneNumberIdentifier("+1XXXXXXXXXXX");
128128

129129
Developers can subscribe to the *RecognizeCompleted* and *RecognizeFailed* events on the webhook callback they registered for the call to create business logic in their application for determining next steps when one of the previously mentioned events occurs.
130130

131-
### Example of DTMF *RecognizeCompleted* event:
132-
``` json
133-
[
134-
{
135-
"id": "e9cf1c71-f119-48db-86ca-4f2530a2004d",
136-
"source": "calling/callConnections/411f0b00-d97f-49ad-a6ff-3f8c05dc64d7/RecognizeCompleted",
137-
"type": "Microsoft.Communication.RecognizeCompleted",
138-
"data": {
139-
"eventSource": "calling/callConnections/411f0b00-d97f-49ad-a6ff-3f8c05dc64d7/RecognizeCompleted",
140-
"operationContext": "267e33a9-c28e-4ecf-a33e-b3abd9526e32",
141-
"resultInformation": {
142-
"code": 200,
143-
"subCode": 8531,
144-
"message": "Action completed, max digits received."
145-
},
146-
"recognitionType": "dtmf",
147-
"collectTonesResult": {
148-
"tones": [
149-
"nine",
150-
"eight",
151-
"zero",
152-
"five",
153-
"two"
154-
]
155-
},
156-
"callConnectionId": "411f0b00-d97f-49ad-a6ff-3f8c05dc64d7",
157-
"serverCallId": "aHR0cHM6Ly9hcGkuZmxpZ2h0cHJveHkuc2t5cGUuY29tL2FwaS92Mi9jcC9jb252LXVzZWEyLTAxLmNvbnYuc2t5cGUuY29tL2NvbnYvQzNuT3lkY3E0VTZCV0gtcG1GNmc1Zz9pPTQmZT02Mzc5ODYwMDMzNDQ2MTA5MzM=",
158-
"correlationId": "53be6977-d832-4c42-8527-fb2aa4a78b74"
159-
},
160-
"time": "2022-09-13T00:55:08.2240104+00:00",
161-
"specversion": "1.0",
162-
"datacontenttype": "application/json",
163-
"subject": "calling/callConnections/411f0b00-d97f-49ad-a6ff-3f8c05dc64d7/RecognizeCompleted"
164-
}
165-
]
166-
```
167-
### Example of Choices *RecognizeCompleted* event:
168-
``` json
169-
[
170-
{
171-
"id": "cf41d1b3-663d-45ab-94d6-7ff130f41839",
172-
"source": "calling/callConnections/411f7000-1831-48f7-95f3-b8ee7470dd41",
173-
"type": "Microsoft.Communication.RecognizeCompleted",
174-
"data": {
175-
"eventSource": "calling/callConnections/411f7000-1831-48f7-95f3-b8ee7470dd41",
176-
"operationContext": "AppointmentReminderMenu",
177-
"resultInformation": {
178-
"code": 200,
179-
"subCode": 8545,
180-
"message": "Action completed, Recognized phrase matches a valid option."
181-
},
182-
"recognitionType": "choices",
183-
"choiceResult": {
184-
"label": "Confirm",
185-
"recognizedPhrase": "confirm"
186-
},
187-
"callConnectionId": "411f7000-1831-48f7-95f3-b8ee7470dd41",
188-
"serverCallId": "aHR0cHM6Ly9hcGkuZXAtZGV2LnNreXBlLm5ldC9hcGerteeqwertrtertsdfrYtMjAwLmNvbnYtZGV2LnNreXBlLm5ldC9jb252L3dIMTZkNk1VxTjNtajc5M2w2eXc/aTyJmU9N45dfg4MDg5MDEyOTMyODg1OTY5",
189-
"correlationId": "0f40d4ea-2e26-412a-ad43-171411927bf3"
190-
},
191-
"time": "2023-01-10T00:28:56.7369845+00:00",
192-
"specversion": "1.0",
193-
"datacontenttype": "application/json",
194-
"subject": "calling/callConnections/411f7000-1831-48f7-95f3-b8ee7470dd41"
195-
}
196-
]
197-
```
198-
199131
### Example of how you can deserialize the *RecognizeCompleted* event:
200132
``` csharp
201133
if (@event is RecognizeCompleted { OperationContext: "AppointmentReminderMenu" })
@@ -225,60 +157,6 @@ Developers can subscribe to the *RecognizeCompleted* and *RecognizeFailed* event
225157
}
226158
```
227159

228-
### Example of DTMF *RecognizeFailed* event:
229-
``` json
230-
[
231-
{
232-
"id": "47d9cb04-7039-427b-af50-aebdd94db054",
233-
"source": "calling/callConnections/411f0b00-bb72-4d5b-9524-ae1c29713335/RecognizeFailed",
234-
"type": "Microsoft.Communication.RecognizeFailed",
235-
"data": {
236-
"eventSource": "calling/callConnections/411f0b00-bb72-4d5b-9524-ae1c29713335/RecognizeFailed",
237-
"operationContext": "267e33a9-c28e-4ecf-a33e-b3abd9526e32",
238-
"resultInformation": {
239-
"code": 500,
240-
"subCode": 8511,
241-
"message": "Action failed, encountered failure while trying to play the prompt."
242-
},
243-
"callConnectionId": "411f0b00-bb72-4d5b-9524-ae1c29713335",
244-
"serverCallId": "aHR0cHM6Ly9hcGkuZmxpZ2h0cHJveHkuc2t5cGUuY29tL2FwaS92Mi9jcC9jb252LXVzZWEyLTAxLmNvbnYuc2t5cGUuY29tL2NvbnYvQzNuT3lkY3E0VTZCV0gtcG1GNmc1Zz9pPTQmZT02Mzc5ODYwMDMzNDQ2MTA5MzM=",
245-
"correlationId": "53be6977-d832-4c42-8527-fb2aa4a78b74"
246-
},
247-
"time": "2022-09-13T00:55:37.0660233+00:00",
248-
"specversion": "1.0",
249-
"datacontenttype": "application/json",
250-
"subject": "calling/callConnections/411f0b00-bb72-4d5b-9524-ae1c29713335/RecognizeFailed"
251-
}
252-
]
253-
```
254-
255-
### Example of Choices *RecognizeFailed* event:
256-
``` json
257-
[
258-
{
259-
"id": "264be623-5915-415e-bf06-2165e3fa0a08",
260-
"source": "calling/callConnections/411f7000-1831-48f7-95f3-b8ee7470dd41",
261-
"type": "Microsoft.Communication.RecognizeFailed",
262-
"data": {
263-
"eventSource": "calling/callConnections/411f7000-1831-48f7-95f3-b8ee7470dd41",
264-
"operationContext": "AppointmentReminderMenu",
265-
"resultInformation": {
266-
"code": 400,
267-
"subCode": 8547,
268-
"message": "Action failed, recognized phrase does not match a valid option."
269-
},
270-
"callConnectionId": "411f7000-1831-48f7-95f3-b8ee7470dd41",
271-
"serverCallId": "aHR0cHM6Ly9hcGkuZXAtZGV2LnNreXBlLm5ldC9hcGkvdjIvY3AvY29udi1kZXYtMjAwLmNvbnYtZGV2LnNreXBlLm5ldC9jb252L3dIMTZkNkJYU1VxTjNtajc5M2w2eXc/aT0yJmU9NjM4MDg5MDEyOTMyODg1OTY5",
272-
"correlationId": "0f40d4ea-2e26-412a-ad43-171411927bf3"
273-
},
274-
"time": "2023-01-10T00:29:30.300373+00:00",
275-
"specversion": "1.0",
276-
"datacontenttype": "application/json",
277-
"subject": "calling/callConnections/411f7000-1831-48f7-95f3-b8ee7470dd41"
278-
}
279-
]
280-
```
281-
282160
### Example of how you can deserialize the *RecognizeFailed* event:
283161
``` csharp
284162
if (@event is RecognizeFailed { OperationContext: "AppointmentReminderMenu" })
@@ -308,28 +186,6 @@ if (@event is RecognizeFailed { OperationContext: "AppointmentReminderMenu" })
308186
}
309187
```
310188

311-
### Example of *RecognizeCanceled* event:
312-
``` json
313-
[
314-
{
315-
"id": "d4f2e476-fb8f-43c2-abf8-0981f8e70df9",
316-
"source": "calling/callConnections/411f7000-1831-48f7-95f3-b8ee7470dd41",
317-
"type": "Microsoft.Communication.RecognizeCanceled",
318-
"data": {
319-
"eventSource": "calling/callConnections/411f7000-1831-48f7-95f3-b8ee7470dd41",
320-
"operationContext": "AppointmentChoiceMenu",
321-
"callConnectionId": "411f7000-1831-48f7-95f3-b8ee7470dd41",
322-
"serverCallId": "aHR0cHM6Ly9hcGkuZXAtZGV2LnNreXBlLm5ldC9hcGkvdjIvY3AvY29udi1kZXYtMjAwLmNvbnYtZGV2LnNreXBlLm5ldC9jb252L3dIMTZkNkJYU1VxTjNtajc5M2w2eXc/aT0yJmU9NjM4MDg5MDEyOTMyODg1OTY5",
323-
"correlationId": "0f40d4ea-2e26-412a-ad43-171411927bf3"
324-
},
325-
"time": "2023-01-10T00:31:15.3606572+00:00",
326-
"specversion": "1.0",
327-
"datacontenttype": "application/json",
328-
"subject": "calling/callConnections/411f7000-1831-48f7-95f3-b8ee7470dd41"
329-
}
330-
]
331-
```
332-
333189
### Example of how you can deserialize the *RecognizeCanceled* event:
334190
``` csharp
335191
if (@event is RecognizeCanceled { OperationContext: "AppointmentReminderMenu" })

0 commit comments

Comments
 (0)