0

如何在表单中间调用对话框?我想调用位置对话框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);
    }
}
4

1 回答 1

0

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

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

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

从对话框调用表单

这是该答案的代码摘录:

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

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

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

在 Microsoft bot 框架中处理多个对话框

于 2017-08-14T18:48:33.330 回答