2017-05-02 12 views
1

PromptDialog.Choiceを利用しようとすると、無効なType例外が発生します。 は、ここに私のダイアログの上から私のコードを次のとおりです。PromptDialog.Choice - 無効な型の例外

public async Task StartAsync(IDialogContext context) { 
    await context.PostAsync(ConversationHelper.CreateReschedulePromptMessage()); 
    context.Wait(MessageReceivedAsync); 
} 

public virtual async Task MessageReceivedAsync(IDialogContext context, IAwaitable<IMessageActivity> result) { 
    var message = await result; 
    var Options = new[] { "Location", "Date and Time", "Both" }; 

    if (message.Text.ToUpper().CompareTo("PICKUP") == 0) { 
    _rescheduleType = "pickup"; 
    string prompt = string.Format("Is the {0} location incorrect, is the date and time incorrect, or both?", _rescheduleType); 
    PromptDialog.Choice(context, OnResumeFromRescheduleChoice, Options, prompt, promptStyle: PromptStyle.Auto, descriptions: Options); 
    } 
    else if (message.Text.ToUpper().CompareTo("DROP") == 0) { 
    _rescheduleType = "drop-off"; 
    string prompt = string.Format("Is the {0} location incorrect, is the date and time incorrect, or both?", _rescheduleType); 
    PromptDialog.Choice(context, OnResumeFromRescheduleChoice, Options, prompt, promptStyle: PromptStyle.Auto, descriptions: Options); 
    } 
    else { 
    await context.PostAsync(ConversationHelper.CreateGenericRescheduleMessage(SUPPORTNUMBER)); 
    } 

    context.Done<object>(null); 
} 

private async Task OnResumeFromRescheduleChoice(IDialogContext context, IAwaitable<string> result) { 
    var choice = await result; 
} 

OnResumeFromRescheduleChoice方法が発射されますが、ResumeAfterデリゲートの型が文字列を期待しているが、オブジェクトを受信して​​いるため、結果ショーに失敗しました。このPromptDialogの使い方が間違っていますか?また、ユーザーには選択肢が表示されません。私はBot.Builderバージョン3.5.5を使用しています。

+0

コンテキストです。(null)コールが早すぎますか? –

答えて

1

else句の中でcontext.Done<object>(null);コールを移動します。 Promptを発砲した後にに電話をかけることはできません。

+1

それは私の問題でした。ありがとう。 –

関連する問題