Skip to content

Commit a56d770

Browse files
committed
Add make_payment to PizzaBot.
1 parent 6524dc7 commit a56d770

File tree

6 files changed

+31
-6
lines changed

6 files changed

+31
-6
lines changed

src/Infrastructure/BotSharp.Core/Routing/Prompts/router_prompt.liquid

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,6 @@ Reach out to a real customer representative to help.
2626
{{ reasoning_functions }}
2727

2828
### Your response must meet below requirements strictly
29-
* If you can find an appropriate Agent, you must call appropriate function with required arguments.
29+
* If you can find an appropriate Agent, you must call function route_to_agent with required arguments.
3030

3131
### Below are the dialogs between user and different agents:

src/WebStarter/data/agents/c2b57a74-ae4e-4c81-b3ad-9ac5bff982bd/instruction.liquid

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ Follow below step to place order:
44
1: Ask user preferences.
55
2: Confirm with user the pizza type and quantity.
66
3: Call function place_an_order to purchase.
7+
4: Proceed to make payment for this order.
78

89
Use below information to help ordering process:
910
* Today is {{current_date}}, the time now is {{current_time}}, day of week is {{current_weekday}}.
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
{
22
"name": "Payment",
3-
"description": "Make payment when user placed new order.",
3+
"description": "Make payment when user placed new order and system returned the order number.",
44
"createdDateTime": "2023-07-26T02:29:25.123224Z",
55
"updatedDateTime": "2023-07-26T02:29:25.123274Z",
6-
"id": "c2b57a74-ae4e-4c81-b3ad-9ac5bff982bd",
6+
"id": "fe8c60aa-b114-4ef3-93cb-a8efeac80f75",
77
"allowRouting": true,
88
"routingRules": [
99
{
1010
"field": "order_number",
1111
"required": true,
12-
"redirectTo": "ff431273-0c28-4647-88bf-86d82443c579"
12+
"redirectTo": "c2b57a74-ae4e-4c81-b3ad-9ac5bff982bd"
1313
}
1414
]
1515
}
Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,20 @@
11
[
22
{
33
"name": "make_payment",
4-
"description": "call this function to make payment",
4+
"description": "call this function to make payment after system returned the order number",
55
"parameters": {
66
"type": "object",
77
"properties": {
88
"order_number": {
99
"type": "string",
1010
"description": "order number."
11+
},
12+
"total_amount": {
13+
"type": "string",
14+
"description": "total amount."
1115
}
1216
},
13-
"required": ["order_number"]
17+
"required": ["order_number", "total_amount"]
1418
}
1519
}
1620
]
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
using BotSharp.Abstraction.Conversations.Models;
2+
3+
namespace BotSharp.Plugin.PizzaBot.Functions;
4+
5+
public class MakePaymentFn : IFunctionCallback
6+
{
7+
public string Name => "make_payment";
8+
9+
public async Task<bool> Execute(RoleDialogModel message)
10+
{
11+
message.ExecutionResult = "Payment proceed successfully. Thank you for your business. Have a great day!";
12+
message.ExecutionData = new
13+
{
14+
Transaction = Guid.NewGuid().ToString(),
15+
Status = "Success"
16+
};
17+
return true;
18+
}
19+
}

tests/BotSharp.Plugin.PizzaBot/PizzaBotPlugin.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ public void RegisterDI(IServiceCollection services, IConfiguration config)
1313
services.AddScoped<IFunctionCallback, PlaceOrderFn>();
1414
services.AddScoped<IFunctionCallback, OrderFoundFn>();
1515
services.AddScoped<IFunctionCallback, GetDeliveryTimeFn>();
16+
services.AddScoped<IFunctionCallback, MakePaymentFn>();
1617

1718
// Register hooks
1819
services.AddScoped<IAgentHook, PizzaBotAgentHook>();

0 commit comments

Comments
 (0)