From 8d5b1402d014f03a8e08c4d5b476f3e582b33707 Mon Sep 17 00:00:00 2001 From: "nick.yi" Date: Fri, 27 Jun 2025 14:13:53 +0800 Subject: [PATCH 1/3] Fixed an issue where response_to_user is called when the user wants to end the conversation. It should call route_to_agent with converation_end as true --- .../instructions/instruction.liquid | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Infrastructure/BotSharp.Core/data/agents/01fcc3e5-9af7-49e6-ad7a-a760bd12dc4a/instructions/instruction.liquid b/src/Infrastructure/BotSharp.Core/data/agents/01fcc3e5-9af7-49e6-ad7a-a760bd12dc4a/instructions/instruction.liquid index 775de66ca..8d2da12c8 100644 --- a/src/Infrastructure/BotSharp.Core/data/agents/01fcc3e5-9af7-49e6-ad7a-a760bd12dc4a/instructions/instruction.liquid +++ b/src/Infrastructure/BotSharp.Core/data/agents/01fcc3e5-9af7-49e6-ad7a-a760bd12dc4a/instructions/instruction.liquid @@ -5,7 +5,8 @@ Follow these steps to handle user request: 2. Determine which agent is suitable to handle this conversation. Try to minimize the routing of human service. 3. Extract and populate agent required arguments, think carefully, leave it as blank object if user didn't provide the specific arguments. 4. You must include all required args for the selected agent, but you must not make up any parameters when there is no exact value provided, those parameters must set value as null if not declared. -5. If user is greeting, you can call function response_to_user with a greeting message. +5. If user wants to end the conversation, call route_to_agent function with conversation_end as true. +6. If user is greeting, you can call function response_to_user with a greeting message. {% if routing_requirements and routing_requirements != empty %} [REQUIREMENTS] From 94c3a86635b8e00ce040e0cdaec2615110164fee Mon Sep 17 00:00:00 2001 From: "nick.yi" Date: Tue, 8 Jul 2025 23:03:54 +0800 Subject: [PATCH 2/3] optimize twilio --- .../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 511abb455..07c4ad871 100644 --- a/src/Plugins/BotSharp.Plugin.Twilio/Controllers/TwilioInboundController.cs +++ b/src/Plugins/BotSharp.Plugin.Twilio/Controllers/TwilioInboundController.cs @@ -63,6 +63,11 @@ await HookEmitter.Emit(_services, async hook => instruction.AgentId = request.AgentId; instruction.ConversationId = request.ConversationId; + await HookEmitter.Emit(_services, async hook => + { + await hook.OnSessionCreated(request); + }, request.AgentId); + if (twilio.MachineDetected(request)) { response = new VoiceResponse(); @@ -114,12 +119,7 @@ await HookEmitter.Emit(_services, await Task.Delay(1500); await twilio.StartRecording(request.CallSid, request.AgentId, request.ConversationId); }); - } - - await HookEmitter.Emit(_services, async hook => - { - await hook.OnSessionCreated(request); - }, request.AgentId); + } return TwiML(response); } From a5d9da92bc615e802a84ce45a2d7871aa1664607 Mon Sep 17 00:00:00 2001 From: "nick.yi" Date: Tue, 8 Jul 2025 23:09:22 +0800 Subject: [PATCH 3/3] Revert "Fixed an issue where response_to_user is called when the user wants to end the conversation. It should call route_to_agent with converation_end as true" This reverts commit 8d5b1402d014f03a8e08c4d5b476f3e582b33707. --- .../instructions/instruction.liquid | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/Infrastructure/BotSharp.Core/data/agents/01fcc3e5-9af7-49e6-ad7a-a760bd12dc4a/instructions/instruction.liquid b/src/Infrastructure/BotSharp.Core/data/agents/01fcc3e5-9af7-49e6-ad7a-a760bd12dc4a/instructions/instruction.liquid index 8d2da12c8..775de66ca 100644 --- a/src/Infrastructure/BotSharp.Core/data/agents/01fcc3e5-9af7-49e6-ad7a-a760bd12dc4a/instructions/instruction.liquid +++ b/src/Infrastructure/BotSharp.Core/data/agents/01fcc3e5-9af7-49e6-ad7a-a760bd12dc4a/instructions/instruction.liquid @@ -5,8 +5,7 @@ Follow these steps to handle user request: 2. Determine which agent is suitable to handle this conversation. Try to minimize the routing of human service. 3. Extract and populate agent required arguments, think carefully, leave it as blank object if user didn't provide the specific arguments. 4. You must include all required args for the selected agent, but you must not make up any parameters when there is no exact value provided, those parameters must set value as null if not declared. -5. If user wants to end the conversation, call route_to_agent function with conversation_end as true. -6. If user is greeting, you can call function response_to_user with a greeting message. +5. If user is greeting, you can call function response_to_user with a greeting message. {% if routing_requirements and routing_requirements != empty %} [REQUIREMENTS]