diff --git a/src/Infrastructure/BotSharp.Core/Routing/Prompts/router_prompt.liquid b/src/Infrastructure/BotSharp.Core/Routing/Prompts/router_prompt.liquid index e118dd71..83a743d6 100644 --- a/src/Infrastructure/BotSharp.Core/Routing/Prompts/router_prompt.liquid +++ b/src/Infrastructure/BotSharp.Core/Routing/Prompts/router_prompt.liquid @@ -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: \ No newline at end of file diff --git a/src/WebStarter/data/agents/c2b57a74-ae4e-4c81-b3ad-9ac5bff982bd/instruction.liquid b/src/WebStarter/data/agents/c2b57a74-ae4e-4c81-b3ad-9ac5bff982bd/instruction.liquid index 6368d9b4..eacd4dc1 100644 --- a/src/WebStarter/data/agents/c2b57a74-ae4e-4c81-b3ad-9ac5bff982bd/instruction.liquid +++ b/src/WebStarter/data/agents/c2b57a74-ae4e-4c81-b3ad-9ac5bff982bd/instruction.liquid @@ -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}}. \ No newline at end of file diff --git a/src/WebStarter/data/agents/fe8c60aa-b114-4ef3-93cb-a8efeac80f75/agent.json b/src/WebStarter/data/agents/fe8c60aa-b114-4ef3-93cb-a8efeac80f75/agent.json index 352c3ea7..72959d11 100644 --- a/src/WebStarter/data/agents/fe8c60aa-b114-4ef3-93cb-a8efeac80f75/agent.json +++ b/src/WebStarter/data/agents/fe8c60aa-b114-4ef3-93cb-a8efeac80f75/agent.json @@ -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" } ] } \ No newline at end of file diff --git a/src/WebStarter/data/agents/fe8c60aa-b114-4ef3-93cb-a8efeac80f75/functions.json b/src/WebStarter/data/agents/fe8c60aa-b114-4ef3-93cb-a8efeac80f75/functions.json index 34818014..b9219dfe 100644 --- a/src/WebStarter/data/agents/fe8c60aa-b114-4ef3-93cb-a8efeac80f75/functions.json +++ b/src/WebStarter/data/agents/fe8c60aa-b114-4ef3-93cb-a8efeac80f75/functions.json @@ -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"] } } ] diff --git a/tests/BotSharp.Plugin.PizzaBot/Functions/MakePaymentFn.cs b/tests/BotSharp.Plugin.PizzaBot/Functions/MakePaymentFn.cs new file mode 100644 index 00000000..16c1e9ef --- /dev/null +++ b/tests/BotSharp.Plugin.PizzaBot/Functions/MakePaymentFn.cs @@ -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 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; + } +} diff --git a/tests/BotSharp.Plugin.PizzaBot/PizzaBotPlugin.cs b/tests/BotSharp.Plugin.PizzaBot/PizzaBotPlugin.cs index 1cc5ac5c..bc106e70 100644 --- a/tests/BotSharp.Plugin.PizzaBot/PizzaBotPlugin.cs +++ b/tests/BotSharp.Plugin.PizzaBot/PizzaBotPlugin.cs @@ -13,6 +13,7 @@ public class PizzaBotPlugin : IBotSharpPlugin services.AddScoped(); services.AddScoped(); services.AddScoped(); + services.AddScoped(); // Register hooks services.AddScoped();