File tree Expand file tree Collapse file tree
BotSharp.Abstraction/Rules
BotSharp.OpenAPI/Controllers/Agent Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -21,4 +21,10 @@ public interface IRuleTrigger
2121 /// Explain the purpose of rule trigger (display purpose)
2222 /// </summary>
2323 string Statement => string . Empty ;
24+
25+ /// <summary>
26+ /// Optional list of agent IDs this trigger is associated with.
27+ /// Used for display/filtering in UI only (not used in execution logic).
28+ /// </summary>
29+ string [ ] ? AgentIds => null ;
2430}
Original file line number Diff line number Diff line change @@ -5,6 +5,29 @@ namespace BotSharp.OpenAPI.Controllers;
55
66public partial class AgentController
77{
8+ [ HttpGet ( "/rule/triggers/{agentId}" ) ]
9+ public ActionResult < IEnumerable < AgentRuleViewModel > > GetRuleTriggers ( string agentId )
10+ {
11+ if ( string . IsNullOrWhiteSpace ( agentId ) )
12+ {
13+ return BadRequest ( "agentId is required" ) ;
14+ }
15+
16+ var triggers = _services . GetServices < IRuleTrigger > ( )
17+ . Where ( x =>
18+ {
19+ var agentIds = x . AgentIds ;
20+ return agentIds == null || agentIds . Contains ( agentId , StringComparer . OrdinalIgnoreCase ) ;
21+ } ) ;
22+ return Ok ( triggers . Select ( x => new AgentRuleViewModel
23+ {
24+ TriggerName = x . Name ,
25+ Channel = x . Channel ,
26+ Statement = x . Statement ,
27+ OutputArgs = x . OutputArgs
28+ } ) . OrderBy ( x => x . TriggerName ) ) ;
29+ }
30+
831 [ HttpGet ( "/rule/triggers" ) ]
932 public IEnumerable < AgentRuleViewModel > GetRuleTriggers ( )
1033 {
You can’t perform that action at this time.
0 commit comments