我已经在C#中创建了BOT框架并成功了,我想启用以下功能:
我的一个Intent Utterance必须点击API,这需要一段时间才能返回结果集。所以我想在我的BOT中处理等待时间,说'请等一下,我得到了结果'
如何在代码中处理此问题?这是我的代码片段:
public async Task GetClassListIntent(IDialogContext context, LuisResult result)
{
try
{
var message = context.MakeMessage();
ClassService classService = new ClassService();
IList< Result> Results = await classService.GetResults(criteria);
if (Results != null && Results.Count > 0)
{
foreach (var classresult in Results)
{
var attachment = Card.GetClassSearchResult(classresult);
message.Attachments.Add(attachment);
}
message.AttachmentLayout = AttachmentLayoutTypes.Carousel;
await context.PostAsync(message);
}
else
{
await context.PostAsync("No results found. Please provide more search details ");
await context.PostAsync(message);
}
}
...
}
答案 0 :(得分:2)
在处理开始时添加进度消息
await context.PostAsync("Please hold on a moment , I am getting the results");