小编Eir*_*ren的帖子

如何链接多个对话框?

我正在使用C#Bot Builder处理机器人.

现在,我知道有很多关于如何处理链接对话框的例子.像FacebookAuthDialog或ChainedEchoDialog.

我想要做什么:用户必须经过一个授权对话框,当多数民众赞成在做,我想立即把用户进入"UserDialog"在那里,他可以使用哪些需要他的身份验证的所有功能.

这是我的代码:

public static readonly IDialog<string> dialog = Chain
        .PostToChain()
        .Switch(
            new Case<Message, IDialog<string>>((msg) =>
            {
                var userInfo = new StorageClient().GetUser(msg.From.Id);

                if (userInfo != null && userInfo.Activated)
                    return false;
                else
                    return true;
            }, (ctx, msg) =>
            {
                return Chain.ContinueWith(new AuthenticationDialog(),
                            async (context, res) =>
                            {
                                var result = await res;
                                return Chain.Return($"You successfully activated your account.");
                            });
            }),
            new Case<Message, IDialog<string>>((msg) =>
            {
                var userInfo = new StorageClient().GetUser(msg.From.Id);
                if (userInfo != null && userInfo.Activated)
                    return true;
                else …
Run Code Online (Sandbox Code Playgroud)

c# botframework botbuilder

8
推荐指数
1
解决办法
1355
查看次数

标签 统计

botbuilder ×1

botframework ×1

c# ×1