enable answering machine detection
This commit is contained in:
parent
2101f3a59f
commit
c1d64314a1
|
|
@ -126,9 +126,11 @@ public class TwilioVoiceController : TwilioController
|
|||
SeqNumber = request.SeqNum,
|
||||
Content = messageContent,
|
||||
Digits = request.Digits,
|
||||
From = request.From,
|
||||
From = string.Equals(request.Direction, "inbound") ? request.From : request.To,
|
||||
States = ParseStates(request.States)
|
||||
};
|
||||
callerMessage.RequestHeaders = new KeyValuePair<string, Microsoft.Extensions.Primitives.StringValues>[Request.Headers.Count];
|
||||
Request.Headers.CopyTo(callerMessage.RequestHeaders, 0);
|
||||
await messageQueue.EnqueueAsync(callerMessage);
|
||||
|
||||
response = new VoiceResponse();
|
||||
|
|
@ -387,6 +389,7 @@ public class TwilioVoiceController : TwilioController
|
|||
$"twilio/voice/speeches/{conversationId}/intial.mp3"
|
||||
}
|
||||
};
|
||||
string tag = Request.Form["AnsweredBy"];
|
||||
var twilio = _services.GetRequiredService<TwilioService>();
|
||||
var response = twilio.ReturnNoninterruptedInstructions(instruction);
|
||||
return TwiML(response);
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
using Microsoft.Extensions.Primitives;
|
||||
|
||||
namespace BotSharp.Plugin.Twilio.Models
|
||||
{
|
||||
public class CallerMessage
|
||||
|
|
@ -8,6 +10,7 @@ namespace BotSharp.Plugin.Twilio.Models
|
|||
public string Digits { get; set; }
|
||||
public string From { get; set; }
|
||||
public Dictionary<string, string> States { get; set; } = new();
|
||||
public KeyValuePair<string, StringValues>[] RequestHeaders { get; set; }
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
|
|
|
|||
|
|
@ -92,7 +92,8 @@ namespace BotSharp.Plugin.Twilio.OutboundPhoneCallHandler.Functions
|
|||
var call = await CallResource.CreateAsync(
|
||||
url: new Uri($"{_twilioSetting.CallbackHost}/twilio/voice/init-call?conversationId={conversationId}"),
|
||||
to: new PhoneNumber(args.PhoneNumber),
|
||||
from: new PhoneNumber(_twilioSetting.PhoneNumber));
|
||||
from: new PhoneNumber(_twilioSetting.PhoneNumber),
|
||||
machineDetection: "DetectMessageEnd");
|
||||
|
||||
message.Content = $"The generated phone message: {args.InitialMessage}. \r\n[Conversation ID: {conversationId}]" ?? message.Content;
|
||||
message.StopCompletion = true;
|
||||
|
|
|
|||
|
|
@ -65,6 +65,10 @@ namespace BotSharp.Plugin.Twilio.Services
|
|||
var httpContext = sp.GetRequiredService<IHttpContextAccessor>();
|
||||
httpContext.HttpContext = new DefaultHttpContext();
|
||||
httpContext.HttpContext.User = new ClaimsPrincipal(new ClaimsIdentity());
|
||||
foreach (var header in message.RequestHeaders)
|
||||
{
|
||||
httpContext.HttpContext.Request.Headers[header.Key] = header.Value;
|
||||
}
|
||||
httpContext.HttpContext.Request.Headers["X-Twilio-BotSharp"] = "LOST";
|
||||
|
||||
AssistantMessage reply = null;
|
||||
|
|
|
|||
Loading…
Reference in a new issue