2 回答

TA貢獻(xiàn)1801條經(jīng)驗(yàn) 獲得超8個(gè)贊
您不需要使用瀑布對(duì)話框。Simple Prompt Bot Sample應(yīng)該可以幫助您入門(mén)。
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)更多信息,我在此問(wèn)題上發(fā)布了類似的答案,并且我有一位同事在此處給出了類似的答案。

TA貢獻(xiàn)1900條經(jīng)驗(yàn) 獲得超5個(gè)贊
好的,我想自己回答這個(gè)問(wèn)題:botframework v4 有一個(gè)IBot接口,每條消息都通過(guò)你實(shí)現(xiàn)的接口的單例實(shí)例進(jìn)行路由。所以我的想法是,啟動(dòng)的對(duì)話會(huì)直接得到用戶的響應(yīng)。相反,您的實(shí)現(xiàn)IBot需要?jiǎng)?chuàng)建一個(gè) dialogContext 并且還需要在OnTurnAsync方法中繼續(xù)活動(dòng)對(duì)話框:
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)注
- 87 瀏覽
添加回答
舉報(bào)