2 回答

TA貢獻1801條經(jīng)驗 獲得超8個贊
您不需要使用瀑布對話框。Simple Prompt Bot Sample應(yīng)該可以幫助您入門。
if (results.Status == DialogTurnStatus.Empty)
{
// A prompt dialog can be started directly on the DialogContext. The prompt text is given in the PromptOptions.
await dialogContext.PromptAsync(
"name",
new PromptOptions { Prompt = MessageFactory.Text("Please enter your name.") },
cancellationToken);
}
// We had a dialog run (it was the prompt). Now it is Complete.
else if (results.Status == DialogTurnStatus.Complete)
{
// Check for a result.
if (results.Result != null)
{
// Finish by sending a message to the user. Next time ContinueAsync is called it will return DialogTurnStatus.Empty.
await turnContext.SendActivityAsync(MessageFactory.Text($"Thank you, I have your name as '{results.Result}'."));
}
}
}
有關(guān)更多信息,我在此問題上發(fā)布了類似的答案,并且我有一位同事在此處給出了類似的答案。

TA貢獻1900條經(jīng)驗 獲得超5個贊
好的,我想自己回答這個問題:botframework v4 有一個IBot接口,每條消息都通過你實現(xiàn)的接口的單例實例進行路由。所以我的想法是,啟動的對話會直接得到用戶的響應(yīng)。相反,您的實現(xiàn)IBot需要創(chuàng)建一個 dialogContext 并且還需要在OnTurnAsync方法中繼續(xù)活動對話框:
var dialogContext = await _dialogs.CreateContextAsync(context, cancellationToken);
if (dialogContext.ActiveDialog is null)
{
await dialogContext.BeginDialogAsync(nameof(AgeDialog),
cancellationToken: cancellationToken);
}
else
{
await dialogContext.ContinueDialogAsync(cancellationToken);
}
await _accessor.ConversationState.SaveChangesAsync(context, false, cancellationToken);
- 2 回答
- 0 關(guān)注
- 96 瀏覽
添加回答
舉報