Skip to content

Commit

Permalink
disconnecting the call when max timeout reached
Browse files Browse the repository at this point in the history
  • Loading branch information
v-vdharmaraj committed Nov 28, 2023
1 parent 235be8f commit 08eeec4
Showing 1 changed file with 5 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ You are an assisant designed to answer the customer query and analyze the sentim

string transferFailedContext = "TransferFailed";
string connectAgentContext = "ConnectAgent";
string goodbyeContext = "Goodbye";

string agentPhonenumber = builder.Configuration.GetValue<string>("AgentPhoneNumber");
string chatResponseExtractPattern = @"\s*Content:(.*)\s*Score:(.*\d+)\s*Intent:(.*)\s*Category:(.*)";
Expand Down Expand Up @@ -113,9 +114,10 @@ You are an assisant designed to answer the customer query and analyze the sentim
client.GetEventProcessor().AttachOngoingEventProcessor<PlayCompleted>(answerCallResult.CallConnection.CallConnectionId, async (playCompletedEvent) =>
{
logger.LogInformation($"Play completed event received for connection id: {playCompletedEvent.CallConnectionId}.");
if (!string.IsNullOrWhiteSpace(playCompletedEvent.OperationContext) && playCompletedEvent.OperationContext.Equals(transferFailedContext, StringComparison.OrdinalIgnoreCase))
if (!string.IsNullOrWhiteSpace(playCompletedEvent.OperationContext) && (playCompletedEvent.OperationContext.Equals(transferFailedContext, StringComparison.OrdinalIgnoreCase)
|| playCompletedEvent.OperationContext.Equals(goodbyeContext, StringComparison.OrdinalIgnoreCase)))
{
logger.LogInformation($"Call transfer failed, disconnecting the call...");
logger.LogInformation($"Disconnecting the call...");
await answerCallResult.CallConnection.HangUpAsync(true);
}
else if (!string.IsNullOrWhiteSpace(playCompletedEvent.OperationContext) && playCompletedEvent.OperationContext.Equals(connectAgentContext, StringComparison.OrdinalIgnoreCase))
Expand Down Expand Up @@ -216,7 +218,7 @@ await HandlePlayAsync(connectAgentPrompt,
else
{
Console.WriteLine($"Recognize failed event received for connection id: {recognizeFailedEvent.CallConnectionId}. Playing goodbye message...");
await HandlePlayAsync(goodbyePrompt, "RecognizeFailed", callConnectionMedia);
await HandlePlayAsync(goodbyePrompt, goodbyeContext, callConnectionMedia);
}
});
}
Expand Down

0 comments on commit 08eeec4

Please sign in to comment.