1

別のコンテキスト値の値に依存する一連の条件に基づいて、コンテキスト変数の値を設定することは可能ですか? NLU (自然言語理解) サービスを会話サービスと統合しようとしており、NLU によって返される値に基づいていくつかのコンテキスト変数を設定したいと考えています。たとえば、NLU から次のエンティティを取得しています。

{
...
"context": {
    ...
    "nlu_response": {
        "entities": [{
            "type": "Person",
            "relevance": 0.5,
            "count": 1,
            "text": "Jon Doe",
            "emotion": {
                "anger": 0.082378,
                "disgust": 0.033499,
                "fear": 0.072588,
                "joy": 0.100971,
                "sadness": 0.147584
            },
            "sentiment": {
                "score": 0.409803
            }
        },
        {
            "type": "Person",
            "relevance": 0.5,
            "count": 1,
            "text": "Jane Doe",
            "emotion": {
                "anger": 0.140151,
                "disgust": 0.091598,
                "fear": 0.059244,
                "joy": 0.046762,
                "sadness": 0.165763
            },
            "sentiment": {
                "score": 0
            }
        }]
    }
}

}

type="Person" のエンティティ オブジェクトに値がある場合にのみ、"Jon Doe" の値を持つコンテキスト変数 EntityPerson_1 を作成したいと考えています。つまり、応答ノードでは次のようなことが可能です。

{
...
"context": {
    ...
    "EntityPerson_1": <? context.nlu_response.entities.size()>0 && context.nlu_response.entities.get(0).type.contains('Person')?context.nlu_response.entities.get(0).text:'' ?>
}

}

4

1 に答える 1