使用activity.text而不是实际提示用户的瀑布提示 [英] Waterfall prompt using activity.text instead of actually prompting user
问题描述
我有一个对话框,其中跳过了第一步的提示.我确定发生的事情是step.context.activity.text会以某种方式自动解释为快速响应.例如,如果我使用加速我的订单"触发对话框,则第一步中的step.context.activity.text是加速我的订单",则跳过提示,而下一步中的step.result是加速我的订单"订单".
我尝试在步骤1中创建一个缓冲步骤",该操作只是执行 return await step.next()
,但是随后在步骤2中捕获了相同的activity.text作为提示响应!/p>
有趣的是,我使用mocha创建了一个模拟对话框测试,但没有出现这些问题.我在漫游器中还有其他对话框,在第一个步骤中也有文本提示,并且无论是在mocha测试中还是在仿真器中运行(或部署在Azure上),它们都没有出现这些问题.我确实注意到step.context内部有一个区别:正在运行的对话框为 step.context.responded = false
,而跳过提示的对话框为step.context.responded = true`.但是我不知道为什么在一种情况下而不是在其他情况下设置这种情况.这似乎是难题的重要组成部分.
我通过在步骤开始时设置 step.context.activity.text =''
来解决"此问题,但这似乎是一种不好的做法.关于为什么在此提示中发生这种情况有任何想法吗?下面是我第一步的对话框代码.
const {TextPrompt,ChoicePrompt,ChoiceFactory,ComponentDialog,WaterfallDialog} = require('botbuilder-dialogs');const {oemLocatorHelper} = require('../helpers/oemLocatorHelper');const WATERFALL_DIALOG ='waterfallDialog2';const CHOICE_PROMPT ='choicePrompt';const TEXT_PROMPT ='文本提示';const ESCALATION_OPTIONS = ['聊天','电子邮件','通话','不用了,谢谢]];类escalationDialog扩展了ComponentDialog {构造函数(dialogId,userDialogStateAccessor,userState){super(dialogId);this.addDialog(new ChoicePrompt(CHOICE_PROMPT));this.addDialog(new TextPrompt(TEXT_PROMPT));this.addDialog(new WaterfallDialog(WATERFALL_DIALOG,[this.promptAccount.bind(this),this.promptChannel.bind(this),this.promptSummary.bind(this)]));this.initialDialogId = WATERFALL_DIALOG;//状态访问器this.userDialogStateAccessor = userDialogStateAccessor;this.userState = userState;}//结束构造函数异步提示帐户(步骤){如果(step.context.responded){step.context.activity.text ='';}const userData =等待this.userDialogStateAccessor.get(step.context,{});如果(userData.accountNumber){返回userData.accountNumber;} 别的 {返回await step.prompt(TEXT_PROMPT,为帮助您找到合适的代理商,请您提供您的帐号给我?);}}
应该是step.context.activity.text,而不是step.activity.text.在几个地方进行了更新.而且,仅在step.context.responded为true时,更改现在才清除此值.
我相信问题是您的机器人程序在开始 escalationDialog
continueDialog >.我已经评论了您的私人GitHub问题.
I have a dialog where a prompt in the first step is getting skipped. I determined that what is happening is that somehow step.context.activity.text is automatically being interpreted as the prompt response. For example, if I trigger the dialog with "Expedite my order", step.context.activity.text in the first step is "Expedite my order", the prompt is skipped, and step.result in the next step is "Expedite my order".
I tried creating a "buffer step" as step 1 that just did return await step.next()
, but the same activity.text was then captured as the prompt response in step 2!
Interestingly, I created a mock dialog test with mocha and it did NOT exhibit these issues. I have other dialogs within the bot that also have a text prompt on step one and they are not exhibiting these issues either in mocha tests OR running in emulator (or deployed on Azure). I did note there is one difference within step.context: the dialogs that are working have step.context.responded = false
and the one which is skipping the prompt has step.context.responded = true`. But I have no idea why this is set in one case but not others. This seems to be an important part of the puzzle.
I did "solve" this by setting step.context.activity.text = ''
at the beginning of the step, but that seems like a bad practice. Any idea on why this is happening within this prompt? Below is my dialog code through that first step.
const { TextPrompt, ChoicePrompt, ChoiceFactory, ComponentDialog, WaterfallDialog } = require('botbuilder-dialogs');
const { oemLocatorHelper } = require('../helpers/oemLocatorHelper');
const WATERFALL_DIALOG = 'waterfallDialog2';
const CHOICE_PROMPT = 'choicePrompt';
const TEXT_PROMPT = 'textPrompt';
const ESCALATION_OPTIONS = ['Chat','Email','Call','No Thanks'];
class escalationDialog extends ComponentDialog {
constructor(dialogId, userDialogStateAccessor, userState) {
super(dialogId);
this.addDialog(new ChoicePrompt(CHOICE_PROMPT));
this.addDialog(new TextPrompt(TEXT_PROMPT));
this.addDialog(new WaterfallDialog(WATERFALL_DIALOG, [
this.promptAccount.bind(this),
this.promptChannel.bind(this),
this.promptSummary.bind(this)
]));
this.initialDialogId = WATERFALL_DIALOG;
// State accessors
this.userDialogStateAccessor = userDialogStateAccessor;
this.userState = userState;
} // End constructor
async promptAccount(step) {
if (step.context.responded) {
step.context.activity.text = '';
}
const userData = await this.userDialogStateAccessor.get(step.context, {});
if (userData.accountNumber) {
return userData.accountNumber;
} else {
return await step.prompt(TEXT_PROMPT, `To help me get you to the right agent, can you please provide me your account number?`);
}
}
EDIT: Should be step.context.activity.text, not step.activity.text. Updated in several spots. Also, the change now clears this value only if step.context.responded is true.
I believe the problem is that your bot class is calling continueDialog
on the same turn that it begins escalationDialog
. I have commented on your private GitHub issue.
这篇关于使用activity.text而不是实际提示用户的瀑布提示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!