Skip to content

Commit fd66718

Browse files
author
aden.chen
committed
Supports allow to interrupt the welcome message playing
1 parent 840ee27 commit fd66718

3 files changed

Lines changed: 18 additions & 1 deletion

File tree

src/Plugins/BotSharp.Plugin.Twilio/Controllers/TwilioOutboundController.cs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,15 @@ await HookEmitter.Emit<ITwilioCallStatusHook>(_services,
5353
{
5454
instruction.SpeechPaths.Add(request.InitAudioFile);
5555
}
56-
response = twilio.ReturnNoninterruptedInstructions(instruction);
56+
57+
if (request.WelcomeMessageAllowToBeInterrupted.HasValue && request.WelcomeMessageAllowToBeInterrupted.Value)
58+
{
59+
response = twilio.ReturnInstructions(instruction);
60+
}
61+
else
62+
{
63+
response = twilio.ReturnNoninterruptedInstructions(instruction);
64+
}
5765
}
5866

5967
return TwiML(response);

src/Plugins/BotSharp.Plugin.Twilio/Models/ConversationalVoiceRequest.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,9 @@ public class ConversationalVoiceRequest : VoiceRequest
4242
[FromForm]
4343
public int MachineDetectionDuration { get; set; }
4444

45+
[FromQuery(Name = "welcome_message_allow_to_be_interrupted")]
46+
public bool? WelcomeMessageAllowToBeInterrupted { get; set; }
47+
4548
[FromForm]
4649
public int CallDuration { get; set; }
4750

src/Plugins/BotSharp.Plugin.Twilio/OutboundPhoneCallHandler/Functions/OutboundPhoneCallFn.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ public class OutboundPhoneCallFn : IFunctionCallback
2525

2626
public string Name => "util-twilio-outbound_phone_call";
2727
public string Indication => "Dialing the phone number";
28+
public const string WelcomeMessageAllowToBeInterrupted = "welcome_message_allow_to_be_interrupted";
2829

2930
public OutboundPhoneCallFn(
3031
IServiceProvider services,
@@ -106,6 +107,11 @@ public async Task<bool> Execute(RoleDialogModel message)
106107
processUrl += $"&init-audio-file={initAudioFile}";
107108
}
108109

110+
if (agent.Labels.Contains(WelcomeMessageAllowToBeInterrupted))
111+
{
112+
processUrl += $"${WelcomeMessageAllowToBeInterrupted}=true";
113+
}
114+
109115
// Make outbound call
110116
var call = await CallResource.CreateAsync(
111117
url: new Uri(processUrl),

0 commit comments

Comments
 (0)