【问题标题】:How to have dynamic flow for teams bot built using microsoft bot framework?如何为使用 microsoft bot 框架构建的团队 bot 提供动态流程?
【发布时间】:2020-06-02 08:41:17
【问题描述】:

我创建了一个由选项卡和机器人组成的 Microsoft 团队应用。我将此作为reference 用于创建团队插件。在这里,我使用的是 bot 框架建议的瀑布流模型。在使用它时,我必须给出固定数量的动作,但我想要动态动作。这是示例

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 以再次做出决定而没有任何问题。我尝试从actStep调用decisionStep然后我遇到异常并且机器人失败了。当有一些重复的工作要做时,由于动作数量固定,我无法完成。

提前致谢。

【问题讨论】:

    标签: botframework microsoft-graph-api microsoft-teams


    【解决方案1】:

    我遇到了同样的问题,我使用以下代码 (C#) 解决了它。它不干净(有点黑客),但它可以工作

    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);
    }
    

    【讨论】:

      【解决方案2】:

      您能否查看Conversation Bot 的示例代码。

      您可以找到更多示例解决方案here

      【讨论】:

      • 我已阅读文档。没有找到任何合适的解决方案。所以我在这里发布了这个问题。
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-12-29
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-05-14
      • 2018-01-27
      相关资源
      最近更新 更多