c# - 有没有办法可以与 luis 链接对话
问题描述
我试图从我的路易斯意图中调用一个对话。但我收到错误。请检查我的代码。它到达 UserInteraction 对话框,但控件没有转到 Getuser purpose。它显示错误“我的机器人代码有问题”
我尝试调试,发现控件在 StartAsync 任务之后转移到 Webapi 配置类。
[LuisIntent("Getfile")]
public async Task GetfileIntent(IDialogContext context, LuisResult result)
{
await context.PostAsync("Sure we can help you on that... ");
//PromptDialog.Text(context, UserEnteredInfo, "can you please provide us with below info. " +
// "Purpose" + "Client name" + "Team Name");
await context.PostAsync("But first i need to know the purpose ");
// Conversation.SendAsync(Activity, () => new UserInteraction());
context.Call(new UserInteraction(),ResumeAfterFeedback);
}
private async Task ResumeAfterFeedback(IDialogContext context, IAwaitable<object> result)
{
await context.PostAsync("Prepared an email for you");
context.Wait(MessageReceived);
}
[Serializable]
public class UserInteraction : IDialog<object>
{
protected string Purpose { get; set; }
protected string ClientName { get; set; }
protected string Teamname { get; set; }
public async Task StartAsync(IDialogContext context)
{
await context.PostAsync("Please enter the purpose");
// context.Wait(this.MessageReceivedAsync);
context.Wait(Getuserpurpose);
}
public async Task Getuserpurpose(IDialogContext context, IAwaitable<IMessageActivity> argument)
{
var message = await argument;
this.Purpose = message.Text;
await context.PostAsync("Now please tell me the client name");
context.Wait(Getuserclient);
}
解决方案
我刚刚对此进行了测试,它确实按预期工作。
[LuisIntent("Getfile")]
public async Task GetfileIntent(IDialogContext context, LuisResult result)
{
await context.PostAsync("Sure we can help you on that... ");
await context.PostAsync("But first i need to know the purpose ");
context.Call(new UserInteraction(),ResumeAfterFeedback);
}
private async Task ResumeAfterFeedback(IDialogContext context, IAwaitable<object> result)
{
var interactionResult = await result as UserInteraction;
await context.PostAsync("Prepared an email for you");
context.Wait(MessageReceived);
}
[Serializable]
public class UserInteraction : IDialog<object>
{
protected string Purpose { get; set; }
protected string ClientName { get; set; }
protected string Teamname { get; set; }
public async Task StartAsync(IDialogContext context)
{
await context.PostAsync("Please enter the purpose");
context.Wait(Getuserpurpose);
}
public async Task Getuserpurpose(IDialogContext context, IAwaitable<IMessageActivity> argument)
{
var message = await argument;
this.Purpose = message.Text;
await context.PostAsync("Now please tell me the client name");
context.Wait(Getuserclient);
}
private async Task Getuserclient(IDialogContext context, IAwaitable<IMessageActivity> result)
{
var message = await result;
ClientName = message.Text;
await context.PostAsync("Now please tell me Team Name");
context.Wait(GetUserTeamName);
}
private async Task GetUserTeamName(IDialogContext context, IAwaitable<IMessageActivity> result)
{
var message = await result;
Teamname = message.Text;
await context.PostAsync("Got it");
context.Done(this);
}
}
推荐阅读
- sql-server - 无法拖放表以进行查询(SQL Server)
- python - 如何将单元格公式复制到上面的 1 行,但引用新行的数据(而不是前一行的数据)
- javascript - 无法使用 replaceWith() 将值绑定到工具提示
- apache-flink - 过滤apache flink中的唯一事件
- scrapy - 在scrapy管道中访问蜘蛛属性好吗?
- reactjs - 无法读取未定义的属性“地图”,因为减速器有问题
- git - 大型测试数据文件和github
- c# - 如何将 C# 代码重写为 python - 计算 SHA1
- java - 在类的私有静态最终变量中使用动态类名
- android - 如何实现灵活且即时的应用内更新