Skip to content
6 changes: 6 additions & 0 deletions src/Infrastructure/BotSharp.Abstraction/Rules/IRuleTrigger.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,10 @@ public interface IRuleTrigger
/// Explain the purpose of rule trigger (display purpose)
/// </summary>
string Statement => string.Empty;

/// <summary>
/// Optional list of agent IDs this trigger is associated with.
/// Used for display/filtering in UI only (not used in execution logic).
/// </summary>
string[]? AgentIds => null;
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,23 @@ namespace BotSharp.OpenAPI.Controllers;

public partial class AgentController
{
[HttpGet("/rule/triggers/{agentId}")]
public IEnumerable<AgentRuleViewModel> GetRuleTriggers(string agentId)
{
var triggers = _services.GetServices<IRuleTrigger>();
if (!string.IsNullOrWhiteSpace(agentId))
{
triggers = triggers.Where(x => x.AgentIds == null || x.AgentIds.Contains(agentId, StringComparer.OrdinalIgnoreCase));
}
return 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<AgentRuleViewModel> GetRuleTriggers()
{
Expand Down
Loading