From 866cbd2e2245bc828f4e72de03ba9c90578e9a10 Mon Sep 17 00:00:00 2001 From: Haiping Date: Thu, 10 Apr 2025 15:24:18 -0500 Subject: [PATCH] Update TwilioInboundController.cs --- .../Controllers/TwilioInboundController.cs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/Plugins/BotSharp.Plugin.Twilio/Controllers/TwilioInboundController.cs b/src/Plugins/BotSharp.Plugin.Twilio/Controllers/TwilioInboundController.cs index 49f13c78..b37e09ea 100644 --- a/src/Plugins/BotSharp.Plugin.Twilio/Controllers/TwilioInboundController.cs +++ b/src/Plugins/BotSharp.Plugin.Twilio/Controllers/TwilioInboundController.cs @@ -166,19 +166,19 @@ public class TwilioInboundController : TwilioController states.Add(new("init_audio_file", request.InitAudioFile)); } - convService.SetConversationId(conversation.Id, states); - - // Load agent profile var agentService = _services.GetRequiredService(); - var agent = await agentService.LoadAgent(request.AgentId); - + // Get agent from storage + var agent = await agentService.GetAgent(request.AgentId); // Enable lazy routing mode to optimize realtime experience if (agent.Profiles.Contains("realtime") && agent.Type == AgentType.Routing) { states.Add(new(StateConst.ROUTING_MODE, "lazy")); } - + convService.SetConversationId(conversation.Id, states); convService.SaveStates(); + + // reload agent rendering with states + agent = await agentService.LoadAgent(request.AgentId); return (agent, conversation); }