BotSharp/tests/BotSharp.Plugin.PizzaBot/Functions/PlaceOrderFn.cs

29 lines
836 B
C#
Raw Normal View History

2025-03-28 01:46:01 +00:00
using BotSharp.Abstraction.Conversations;
using BotSharp.Abstraction.Conversations.Models;
2025-04-26 18:05:15 +00:00
using BotSharp.Abstraction.Infrastructures.Enums;
2023-08-30 22:40:45 +00:00
2025-03-28 01:46:01 +00:00
namespace BotSharp.Plugin.PizzaBot.Functions;
2023-08-30 22:40:45 +00:00
2025-03-28 01:46:01 +00:00
public class PlaceOrderFn : IFunctionCallback
{
2025-04-26 18:05:15 +00:00
public string Name => "place_order";
2023-08-30 22:40:45 +00:00
2025-03-28 01:46:01 +00:00
private readonly IServiceProvider _service;
public PlaceOrderFn(IServiceProvider service)
{
_service = service;
}
2023-10-13 20:08:59 +00:00
2025-03-28 01:46:01 +00:00
public async Task<bool> Execute(RoleDialogModel message)
{
message.Content = "The order number is P123-01";
var state = _service.GetRequiredService<IConversationStateService>();
state.SetState("order_number", "P123-01");
2023-10-13 20:08:59 +00:00
2025-04-26 18:05:15 +00:00
// Set the next action agent to Payment
state.SetState(StateConst.EXPECTED_ACTION_AGENT, "Payment", activeRounds: 2);
2025-03-28 01:46:01 +00:00
return true;
}
}