BotSharp/src/Infrastructure/BotSharp.Core/Routing/Functions/FallbackToRouterFn.cs

26 lines
766 B
C#
Raw Normal View History

using BotSharp.Abstraction.Functions;
using BotSharp.Abstraction.Routing.Models;
namespace BotSharp.Core.Routing.Functions;
public class FallbackToRouterFn : IFunctionCallback
{
2025-02-25 04:35:22 +00:00
public string Name => "util-routing-fallback_to_router";
private readonly IServiceProvider _services;
2025-02-25 04:35:22 +00:00
public FallbackToRouterFn(IServiceProvider services)
{
_services = services;
}
public async Task<bool> Execute(RoleDialogModel message)
{
2025-02-25 04:35:22 +00:00
var args = JsonSerializer.Deserialize<FallbackArgs>(message.FunctionArgs);
2024-03-24 17:33:41 +00:00
var routing = _services.GetRequiredService<IRoutingService>();
2025-02-25 04:35:22 +00:00
routing.Context.PopTo(routing.Context.EntryAgentId, "pop to entry agent");
message.Content = args.Question;
return true;
}
}