Search code examples
botframeworkbot-framework-composer

Access an JSON object value - used path contains an dynamic value


I like to access a specific JSON object value, where the access path contains a dynamic value. The dynamic value is calculated beforehand during the dialog process.

How can I do this in a "set property" node? I did not find a good working approach.

Here my approach, which leads to no useful result.

=user.api_content.prediction.intents.${virtualagent.intent}.score

Thanks


Solution

  • Which language are you using? You should be able to just address it directly without a string designator. For example, here is how I get the score for the top intent, where intent is a variable property. You would just want to get it via the [] notation instead of the . notation.

                var intent = LuisRecognizer.topIntent(recognizerResult);
                if (recognizerResult.intents[intent].score < 0.5) {
                    intent = 'None';
                }