【问题标题】:How call Dialog from FormFlow如何从 FormFlow 调用 Dialog
【发布时间】:2017-08-16 06:44:17
【问题描述】:

如何在Form中间调用对话框? 我想打电话给位置对话框https://github.com/Microsoft/BotBuilder-Location 来获取地址。 谢谢。

[Serializable]
public class IssueShares
{
    [Prompt("Please enter holder name:")]
    public string HolderName;
    [Prompt("Please enter holder address:")]
   **[Call(typeof(AddressDialog))]**
    public Address Address;

    [Prompt("Enter shares class:")]
    public string SharesClass { get; set; }
    [Prompt("How many shares your issue?")]
    [Describe("Number of shares")]
    public int NumberOfShares { get; set; }
}

[Serializable]
public class AddressDialog : IDialog<Address>
{
    public Task StartAsync(IDialogContext context)
    {
        context.Wait(MessageReceived);
        return Task.CompletedTask;
    }

    private async Task MessageReceived(IDialogContext context, IAwaitable<object> result)
    {
        // some logic
        context.Done(address);
    }
}

【问题讨论】:

  • 这不是当前的功能。

标签: c# botframework formflow


【解决方案1】:

您期待基于属性声明的解决方案还是可以接受常规代码?

Microsoft 提供作为序列或堆栈调用的对话链。

以下 SO 问题中接受的答案回答了我认为的您的问题。

Calling Forms from Dialogs

这是该答案的代码摘录:

var myform = new FormDialog<CreateNewLeadForm>(new CreateNewLeadForm(), CreateNewLeadForm.BuildForm, FormOptions.PromptInStart, null);

context.Call<CreateNewLeadForm>(myform, FormCompleteCallback);

另一个 SO 问题更笼统地讨论了这个主题:

Handling multiple dialogs in Microsoft bot framework

【讨论】:

  • 谢谢。但第一个代码示例显示了如何从对话框调用表单。我需要从表单中调用对话框。基于属性的解决方案只是我的建议
猜你喜欢
  • 1970-01-01
  • 2011-08-18
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多