Remove call_sid from function util-twilio-hangup_phone_call
This commit is contained in:
parent
20563d28f5
commit
1468c01f46
|
|
@ -139,7 +139,7 @@ public class RealtimeHub : IRealtimeHub
|
|||
|
||||
if (!string.IsNullOrEmpty(message.Content))
|
||||
{
|
||||
await hook.OnMessageReceived(message);
|
||||
await hook.OnResponseGenerated(message);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -93,6 +93,7 @@ public class TwilioStreamController : TwilioController
|
|||
Id = request.CallSid,
|
||||
AgentId = _settings.AgentId,
|
||||
Channel = ConversationChannel.Phone,
|
||||
ChannelId = request.CallSid,
|
||||
Title = $"Phone call from {request.From}",
|
||||
Tags = [],
|
||||
};
|
||||
|
|
@ -103,7 +104,8 @@ public class TwilioStreamController : TwilioController
|
|||
var states = new List<MessageState>
|
||||
{
|
||||
new("channel", ConversationChannel.Phone),
|
||||
new("calling_phone", request.From)
|
||||
new("calling_phone", request.From),
|
||||
new("twilio_call_sid", request.CallSid),
|
||||
};
|
||||
|
||||
convService.SetConversationId(conversation.Id, states);
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
using BotSharp.Plugin.Twilio.OutboundPhoneCallHandler.LlmContexts;
|
||||
using Twilio.Rest.Api.V2010.Account;
|
||||
|
||||
namespace BotSharp.Plugin.Twilio.OutboundPhoneCallHandler.Functions;
|
||||
|
|
@ -21,14 +20,24 @@ public class HangupPhoneCallFn : IFunctionCallback
|
|||
|
||||
public async Task<bool> Execute(RoleDialogModel message)
|
||||
{
|
||||
var args = JsonSerializer.Deserialize<LlmContextIn>(message.FunctionArgs);
|
||||
var states = _services.GetRequiredService<IConversationStateService>();
|
||||
var callSid = states.GetState("twilio_call_sid");
|
||||
|
||||
if (string.IsNullOrEmpty(callSid))
|
||||
{
|
||||
message.Content = "The call has not been initiated.";
|
||||
_logger.LogError(message.Content);
|
||||
return false;
|
||||
}
|
||||
|
||||
// Have to find the SID by the phone number
|
||||
var call = CallResource.Update(
|
||||
status: CallResource.UpdateStatusEnum.Completed,
|
||||
pathSid: args.CallSid
|
||||
pathSid: callSid
|
||||
);
|
||||
|
||||
message.Content = "The call has ended.";
|
||||
message.StopCompletion = true;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -105,7 +105,7 @@ public class OutboundPhoneCallFn : IFunctionCallback
|
|||
|
||||
convStorage.Append(newConversationId, new List<RoleDialogModel>
|
||||
{
|
||||
new RoleDialogModel(AgentRole.User, $"[Calling Phone To: {resource.ToFormatted}, Call SID: {resource.Sid}.]")
|
||||
new RoleDialogModel(AgentRole.User, "Hi")
|
||||
{
|
||||
CurrentAgentId = entryAgentId
|
||||
},
|
||||
|
|
|
|||
|
|
@ -9,7 +9,4 @@ public class LlmContextIn
|
|||
|
||||
[JsonPropertyName("initial_message")]
|
||||
public string InitialMessage { get; set; }
|
||||
|
||||
[JsonPropertyName("call_sid")]
|
||||
public string CallSid { get; set; }
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,11 +5,7 @@
|
|||
"parameters": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"call_sid": {
|
||||
"type": "string",
|
||||
"description": "The unique string SID that we created to identify this Call resource."
|
||||
}
|
||||
},
|
||||
"required": [ "call_sid" ]
|
||||
"required": []
|
||||
}
|
||||
}
|
||||
|
|
@ -1,2 +1 @@
|
|||
** Please call util-twilio-outbound_phone_call if user wants to make an outbound call.
|
||||
** For outbound calls, phone number format is "XXX-XXX-XXXX".
|
||||
** Please call util-twilio-outbound_phone_call if user wants to make an outbound call.
|
||||
Loading…
Reference in a new issue