Skip to content

Commit f498c62

Browse files
author
Visagan Guruparan
committed
Add optional agentId to ruleTrigger for easy filtering on UI
1 parent 9b74463 commit f498c62

2 files changed

Lines changed: 20 additions & 0 deletions

File tree

src/Infrastructure/BotSharp.Abstraction/Rules/IRuleTrigger.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff 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 => [];
2430
}

src/Infrastructure/BotSharp.OpenAPI/Controllers/Agent/AgentController.Rule.cs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,20 @@ namespace BotSharp.OpenAPI.Controllers;
55

66
public partial class AgentController
77
{
8+
[HttpGet("/rule/triggers/{agentId}")]
9+
public IEnumerable<AgentRuleViewModel> GetRuleTriggers(string agentId)
10+
{
11+
var triggers = _services.GetServices<IRuleTrigger>();
12+
triggers = triggers.Where(x => x.AgentIds?.Count() == 0 || x.AgentIds.Contains(agentId));
13+
return triggers.Select(x => new AgentRuleViewModel
14+
{
15+
TriggerName = x.Name,
16+
Channel = x.Channel,
17+
Statement = x.Statement,
18+
OutputArgs = x.OutputArgs
19+
}).OrderBy(x => x.TriggerName);
20+
}
21+
822
[HttpGet("/rule/triggers")]
923
public IEnumerable<AgentRuleViewModel> GetRuleTriggers()
1024
{

0 commit comments

Comments
 (0)