How to forward from RootDialog to LuisDialog in Bot Framework

后端 未结 2 2080
终归单人心
终归单人心 2020-12-12 06:27

I\'m creating a bot for FAQ . When bot start conversations send a PromptDialog with 2 options: english, french.

I want to forward the dialog to EnglishLuis when user

2条回答
  •  挽巷
    挽巷 (楼主)
    2020-12-12 07:10

    First, doing

    context.Wait(this.MessageReceived);
    context.Done(true);
    

    it's wrong. You need to choose: or you wait for a new message in the EnglishDialog or you end the EnglishDialog (with Done)

    Then, you are trying to send a string in the context.Forward and you need to forward an IMessageActivity. And I suspect you want to send the original message, so you will need to save that in global variable before continuing with the prompt. Try with:

    var newMessage = context.MakeMessage();
    newMessage.Text = this.originalMessageText //the variable that contains the text of the original message that you will have to save at MessageReceiveAsync
    await context.Forward(new EnglishLuis(), ResumeAfterDialog, newMessage, CancellationToken.None);
    
    
    MessageReceivedAsync in RootDialog should looks like:
    
     private async Task MessageReceiveAsync(IDialogContext context, IAwaitable result)
        {
            var reply = await result;
            if (reply.Text.ToLower().Contains("help"))
            {
                await context.PostAsync("You can implement help menu here");
            }
            else
            {
                this.originalMessage = reply.Text;
                await ShowMainmenu(context);
            }
        }
    

提交回复
热议问题