How do you get to the original message text in a Microsoft Bot Framework LuisIntent method

后端 未结 4 1702
孤城傲影
孤城傲影 2021-02-14 11:00

I\'m trying to access the complete original text from within a method marked as a LuisIntent within a LuisDialog.

The documentation shows these

4条回答
  •  萌比男神i
    2021-02-14 11:14

    If you break into the method, you can see in the quick watch that the context object has a non-public property through to context.data.mesage.Text (note the misspelling of "mesage"). Since the property is non-public, you could cheat by using reflection to get at it (see GetInstanceField in How to get the value of private field in C#?)

            Microsoft.Bot.Builder.Dialogs.Internals.JObjectBotData data = GetInstanceField(typeof (Microsoft.Bot.Builder.Dialogs.Internals.DialogContext), context, "data") as Microsoft.Bot.Builder.Dialogs.Internals.JObjectBotData;            
            Microsoft.Bot.Connector.Message originalMessage = GetInstanceField(typeof(Microsoft.Bot.Builder.Dialogs.Internals.JObjectBotData), data, "mesage") as Microsoft.Bot.Connector.Message;
            string originalMessageText = originalMessage.Text;
    

提交回复
热议问题