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,29 @@ namespace BotSharp.OpenAPI.Controllers;

public partial class AgentController
{
[HttpGet("/rule/triggers/{agentId}")]
public ActionResult<IEnumerable<AgentRuleViewModel>> GetRuleTriggers(string agentId)
{
if (string.IsNullOrWhiteSpace(agentId))
{
return BadRequest("agentId is required");
}

var triggers = _services.GetServices<IRuleTrigger>()
.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<AgentRuleViewModel> GetRuleTriggers()
{
Expand Down
Loading