diff --git a/src/Infrastructure/BotSharp.Abstraction/Routing/IRoutingService.cs b/src/Infrastructure/BotSharp.Abstraction/Routing/IRoutingService.cs index 3ba73ee50..170276520 100644 --- a/src/Infrastructure/BotSharp.Abstraction/Routing/IRoutingService.cs +++ b/src/Infrastructure/BotSharp.Abstraction/Routing/IRoutingService.cs @@ -11,6 +11,7 @@ public interface IRoutingService List GetHandlers(); void ResetRecursiveCounter(); Task InvokeAgent(string agentId, List dialogs); + Task InvokeFunction(string name, RoleDialogModel message); Task InstructLoop(RoleDialogModel message); /// diff --git a/src/Infrastructure/BotSharp.Core/Routing/RoutingService.InvokeFunction.cs b/src/Infrastructure/BotSharp.Core/Routing/RoutingService.InvokeFunction.cs new file mode 100644 index 000000000..7d142c7dc --- /dev/null +++ b/src/Infrastructure/BotSharp.Core/Routing/RoutingService.InvokeFunction.cs @@ -0,0 +1,14 @@ +using BotSharp.Abstraction.Functions; + +namespace BotSharp.Core.Routing; + +public partial class RoutingService +{ + public async Task InvokeFunction(string name, RoleDialogModel message) + { + var function = _services.GetServices().FirstOrDefault(x => x.Name == name); + if (function == null) return false; + + return await function.Execute(message); + } +}