2017-08-14 51 views
0

如何在Form中調用對話框? 我想調用位置對話框https://github.com/Microsoft/BotBuilder-Location來獲取地址。 謝謝。如何從FormFlow調用Dialog

[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); 
    } 
} 
+0

這不是目前的特徵。 – JasonSowers

回答

0

您是否期待基於屬性聲明的解決方案還是常規代碼可接受?

Microsoft提供了作爲序列或堆棧調用的Dialog Chaining。

在接下來的問題中接受的答案回答你的問題,我認爲。

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

+0

謝謝。但第一個代碼示例顯示如何從Dialog調用Form。我需要從窗體調用Dialog。基於屬性的解決方案就是我的建議 – Ma3yTa