如何使用节点 js 结束机器人框架中的对话
how to end coversation in bot framework using node js
我正在使用触发操作和结束对话来结束我的聊天..但是它关闭了当前的聊天对话框...
我要结束聊天记录或数据....
我正在尝试这段代码..
bot.dialog('/end', function (session) {
session.endConversation("End Conversation");
}).triggerAction({ matches: /^(exit)|(quit)/i });
您可以尝试使用
session.clearDialogStack()
或
session.reset();
session.endDialog();
在这里您可以找到关于 reset and here about clearDialogStack 的信息。
You can use the command “/deleteprofile” to delete the
User/PrivateConversation bot data bag state and reset your bot. Note,
some channels interpret slash-commands natively, so it may be
necessary to send the command with a space in front (“
/deleteprofile”)
从这里开始:https://docs.botframework.com/en-us/technical-faq#my-bot-is-stuck--how-can-i-reset-the-conversation
您可以使用这个简单的中间件来清除 userData/conversationData 包:
export interface IResetDataSettings {
resetCommand: RegExp;
}
export class ResetMiddleware {
public static data(settings: IResetDataSettings): IMiddlewareMap {
return {
botbuilder: (session, next) => {
if (settings.resetCommand && session.message.text && settings.resetCommand.test(session.message.text)) {
session.userData = {};
session.conversationData = {};
session.privateConversationData = {};
session.endConversation("Your conversation state was reset.");
} else {
next();
}
}
};
}
}
然后这样设置:
this.bot.use(ResetMiddleware.data({ resetCommand: /^reset data$/i }));
delete session.userData;
这对我有用。
我正在使用触发操作和结束对话来结束我的聊天..但是它关闭了当前的聊天对话框... 我要结束聊天记录或数据....
我正在尝试这段代码..
bot.dialog('/end', function (session) {
session.endConversation("End Conversation");
}).triggerAction({ matches: /^(exit)|(quit)/i });
您可以尝试使用
session.clearDialogStack()
或
session.reset();
session.endDialog();
在这里您可以找到关于 reset and here about clearDialogStack 的信息。
You can use the command “/deleteprofile” to delete the User/PrivateConversation bot data bag state and reset your bot. Note, some channels interpret slash-commands natively, so it may be necessary to send the command with a space in front (“ /deleteprofile”)
从这里开始:https://docs.botframework.com/en-us/technical-faq#my-bot-is-stuck--how-can-i-reset-the-conversation
您可以使用这个简单的中间件来清除 userData/conversationData 包:
export interface IResetDataSettings {
resetCommand: RegExp;
}
export class ResetMiddleware {
public static data(settings: IResetDataSettings): IMiddlewareMap {
return {
botbuilder: (session, next) => {
if (settings.resetCommand && session.message.text && settings.resetCommand.test(session.message.text)) {
session.userData = {};
session.conversationData = {};
session.privateConversationData = {};
session.endConversation("Your conversation state was reset.");
} else {
next();
}
}
};
}
}
然后这样设置:
this.bot.use(ResetMiddleware.data({ resetCommand: /^reset data$/i }));
delete session.userData;
这对我有用。