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

25 lines
662 B
C#
Raw Normal View History

2023-10-13 20:08:59 +00:00
using BotSharp.Abstraction.Conversations;
2023-08-30 22:40:45 +00:00
using BotSharp.Abstraction.Conversations.Models;
namespace BotSharp.Plugin.PizzaBot.Functions;
2023-09-06 03:19:36 +00:00
public class PlaceOrderFn : IFunctionCallback
2023-08-30 22:40:45 +00:00
{
2023-09-06 03:19:36 +00:00
public string Name => "place_an_order";
2023-08-30 22:40:45 +00:00
2023-10-13 20:08:59 +00:00
private readonly IServiceProvider _service;
public PlaceOrderFn(IServiceProvider service)
{
_service = service;
}
2023-08-30 22:40:45 +00:00
public async Task<bool> Execute(RoleDialogModel message)
{
message.ExecutionResult = "The order number is P123-01";
2023-10-13 20:08:59 +00:00
var state = _service.GetRequiredService<IConversationStateService>();
state.SetState("order_number", "P123-01");
2023-08-30 22:40:45 +00:00
return true;
}
}