我现在正在开发聊天机器人,该机器人可以回答客户提出的问题。我想删除第一条通讯行“输入一些单词以回答问题”。但是,我找不到路。
初始化通信。
if (member.Id != turnContext.Activity.Recipient.Id)
{
var reply = MessageFactory.Text("質問を続けるには何か入力してください。");
await turnContext.SendActivityAsync(reply, cancellationToken);
}
问客户一个问题。
private async Task<DialogTurnResult> InputQuestionAsync(WaterfallStepContext stepContext, CancellationToken cancellationToken)
{
_logger.LogInformation("MainDialog.InputQuestionAsync");
var promptOptions = new PromptOptions { Prompt = MessageFactory.Text("ご質問を話し言葉で入力して下さい。") };
return await stepContext.PromptAsync(nameof(TextPrompt), promptOptions, cancellationToken);
}
回答问题。
private async Task<DialogTurnResult> ShowCardStepAsync(WaterfallStepContext stepContext, CancellationToken cancellationToken)
{
_logger.LogInformation("MainDialog.ShowCardStepAsync");
var receivedMessage = (string)stepContext.Result;
var userProfile = await _userProfileAccessor.GetAsync(stepContext.Context, () => new UserProfile(), cancellationToken);
userProfile.Question = receivedMessage;
*
*
*
*
msg = msg + sec.ToString() + ".知りたい質問がありません\n\n" + third.ToString() + ".質問を変える\n\n";
var reply = MessageFactory.Text(msg);
list1.Add(sec.ToString());
list1.Add(third.ToString());
reply.Attachments.Add(Cards.GetHeroCard(list1).ToAttachment());
await stepContext.Context.SendActivityAsync(reply, cancellationToken);
var promptOptions = new PromptOptions { Prompt = MessageFactory.Text("番号を押してください") };
return await stepContext.PromptAsync(nameof(TextPrompt), promptOptions, cancellationToken);
}
}
答案 0 :(得分:1)
添加
var accessor = ConversationState.CreateProperty<DialogState>(nameof(DialogState));
await Dialog.RunAsync(turnContext, accessor, cancellationToken);
在 OnMember⚓Async和OnMessageActivityAsync解决了这个问题。