是否可以根据一组依赖于另一个上下文值的值的条件来设置上下文变量的值?我正在尝试将NLU(自然语言理解)服务与Conversation服务集成,并希望根据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:'' ?>
}
}