简体   繁体   English

如何为使用 microsoft bot 框架构建的团队 bot 提供动态流程?

[英]How to have dynamic flow for teams bot built using microsoft bot framework?

I have created a Microsoft teams app which consists of tabs and a bot.我创建了一个由选项卡和机器人组成的 Microsoft 团队应用程序。 I took this as reference for creating teams addon.我将此作为创建团队插件的参考 Here I am using the Waterfall flow model which was suggested by bot framework.在这里,我使用的是 bot 框架建议的瀑布流 model。 While using this I have to give fixed number of actions, but I wanted to have dynamic actions.在使用它时,我必须给出固定数量的动作,但我想要动态动作。 here is the example这是示例

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

How can I go to previous function ie, actStep to decidesStep again without having any problem.我怎样才能将 go 转换为以前的 function 即,actStep 以再次确定Step 而没有任何问题。 I tried calling the decideStep from actStep then I am having an exception and bot is failing.我尝试从actStep调用decisionStep然后我遇到异常并且机器人失败了。 When there is some repetitive work to be done I am not able to do due to the fixed number of actions.当有一些重复的工作要做时,由于动作数量固定,我无法完成。

Thanks in advance.提前致谢。

I had the same problem and I solved it using something like the following code (C#).我遇到了同样的问题,我使用以下代码(C#)解决了它。 It's not clean (kind of hack) but it works它不干净(有点黑客),但它有效

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

Could you please look into the sample code for Conversation Bot .您能否查看对话机器人的示例代码。

You could find more sample solutions here您可以在此处找到更多示例解决方案

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 使用ngrok时Microsoft Bot Framework Bot在Microsoft Teams中不起作用 - Microsoft Bot Framework bot not working in Microsoft Teams when using ngrok Microsoft Bot Framework 和 Microsoft Teams - Microsoft Bot Framework and Microsoft Teams 如何调试在 Microsoft Teams 上运行的 Bot Framework BOT - How to debug a Bot Framework BOT running on Microsoft Teams Microsoft Bot Framework 团队身份验证 - Microsoft Bot Framework Teams Authentication 如何使用Java的Bot Framework SDK将Cards添加到Microsoft Team Bot? - How to add Cards to microsoft teams bot using Bot Framework SDK for Java? 使用Microsoft bot框架在Microsoft团队中显示欢迎消息 - show welcome message in Microsoft teams using Microsoft bot framework 面临错误:对于使用 Bot Framework SDK 构建的 MS Teams Bot,此机器人不支持文件附件 - Facing Error: File attachments aren’t supported for this bot for MS Teams Bot built using Bot Framework SDK 如何连接到团队中的Bot Microsoft Flow之类的任何租户 - How to connect to any tenant like Bot Microsoft Flow in Teams 使用Microsoft Bot Framework自动对Microsoft团队中的用户进行身份验证 - Auto authenticate users in Microsoft teams using Microsoft Bot Framework 如何在 Microsoft Teams for Microsoft Bot Framework 中检测用户的语言? - How to detect user's language in Microsoft Teams for Microsoft Bot Framework?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM