小编And*_*asS的帖子

在 Bot Framework V4 中保留自定义提示验证

我开始在 Microsoft 的 Bot Framework V4 中构建一个对话框,为此我想使用提示的自定义验证。几个月前,当 4.4 版发布时,一个新属性“AttemptCount”被添加到PromptValidatorContext 中。此属性提供有关用户回答多少次的信息。显然,如果用户被多次重新提示,最好结束当前对话。但是,我没有找到摆脱这种状态的方法,因为与 DialogContext(或 WaterfallStepContext)不同,给定的 PromptValidatorContext 不提供替换对话框的方法。我在github上问了这个问题,但没有得到答案。

public class MyComponentDialog : ComponentDialog
{
    readonly WaterfallDialog waterfallDialog;

    public MyComponentDialog(string dialogId) : (dialogId)
    {
        // Waterfall dialog will be started when MyComponentDialog is called.
        this.InitialDialogId = DialogId.MainDialog;

        this.waterfallDialog = new WaterfallDialog(DialogId.MainDialog, new WaterfallStep[] { this.StepOneAsync, this.StepTwoAsync});
        this.AddDialog(this.waterfallDialog);

        this.AddDialog(new TextPrompt(DialogId.TextPrompt, CustomTextValidatorAsync));
    }

    public async Task<DialogTurnResult> StepOneAsync(WaterfallStepContext stepContext, CancellationToken cancellationToken)
    {
        var promptOptions = new PromptOptions
                            {
                                Prompt = MessageFactory.Text("Hello from text prompt"), …
Run Code Online (Sandbox Code Playgroud)

c# botframework

2
推荐指数
1
解决办法
3249
查看次数

标签 统计

botframework ×1

c# ×1