Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 5 additions & 50 deletions CallAutomationTests/Handlers/CallEventHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,9 @@ public class CallEventHandler :
IEventCloudEventHandler<AddParticipantSucceeded>,
IEventCloudEventHandler<CallConnected>,
IEventCloudEventHandler<CallDisconnected>,
IEventCloudEventHandler<CallTransferAccepted>,
IEventCloudEventHandler<CallTransferFailed>,
IEventCloudEventHandler<ParticipantsUpdated>,
IEventCloudEventHandler<PlayCompleted>,
IEventCloudEventHandler<PlayFailed>,
IEventCloudEventHandler<PlayCanceled>,
IEventCloudEventHandler<RecognizeCompleted>,
IEventCloudEventHandler<RecognizeFailed>,
IEventCloudEventHandler<RecognizeCanceled>,
Expand Down Expand Up @@ -123,25 +120,13 @@ public Task Handle(AddParticipantSucceeded addParticipantSucceeded, string calle

if (operationContext == Constants.OperationContext.AgentJoining)
{
_logger.LogInformation($"Attempting to stop hold music");
//_logger.LogInformation($"Attempting to stop hold music");

var callConnectionId = addParticipantSucceeded.CallConnectionId;

_callContextService.AddAgentAcsId(callConnectionId, addParticipantSucceeded.Participant.RawId);
}
else if (operationContext == Constants.OperationContext.SupervisorJoining)
{
_logger.LogInformation($"Adding supervisor to call.");
var callConnectionId = addParticipantSucceeded.CallConnectionId;
var callConnection = _callAutomationService.GetCallConnection(callConnectionId);
callConnection.MuteParticipants(addParticipantSucceeded.Participant, operationContext);

_callContextService.AddAgentAcsId(callConnectionId, addParticipantSucceeded.Participant.RawId);
}
else
{
_logger.LogWarning($"AddParticipantSucceeded for a non-agent. Call ID was '{addParticipantSucceeded.CorrelationId}'");
}


return Task.CompletedTask;
}
Expand All @@ -162,11 +147,7 @@ public async Task Handle(CallConnected callConnected, string callerId)

var operationContext = callConnected.OperationContext;

if (operationContext == Constants.OperationContext.AgentJoining || operationContext == Constants.OperationContext.SupervisorJoining)
{
_logger.LogCritical($"CallConnected was for an agent or supervisor, callerId was '{callerId}'. Set the allowlist to prevent accepting calls from the IVR.");
return;
}


var callId = callConnected.CorrelationId;
var callConnectionId = callConnected.CallConnectionId;
Expand Down Expand Up @@ -194,17 +175,7 @@ public async Task Handle(CallConnected callConnected, string callerId)
var ivrConfig = _callAutomationService.GetIvrConfig();
var textToSpeechLocale = ivrConfig["TextToSpeechLocale"];

// Recognized phone number
if (ivrConfig.GetValue<bool>("UseNlu") && ivrConfig.GetValue<bool>("UseAiPairing"))
{
_logger.LogInformation("Caller ID was recognized, sending to AI pairing immediately");
//await PromptCustomerForAiPairing(callConnection, textToSpeechLocale, callerId);
}
else
{
_logger.LogInformation("Caller ID was recognized, sending to IVR immediately");
await PlayMainMenu(callConnection, textToSpeechLocale, callerId, prerollText);
}


}
}
Expand Down Expand Up @@ -264,15 +235,7 @@ public async Task Handle(CallDisconnected callDisconnected, string callerId)
}
}

public Task Handle(CallTransferAccepted callTransferAccepted, string callerId)
{
throw new NotImplementedException();
}

public Task Handle(CallTransferFailed callTransferFailed, string callerId)
{
throw new NotImplementedException();
}

public async Task Handle(ParticipantsUpdated participantsUpdated, string callerId)
{
Expand Down Expand Up @@ -416,15 +379,7 @@ public async Task Handle(PlayFailed playFailed, string callerId)
}
}

public Task Handle(PlayCanceled playCanceled, string callerId)
{
using (_logger.BeginScope(GetLogContext(playCanceled.CorrelationId, playCanceled.CallConnectionId, playCanceled.OperationContext)))
{
_logger.LogInformation($"PlayCanceled received for OperationContext: '{playCanceled.OperationContext}'");

return Task.CompletedTask;
}
}


public async Task Handle(RecognizeCompleted recognizeCompleted, string callerId)
{
Expand Down
6 changes: 2 additions & 4 deletions CallAutomationTests/ServiceCollectionExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,11 @@ public static IServiceCollection AddAllEventGridEventHandlers(this IServiceColle
services.AddSingleton<IEventCloudEventHandler<AddParticipantFailed>, CallEventHandler>();
services.AddSingleton<IEventCloudEventHandler<AddParticipantSucceeded>, CallEventHandler>();
services.AddSingleton<IEventCloudEventHandler<CallConnected>, CallEventHandler>();
services.AddSingleton<IEventCloudEventHandler<CallDisconnected>, CallEventHandler>();
services.AddSingleton<IEventCloudEventHandler<CallTransferAccepted>, CallEventHandler>();
services.AddSingleton<IEventCloudEventHandler<CallTransferFailed>, CallEventHandler>();
services.AddSingleton<IEventCloudEventHandler<CallDisconnected>, CallEventHandler>();
services.AddSingleton<IEventCloudEventHandler<ParticipantsUpdated>, CallEventHandler>();
services.AddSingleton<IEventCloudEventHandler<PlayCompleted>, CallEventHandler>();
services.AddSingleton<IEventCloudEventHandler<PlayFailed>, CallEventHandler>();
services.AddSingleton<IEventCloudEventHandler<PlayCanceled>, CallEventHandler>();

services.AddSingleton<IEventCloudEventHandler<RecognizeCompleted>, CallEventHandler>();
services.AddSingleton<IEventCloudEventHandler<RecognizeFailed>, CallEventHandler>();
services.AddSingleton<IEventCloudEventHandler<RecognizeCanceled>, CallEventHandler>();
Expand Down
21 changes: 4 additions & 17 deletions CallAutomationTests/appsettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
}
},
"ConnectionStrings": {
"ACS": "%ACS%",
"ACS": "endpoint=https://acs-callautomation.communication.azure.com/;accesskey=cqfE3K8naankZhP+DKkPuz0V/IUqe7WqRzMm3WriAYhA7/oMHEVXiIxxRz7d5aPweiu1IZFsVsL3G551UhhlzA==",
"StorageAccount": ""
},
"IVRText": {
Expand Down Expand Up @@ -38,7 +38,7 @@
"PairingCompleted": "Let me get you connected to someone in our {0} service department who can look into this.",
"PairingCompletedOther": "Let me get you connected to someone who can look into this.",
"CustomerQueryTimeout": "I'm sorry, I wasn't quite able to hear that.",
"PostCallSurvey": "Thank you for staying on the line. How would you rate your customer service experience during this call today? Press 1 for satisfied, 2 for neutral, or 3 for dissatisfied."
// "PostCallSurvey": "Thank you for staying on the line. How would you rate your customer service experience during this call today? Press 1 for satisfied, 2 for neutral, or 3 for dissatisfied."
},
"Queues": {
"AllAgentsQueue": {
Expand Down Expand Up @@ -71,26 +71,13 @@
"UseAiPairing": false,
"UseCustomPhraseRecognition": false,
"PostCallSurvey": true,
"SpeechKey": "",
"SpeechRegion": "",
"SpeechRecognitionLanguage": "en-US",
"CustomerQueryTimeout": 22,
"MainMenuTimeout": 10,
"AccountIdTimeout": 33,
"PostCallSurveyTimeout": 20,
"AudioStreamBufferSize": 2048,
"SegmentationSilenceTimeoutMsForAccountId": 2000,
"SegmentationSilenceTimeoutMsForCustomerQuery": 2000,
"CloseCallOnHangup": false,
"AllowMenuInterrupt": false,
"AnnounceEstimatedWaitTime": true,
"AnnounceEstimatedWaitTimeThreshold": 5,
"RecognizerInitialSilenceTimeout": 10,
"DtmfInterToneTimeout": 5,
"EndCallRecognizePhrases": [ "End Call", "Hang up", "Fourth", "Four", "4", "End the call" ],
"RecognizePhrasesYes": [ "Yes", "One" ],
"RecognizePhrasesNo": [ "No", "Two" ],
"OperatorRecognizePhrases": [ "Operator", "all agents", "any agent", "help" ]
"DtmfInterToneTimeout": 5

},
"AllowedHosts": "*",
"EventGridSecret": "abc123",
Expand Down