Bot Framework V4 上的对话延续问题

Dialog Continuation Issue on Bot Framework V4

我想在我的 bot 中显示欢迎消息后立即启动用户对话框 - 无需任何初始用户交互。
完成该操作的代码片段:

public RootDialogBot(BotServices services, BotAccessors accessors, ILoggerFactory loggerFactory)
        {
            if (loggerFactory == null)
            {
                throw new System.ArgumentNullException(nameof(loggerFactory));
            }

            _logger = loggerFactory.CreateLogger<RootDialogBot>();            
            _accessors = accessors ?? throw new System.ArgumentNullException(nameof(accessors));
            _botServices = services ?? throw new System.ArgumentNullException(nameof(services));

            _studentProfileAccessor = _accessors.UserState.CreateProperty<StudentProfile>("studentProfile");

            if (!_botServices.QnAServices.ContainsKey("QnAMaker"))
            {
                throw new System.ArgumentException($"Invalid configuration. Please check your '.bot' file for a QnA service named QnAMaker'.");
            }
            if (!_botServices.LuisServices.ContainsKey("LUIS"))
            {
                throw new System.ArgumentException($"Invalid configuration. Please check your '.bot' file for a Luis service named LUIS'.");
            }                     
                .Add(new Activity2MainDialog(_accessors.UserState, Activity2MainDialog))
                .Add(new Activity2LedFailToWorkDialog(_accessors.UserState, Activity2LedFailToWorkDialog));            
        }
public async Task OnTurnAsync(ITurnContext turnContext, CancellationToken cancellationToken = default(CancellationToken))
        {
...
if (turnContext.Activity.Type == ActivityTypes.ConversationUpdate)
            {                
                if (turnContext.Activity.MembersAdded != null)
                {
                    // Save the new turn count into the conversation state.
                    await _accessors.UserState.SaveChangesAsync(turnContext, false, cancellationToken);
                    await _accessors.ConversationState.SaveChangesAsync(turnContext, false, cancellationToken);
                    var message = "Welcome!";
                    await SendWelcomeMessageAsync(turnContext, dc, message,cancellationToken);  //Welcome message
                }
            } 
...
}
private static async Task SendWelcomeMessageAsync(ITurnContext turnContext, DialogContext dc,string message, CancellationToken cancellationToken)
        {
            foreach (var member in turnContext.Activity.MembersAdded)
            {
                if (member.Id != turnContext.Activity.Recipient.Id)
                {
                    await turnContext.SendActivityAsync(message, cancellationToken: cancellationToken);
                    await dc.BeginDialogAsync(Activity2MainDialog, "activity2MainDialog", cancellationToken);
                }
            }
        }


对话框 (Activity2MainDialog) 在到达 return await stepContext.ContinueDialogAsync(cancellationToken); 调用之前工作正常。
然后它停止了。
我相信这与对话状态有关,但我仍然找不到解决方案。
return await stepContext.ContinueDialogAsync(cancellationToken); 调用的代码片段

public class Activity2MainDialog : ComponentDialog
    {
        private static BellaMain BellaMain = new BellaMain();
        private static FTDMain FTDMain = new FTDMain();
        private readonly IStatePropertyAccessor<StudentProfile> _studentProfileAccessor;        
    ...
        public Activity2MainDialog(UserState userState, string dialogMainId)
                : base(dialogMainId)
        {
            InitialDialogId = Id;
            _studentProfileAccessor = userState.CreateProperty<StudentProfile>("studentProfile");

            WaterfallStep[] waterfallSteps = new WaterfallStep[]
            {
                MsgWelcomeStepAsync
        ...                
            };

            // Add named dialogs to the DialogSet. These names are saved in the dialog state.
            AddDialog(new WaterfallDialog(dialogMainId, waterfallSteps));
            AddDialog(new TextPrompt(nameof(TextPrompt)));
            AddDialog(new ChoicePrompt(nameof(ChoicePrompt)));
            AddDialog(new ConfirmPrompt(nameof(ConfirmPrompt)));
        }
        private async Task<DialogTurnResult> MsgWelcomeStepAsync(WaterfallStepContext stepContext, CancellationToken cancellationToken)
        {
        await stepContext.Context.SendActivityAsync("**Oi**", "Oi", cancellationToken: cancellationToken);
            return await stepContext.ContinueDialogAsync(cancellationToken);
        }
        private async Task<DialogTurnResult> QuestGoAheadStepAsync(WaterfallStepContext stepContext, CancellationToken cancellationToken)
        {
            message = "Vamos nessa?";
            await stepContext.Context.SendActivityAsync(message , message , cancellationToken: cancellationToken);
            retryPromptMessage = message;
            return await stepContext.PromptAsync(nameof(ChoicePrompt),
                        new PromptOptions
                        {
                            Prompt = null,
                            RetryPrompt = MessageFactory.Text(retryPromptMessage, retryPromptSpeakMessage), InputHints.ExpectingInput),            
                            Choices = new[]
                            {
                                    new Choice {Value = "Sim", Synonyms = new List<string> {"yes","yeah","esta","ta","esta","ok","vamos","curti","curtir","claro","tá","sei","top"}},
                                    new Choice {Value = "Não", Synonyms = new List<string> {"no"}}
                            }.ToList(),
                            Style = ListStyle.Auto                            
                        });
        }

关于如何修复它的想法?谢谢

我相当确定问题出在 ContinueDialog 调用上。您需要以以下方式结束该步骤:

return await stepContext.NextAsync(null, cancellationToken);

有关更多示例代码,请参阅 CoreBot

如果不能解决您的问题,请告诉我,我会调整我的答案。