Add make_payment to PizzaBot.

This commit is contained in:
Haiping Chen 2023-09-20 05:59:27 -05:00
parent 6524dc75f4
commit a56d770e27
6 changed files with 31 additions and 6 deletions

View file

@ -26,6 +26,6 @@ Reach out to a real customer representative to help.
{{ reasoning_functions }}
### Your response must meet below requirements strictly
* If you can find an appropriate Agent, you must call appropriate function with required arguments.
* If you can find an appropriate Agent, you must call function route_to_agent with required arguments.
### Below are the dialogs between user and different agents:

View file

@ -4,6 +4,7 @@ Follow below step to place order:
1: Ask user preferences.
2: Confirm with user the pizza type and quantity.
3: Call function place_an_order to purchase.
4: Proceed to make payment for this order.
Use below information to help ordering process:
* Today is {{current_date}}, the time now is {{current_time}}, day of week is {{current_weekday}}.

View file

@ -1,15 +1,15 @@
{
"name": "Payment",
"description": "Make payment when user placed new order.",
"description": "Make payment when user placed new order and system returned the order number.",
"createdDateTime": "2023-07-26T02:29:25.123224Z",
"updatedDateTime": "2023-07-26T02:29:25.123274Z",
"id": "c2b57a74-ae4e-4c81-b3ad-9ac5bff982bd",
"id": "fe8c60aa-b114-4ef3-93cb-a8efeac80f75",
"allowRouting": true,
"routingRules": [
{
"field": "order_number",
"required": true,
"redirectTo": "ff431273-0c28-4647-88bf-86d82443c579"
"redirectTo": "c2b57a74-ae4e-4c81-b3ad-9ac5bff982bd"
}
]
}

View file

@ -1,16 +1,20 @@
[
{
"name": "make_payment",
"description": "call this function to make payment",
"description": "call this function to make payment after system returned the order number",
"parameters": {
"type": "object",
"properties": {
"order_number": {
"type": "string",
"description": "order number."
},
"total_amount": {
"type": "string",
"description": "total amount."
}
},
"required": ["order_number"]
"required": ["order_number", "total_amount"]
}
}
]

View file

@ -0,0 +1,19 @@
using BotSharp.Abstraction.Conversations.Models;
namespace BotSharp.Plugin.PizzaBot.Functions;
public class MakePaymentFn : IFunctionCallback
{
public string Name => "make_payment";
public async Task<bool> Execute(RoleDialogModel message)
{
message.ExecutionResult = "Payment proceed successfully. Thank you for your business. Have a great day!";
message.ExecutionData = new
{
Transaction = Guid.NewGuid().ToString(),
Status = "Success"
};
return true;
}
}

View file

@ -13,6 +13,7 @@ public class PizzaBotPlugin : IBotSharpPlugin
services.AddScoped<IFunctionCallback, PlaceOrderFn>();
services.AddScoped<IFunctionCallback, OrderFoundFn>();
services.AddScoped<IFunctionCallback, GetDeliveryTimeFn>();
services.AddScoped<IFunctionCallback, MakePaymentFn>();
// Register hooks
services.AddScoped<IAgentHook, PizzaBotAgentHook>();