From e4d8524376f8991c885f5a95924dafd2da272a64 Mon Sep 17 00:00:00 2001 From: hchen2020 <101423@smsassist.com> Date: Sun, 27 Aug 2023 06:07:22 -0500 Subject: [PATCH] Add disabled property to routing table. --- .../BotSharp.Abstraction/Agents/Models/RoutingRecord.cs | 3 +++ src/Infrastructure/BotSharp.Core/BotSharp.Core.csproj | 4 ++++ src/Infrastructure/BotSharp.Core/Hooks/AgentHook.cs | 4 +++- 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/Infrastructure/BotSharp.Abstraction/Agents/Models/RoutingRecord.cs b/src/Infrastructure/BotSharp.Abstraction/Agents/Models/RoutingRecord.cs index 8f83c74b..3d8e1868 100644 --- a/src/Infrastructure/BotSharp.Abstraction/Agents/Models/RoutingRecord.cs +++ b/src/Infrastructure/BotSharp.Abstraction/Agents/Models/RoutingRecord.cs @@ -19,6 +19,9 @@ public class RoutingRecord [JsonPropertyName("redirect_to")] public string RedirectTo { get; set; } + [JsonPropertyName("disabled")] + public bool Disabled { get; set; } + public override string ToString() { return Name; diff --git a/src/Infrastructure/BotSharp.Core/BotSharp.Core.csproj b/src/Infrastructure/BotSharp.Core/BotSharp.Core.csproj index ab77723b..20b036e4 100644 --- a/src/Infrastructure/BotSharp.Core/BotSharp.Core.csproj +++ b/src/Infrastructure/BotSharp.Core/BotSharp.Core.csproj @@ -82,4 +82,8 @@ + + + + diff --git a/src/Infrastructure/BotSharp.Core/Hooks/AgentHook.cs b/src/Infrastructure/BotSharp.Core/Hooks/AgentHook.cs index e030a904..559445a9 100644 --- a/src/Infrastructure/BotSharp.Core/Hooks/AgentHook.cs +++ b/src/Infrastructure/BotSharp.Core/Hooks/AgentHook.cs @@ -10,7 +10,9 @@ public class AgentHook : AgentHookBase public override bool OnInstructionLoaded(string template, Dictionary dict) { var router = _services.GetRequiredService(); - dict["routing_records"] = router.GetRoutingRecords(); + dict["routing_records"] = router.GetRoutingRecords() + .Where(x => !x.Disabled) + .ToList(); return true; } }