【问题标题】:Bot Composer - Join list from Luis entityBot Composer - 来自 Luis 实体的加入列表
【发布时间】:2021-06-19 01:31:32
【问题描述】:

Bot Framework Composer v1.4.1

我有一个连接到 Luis 的机器人,它返回一个列表实体,我需要使用该数据进行操作。 我得到的实体是一个类别列表,我需要将该列表的所有元素连接成一个字符串

"entities": {
  "CategoryList": [
    [
      "sub-13-Imprimante",
      "12-materiels"
    ]
  ]
}

预期的结果是

"sub-13-Imprimante,12-materiels"

我尝试了不同的选项,但没有一个按预期连接结果。

@CategoryList //This only assign first element of the array ("sub-13-Imprimante")

join(@CategoryList, ',') //Throw error

join语句得到的错误是:

System.InvalidOperationException: 'NewTicket.fr-fr.lg:@CategoryList evaluates to sub-13-Imprimante which is not a list. [SendActivity_D8EXfc]  Error occurred when evaluating '- ${join(@CategoryList, ',')}'. 

似乎在调用@CategoryList 时,它已经返回了第一项,而不是整个列表。

如何获取串联在字符串中的数组的所有值?

【问题讨论】:

    标签: botframework azure-cognitive-services bot-framework-composer


    【解决方案1】:

    @CategoryList 将返回为实体找到的第一个也是唯一一个值。 @@CategoryList 将返回整个内容。所以,你需要的是join(@@CategoryList, ',')

    在此处查看更多信息:

    https://docs.microsoft.com/en-us/composer/concept-memory?tabs=v2x#memory-shorthand-notations

    【讨论】:

    • 为了澄清,@@CategoryList 以文本格式返回整个实体,包括方括号和引号。要生成数组,首先要清理掉多余的字符[\r\n [\r\n \"sub-13-Imprimante\",\r\n \"12-materiels\"\r\n ]\r\n]
    • 对于.NET;正确的。似乎是两个 SDK 之间的错误/聚会问题。我在这里提交了一个错误:github.com/microsoft/botframework-sdk/issues/6327
    猜你喜欢
    • 2019-03-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-08-28
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多