LUIS / Bot Framework multiple dialog, move intent handling to another dialog

前端 未结 2 666
臣服心动
臣服心动 2021-01-21 13:14

my goal is to implement both dialogs and LUIS into a Microsoft Bot Framework application using their C# SDK. I tried to follow this thread https://github.com/M

2条回答
  •  Happy的楠姐
    2021-01-21 13:48

    I had this same question, but I am using a newer version of Bot Framework, more specifically, V4.

    Here is what I found:

    • BeginDialogAsync's options parameter takes an array of objects that will then be accessible in your dialog.
    // Get skill LUIS model from configuration.
    localizedServices.LuisServices.TryGetValue("MySkill", out var luisService);
    
    if (luisService != null)
    {
        // Get the Luis result. 
        var result = innerDc.Context.TurnState.Get(StateProperties.SkillLuisResult);
        var intent = result?.TopIntent().intent;
    
        // Behavior switched on intent. 
        switch (intent)
        {
            case MySkillLuis.Intent.MyIntent:
                {
                    // result is passed on to my dialog through the Options parameter. 
                    await innerDc.BeginDialogAsync(_myDialog.Id, result);
                    break;
                }
    
            case MySkillLuis.Intent.None:
            default:
                {
                    // intent was identified but not yet implemented
                    await innerDc.Context.SendActivityAsync(_templateEngine.GenerateActivityForLocale("UnsupportedMessage"));
                    break;
                }
        }
    }
    

    From our second dialog, we can access the object through the context and perform any casting, etc. as necessary. In my case, it was a waterfall dialog, so I used stepContext.options.

提交回复
热议问题