Merge pull request #841 from wcao-lessen/fix/twilio-plugin
hang up after maximum gather attempts
This commit is contained in:
commit
620d71cab4
|
|
@ -147,37 +147,20 @@ public class TwilioVoiceController : TwilioController
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// keep waiting for user response
|
if (request.Attempts > _settings.MaxGatherAttempts)
|
||||||
if (request.Attempts > 3)
|
|
||||||
{
|
{
|
||||||
var instruction = new ConversationalVoiceResponse
|
|
||||||
{
|
|
||||||
SpeechPaths = new List<string>(),
|
|
||||||
CallbackPath = $"twilio/voice/{request.ConversationId}/receive/{request.SeqNum}?{GenerateStatesParameter(request.States)}",
|
|
||||||
ActionOnEmptyResult = true
|
|
||||||
};
|
|
||||||
|
|
||||||
// prompt user to speak clearly
|
|
||||||
if (request.SeqNum == 0)
|
|
||||||
{
|
|
||||||
instruction.SpeechPaths.Add("twilio/welcome.mp3");
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
var lastRepy = await sessionManager.GetAssistantReplyAsync(request.ConversationId, request.SeqNum - 1);
|
|
||||||
instruction.SpeechPaths.Add($"twilio/voice/speeches/{request.ConversationId}/{lastRepy.SpeechFileName}");
|
|
||||||
}
|
|
||||||
|
|
||||||
await HookEmitter.Emit<ITwilioSessionHook>(_services, async hook =>
|
await HookEmitter.Emit<ITwilioSessionHook>(_services, async hook =>
|
||||||
{
|
{
|
||||||
await hook.OnWaitingUserResponse(request, instruction);
|
await hook.OnAgentHangUp(request);
|
||||||
}, new HookEmitOption
|
}, new HookEmitOption
|
||||||
{
|
{
|
||||||
OnlyOnce = true
|
OnlyOnce = true
|
||||||
});
|
});
|
||||||
|
|
||||||
response = twilio.ReturnInstructions(instruction);
|
response = twilio.HangUp(null);
|
||||||
}
|
}
|
||||||
|
// keep waiting for user response
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
var instruction = new ConversationalVoiceResponse
|
var instruction = new ConversationalVoiceResponse
|
||||||
|
|
|
||||||
|
|
@ -11,4 +11,5 @@ public class TwilioSetting
|
||||||
public string CallbackHost { get; set; }
|
public string CallbackHost { get; set; }
|
||||||
public string AgentId { get; set; }
|
public string AgentId { get; set; }
|
||||||
public string CsrAgentNumber { get; set; }
|
public string CsrAgentNumber { get; set; }
|
||||||
|
public int MaxGatherAttempts { get; set; } = 4;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue