考虑此情况:
有人可以请您解释这种活动发生了什么以及如何正确处理(通过重新启动我的整个引用参数对话框)
谢谢!!!PS。我为我的机器人使用NodeJs SDK,(机器人框架V4)
编辑:(感谢您很好地询问代码示例以全面了解场景,我还将添加一些屏幕快照以使问题可视化)
因此,此代码在ReferralDialog的瀑布阶段之一内,该阶段专门要求用户确认。
await step.context.sendActivity("Doesn’t that sound easy?");
await step.context.sendActivity({ type: 'typing'});
return await step.prompt(CONFIRM_PROMPT, 'Now, would you like to apply?', ['yes', 'no']);
瀑布的下一阶段包含以下代码片段:
if(step.result)
{
await step.context.sendActivity("And to protect your privacy from prying eyes, I will bring you outside of messenger to a secure East West owned chat environment");
return await step.endDialog();
}
else
{
await step.context.sendActivity("Thank you ! If you change your mind, please click the link your referrer sent you again to re-enter the program.");
return await step.endDialog();
}
在主对话框中(摘要)://通过fb但带有ref(已经进行了交互)
else if(channelData && channelData.referral && channelData.referral.ref && stepContext.context.activity.channelId === 'facebook')
{
return await stepContext.beginDialog(REFERRAL_DIALOG, userData);}
因此,假设是:如果用户说单击是/否,将显示一条消息:(但是有些疯狂的用户再次单击了引荐链接)
所以我们现在出现此错误:
第二和第三张图片是针对机器人的响应:Messenger promptMessenger error
错误消息,发生在index.js中,具有以下代码:(它是从框架预设的,我从不更改/对该代码做任何事情)
// Catch-all for errors.
adapter.onTurnError = async (context, error) => {
// This check writes out errors to console log .vs. app insights.
// NOTE: In production environment, you should consider logging this to Azure
// application insights.
console.error(`\n [onTurnError] unhandled error: ${ error }`);
// Send a trace activity, which will be displayed in Bot Framework Emulator
await context.sendTraceActivity(
'OnTurnError Trace',
`${ error }`,
'https://www.botframework.com/schemas/error',
'TurnError'
);
// Send a message to the user
let onTurnErrorMessage = 'The bot encounted an error or bug.';
await context.sendActivity(onTurnErrorMessage, onTurnErrorMessage, InputHints.ExpectingInput);
onTurnErrorMessage = 'To continue to run this bot, please fix the bot source code.';
await context.sendActivity(onTurnErrorMessage, onTurnErrorMessage, InputHints.ExpectingInput);
await context.sendActivity(error);
// Clear out state
await conversationState.delete(context);
};
而且我的机器人唯一的toLowerCase代码可以在CancelAndHelpDialog中找到(而且我没有定义,但添加了一些内容:
class CancelAndHelpDialog extends ComponentDialog {
async onContinueDialog(innerDc) {
const result = await this.interrupt(innerDc);
if (result) {
console.log("Bot was interrupted");
return result;
}
return await super.onContinueDialog(innerDc);
}
async interrupt(innerDc) {
console.log("Interrupt");
let interruptData=innerDc.context.activity;
if (interruptData && interruptData.text) {
console.log("uhhhhhhhhhmmm" + typeof innerDc.context.activity.text);
const text = innerDc.context.activity.text.toLowerCase();
switch (text) {
case 'help':
case '?': {
const helpMessageText = 'Call our customer service 8888-1700 for further assistance.';
await innerDc.context.sendActivity(helpMessageText, helpMessageText, InputHints.ExpectingInput);
return { status: DialogTurnStatus.waiting };
}
case 'cancel':
case 'quit': {
const cancelMessageText = 'Cancelling...';
await innerDc.context.sendActivity(cancelMessageText, cancelMessageText, InputHints.IgnoringInput);
return await innerDc.cancelAllDialogs();
}
}
}
}
}
这真是奇怪,为什么我在CancelAndHelpDialog中添加的所有console.log()都不会显示,更重要的是(重申一下),除了该对话框之外,我没有其他toLowerCase代码。
谢谢!
编辑:由于问题是用户出错,因此我找到了一种方法来更改onContinueDialog并提示用户重新单击该链接。 [呵呵
async onContinueDialog(innerDc) {
console.log("This is at oncontinue Dialog");
console.log("\n\r This is the channel Data" + JSON.stringify(innerDc.context.activity.channelData));
let interruptData=innerDc.context.activity;
if(interruptData.channelData.referral && interruptData.channelData.referral.ref)
{
await innerDc.context.sendActivity("Sorry I didn't catch it. Kindly click the link again.");
return await innerDc.cancelAllDialogs();
}
else
{
const result = await this.interrupt(innerDc);
console.log("The result: " + JSON.stringify(result));
if (result) {
console.log("Bot was interrupted");
return result;
}
return await super.onContinueDialog(innerDc);
}
}
以这种方式,用户被迫重新单击链接并重新启动所有对话框。