Bot Composer V2.1中如何将属性值设为LUIS datetimeV2实体的resolution值
Bot Composer V2.1获取datetimeV2实体resolution值的解决方案
Bot Composer V2.1默认仅会将datetimeV2实体的timex字段同步到turn.recognized.entities对象中,resolution字段不会默认映射到该节点,需要从LUIS返回的原始响应对象中读取,具体操作如下:
- 正确取值的表达式为:
取值逻辑是直接读取LUIS返回的完整原始响应节点=turn.recognized.luisResult.prediction.entities.datetimeV2[0].values[0].resolution[0].startturn.recognized.luisResult,而非经过Composer处理后的turn.recognized.entities节点。 - 若需要避免空值报错,可使用空安全的表达式写法:
该表达式在解析不到对应值时会返回空字符串,不会触发运行时错误。=coalesce(turn.recognized.luisResult.prediction.entities.datetimeV2?[0]?.values?[0]?.resolution?[0]?.start, '') - 额外校验项:可以登录LUIS管理门户,进入对应应用的实体设置页,确认datetimeV2实体的返回配置中已开启resolution字段返回,该配置默认处于开启状态。
内容的提问来源于stack exchange,提问作者n1k1
相关产品推荐
相关产品推荐

