gpt4 book ai didi

c# - 如何在 MessageController.cs Post 方法中使用 PromptDialog.Confirm()

转载 作者:行者123 更新时间:2023-12-03 01:48:44 24 4
gpt4 key购买 nike

我想在聊天窗口中提示带有"is"或“否”选项的问题,

public class MessagesController : ApiController
{
public virtual async Task<HttpResponseMessage> Post([FromBody] Activity activity)
{
ConnectorClient connector = new ConnectorClient(new Uri(activity.ServiceUrl));
Activity reply;

if (activity != null)
{
// check if activity is of type message
if (activity.Type == ActivityTypes.Message)
{
await GetEntityFromLUIS(activity);
}
else if (activity.Type == ActivityTypes.ConversationUpdate)
{
constructResponse = "Hi";
reply = activity.CreateReply($"{constructResponse}");
await connector.Conversations.ReplyToActivityAsync(reply); //After this we need Prompt question with Yes r No
}
}
else
{
connector = new ConnectorClient(new Uri(activity.ServiceUrl));

HandleSystemMessage(activity);
}

return new HttpResponseMessage(System.Net.HttpStatusCode.Accepted);
}
}

如何在显示Hi后用**有问题**和提示问题。下面的代码旁边

reply = activity.CreateReply($"{constructResponse}");
await connector.Conversations.ReplyToActivityAsync(reply);

最佳答案

您可以像这样使用PromptDialog.Confirm

PromptDialog.Confirm(context, Confirmed,"Have question");

Confirmed() 在用户回答后发生

public async Task Confirmed(IDialogContext context, IAwaitable<bool> argument)
{
bool isCorrect = await argument;
if (isCorrect)
{ }
else
{ }
}

关于c# - 如何在 MessageController.cs Post 方法中使用 PromptDialog.Confirm(),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42417357/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com