diff --git a/src/Infrastructure/BotSharp.Abstraction/Rules/IRuleTrigger.cs b/src/Infrastructure/BotSharp.Abstraction/Rules/IRuleTrigger.cs index c7ad59d9a..bc762bb92 100644 --- a/src/Infrastructure/BotSharp.Abstraction/Rules/IRuleTrigger.cs +++ b/src/Infrastructure/BotSharp.Abstraction/Rules/IRuleTrigger.cs @@ -21,4 +21,10 @@ public interface IRuleTrigger /// Explain the purpose of rule trigger (display purpose) /// string Statement => string.Empty; + + /// + /// Optional list of agent IDs this trigger is associated with. + /// Used for display/filtering in UI only (not used in execution logic). + /// + string[]? AgentIds => null; } diff --git a/src/Infrastructure/BotSharp.OpenAPI/Controllers/Agent/AgentController.Rule.cs b/src/Infrastructure/BotSharp.OpenAPI/Controllers/Agent/AgentController.Rule.cs index 43cf228c4..529ae883f 100644 --- a/src/Infrastructure/BotSharp.OpenAPI/Controllers/Agent/AgentController.Rule.cs +++ b/src/Infrastructure/BotSharp.OpenAPI/Controllers/Agent/AgentController.Rule.cs @@ -5,6 +5,29 @@ namespace BotSharp.OpenAPI.Controllers; public partial class AgentController { + [HttpGet("/rule/triggers/{agentId}")] + public ActionResult> GetRuleTriggers(string agentId) + { + if (string.IsNullOrWhiteSpace(agentId)) + { + return BadRequest("agentId is required"); + } + + var triggers = _services.GetServices() + .Where(x => + { + var agentIds = x.AgentIds; + return agentIds == null || agentIds.Contains(agentId, StringComparer.OrdinalIgnoreCase); + }); + return Ok(triggers.Select(x => new AgentRuleViewModel + { + TriggerName = x.Name, + Channel = x.Channel, + Statement = x.Statement, + OutputArgs = x.OutputArgs + }).OrderBy(x => x.TriggerName)); + } + [HttpGet("/rule/triggers")] public IEnumerable GetRuleTriggers() {