diff --git a/src/Infrastructure/BotSharp.Abstraction/Messaging/IRichMessage.cs b/src/Infrastructure/BotSharp.Abstraction/Messaging/IRichMessage.cs index 79cd06c8..e04692e6 100644 --- a/src/Infrastructure/BotSharp.Abstraction/Messaging/IRichMessage.cs +++ b/src/Infrastructure/BotSharp.Abstraction/Messaging/IRichMessage.cs @@ -1,3 +1,5 @@ +using BotSharp.Abstraction.Messaging.Enums; + namespace BotSharp.Abstraction.Messaging; public interface IRichMessage @@ -6,5 +8,5 @@ public interface IRichMessage string Text { get; set; } [JsonPropertyName("rich_type")] - string RichType => "text"; + string RichType => RichTypeEnum.Text; } diff --git a/src/Infrastructure/BotSharp.Abstraction/Routing/Models/RoutingRule.cs b/src/Infrastructure/BotSharp.Abstraction/Routing/Models/RoutingRule.cs index b0353ce6..e0eb1da3 100644 --- a/src/Infrastructure/BotSharp.Abstraction/Routing/Models/RoutingRule.cs +++ b/src/Infrastructure/BotSharp.Abstraction/Routing/Models/RoutingRule.cs @@ -23,6 +23,7 @@ public class RoutingRule public bool Required { get; set; } public string? RedirectTo { get; set; } + public string? RedirectToAgentName { get; set; } public override string ToString() { diff --git a/src/Infrastructure/BotSharp.OpenAPI/Controllers/AgentController.cs b/src/Infrastructure/BotSharp.OpenAPI/Controllers/AgentController.cs index 1a9389ef..5d7f7b56 100644 --- a/src/Infrastructure/BotSharp.OpenAPI/Controllers/AgentController.cs +++ b/src/Infrastructure/BotSharp.OpenAPI/Controllers/AgentController.cs @@ -29,7 +29,23 @@ public class AgentController : ControllerBase { AgentIds = new List { id } }); - return agents.Items.FirstOrDefault(); + + var targetAgent = agents.Items.FirstOrDefault(); + var redirectAgentIds = targetAgent.RoutingRules + .Where(x => !string.IsNullOrEmpty(x.RedirectTo)) + .Select(x => x.RedirectTo).ToList(); + var redirectAgents = await _agentService.GetAgents(new AgentFilter + { + AgentIds = redirectAgentIds + }); + foreach (var rule in targetAgent.RoutingRules) + { + var found = redirectAgents.Items.FirstOrDefault(x => x.Id == rule.RedirectTo); + if (found == null) continue; + + rule.RedirectToAgentName = found.Name; + } + return targetAgent; } [HttpGet("/agents")]