如何为使用微软机器人框架构建的团队机器人提供动态流程?
How to have dynamic flow for teams bot built using microsoft bot framework?
我创建了一个由选项卡和机器人组成的 Microsoft 团队应用程序。我将此作为 reference 创建团队插件。在这里,我使用了机器人框架建议的瀑布流模型。在使用它时我必须给出固定数量的动作,但我想要动态动作。这是示例
class MainDialog extends ComponentDialog {
constructor(luisRecognizer, bookingDialog) {
super('MainDialog');
if (!luisRecognizer) throw new Error('[MainDialog]: Missing parameter \'luisRecognizer\' is required');
this.luisRecognizer = luisRecognizer;
if (!bookingDialog) throw new Error('[MainDialog]: Missing parameter \'bookingDialog\' is required');
// Define the main dialog and its related components.
// This is a sample "book a flight" dialog.
this.addDialog(new TextPrompt(TEXT_PROMPT))
.addDialog(bookingDialog)
.addDialog(nominationDialogue)
.addDialog(new ChoicePrompt(CHOICE_PROMPT))
.addDialog(new WaterfallDialog(MAIN_WATERFALL_DIALOG, [
this.introStep.bind(this),
this.decidestep.bind(this),
this.originStep.bind(this),
this.actStep.bind(this),
this.Actualstep.bind(this)
]));
this.initialDialogId = MAIN_WATERFALL_DIALOG;
}
/**
* The run method handles the incoming activity (in the form of a TurnContext) and passes it through the dialog system.
* If no dialog is active, it will start the default dialog.
* @param {*} turnContext
* @param {*} accessor
*/
async run(turnContext, accessor) {
const dialogSet = new DialogSet(accessor);
dialogSet.add(this);
const dialogContext = await dialogSet.createContext(turnContext);
const results = await dialogContext.continueDialog();
if (results && results.status === DialogTurnStatus.empty) {
await dialogContext.beginDialog(this.id);
}
}
我怎样才能毫无问题地转到上一个函数,即 actStep 到 decidesStep 。我尝试从 actStep 调用 decideStep 然后我遇到异常并且机器人失败。当有一些重复性的工作要做时,由于动作数量固定,我无法完成。
提前致谢。
您能否查看 Conversation Bot 的示例代码。
您可以找到更多示例解决方案here
我遇到了同样的问题,我使用类似下面的代码 (C#) 解决了它。它不干净(有点 hack)但它有效
private static async Task<DialogTurnResult> actStep (WaterfallStepContext stepContext, CancellationToken cancellationToken)
{
.
.
.
stepContext.ActiveDialog.State["stepIndex"] = (int)stepContext.ActiveDialog.State["stepIndex"] - 2;
return await stepContext.NextAsync(null, cancellationToken);
}
我创建了一个由选项卡和机器人组成的 Microsoft 团队应用程序。我将此作为 reference 创建团队插件。在这里,我使用了机器人框架建议的瀑布流模型。在使用它时我必须给出固定数量的动作,但我想要动态动作。这是示例
class MainDialog extends ComponentDialog {
constructor(luisRecognizer, bookingDialog) {
super('MainDialog');
if (!luisRecognizer) throw new Error('[MainDialog]: Missing parameter \'luisRecognizer\' is required');
this.luisRecognizer = luisRecognizer;
if (!bookingDialog) throw new Error('[MainDialog]: Missing parameter \'bookingDialog\' is required');
// Define the main dialog and its related components.
// This is a sample "book a flight" dialog.
this.addDialog(new TextPrompt(TEXT_PROMPT))
.addDialog(bookingDialog)
.addDialog(nominationDialogue)
.addDialog(new ChoicePrompt(CHOICE_PROMPT))
.addDialog(new WaterfallDialog(MAIN_WATERFALL_DIALOG, [
this.introStep.bind(this),
this.decidestep.bind(this),
this.originStep.bind(this),
this.actStep.bind(this),
this.Actualstep.bind(this)
]));
this.initialDialogId = MAIN_WATERFALL_DIALOG;
}
/**
* The run method handles the incoming activity (in the form of a TurnContext) and passes it through the dialog system.
* If no dialog is active, it will start the default dialog.
* @param {*} turnContext
* @param {*} accessor
*/
async run(turnContext, accessor) {
const dialogSet = new DialogSet(accessor);
dialogSet.add(this);
const dialogContext = await dialogSet.createContext(turnContext);
const results = await dialogContext.continueDialog();
if (results && results.status === DialogTurnStatus.empty) {
await dialogContext.beginDialog(this.id);
}
}
我怎样才能毫无问题地转到上一个函数,即 actStep 到 decidesStep 。我尝试从 actStep 调用 decideStep 然后我遇到异常并且机器人失败。当有一些重复性的工作要做时,由于动作数量固定,我无法完成。
提前致谢。
您能否查看 Conversation Bot 的示例代码。
您可以找到更多示例解决方案here
我遇到了同样的问题,我使用类似下面的代码 (C#) 解决了它。它不干净(有点 hack)但它有效
private static async Task<DialogTurnResult> actStep (WaterfallStepContext stepContext, CancellationToken cancellationToken)
{
.
.
.
stepContext.ActiveDialog.State["stepIndex"] = (int)stepContext.ActiveDialog.State["stepIndex"] - 2;
return await stepContext.NextAsync(null, cancellationToken);
}