DialogFlow 中的fulfillmentText 与fulfillmentMessages

noo*_*oob 5 javascript node.js google-cloud-platform dialogflow-es hangouts-chat

我正在制作一个目前使用 Google Hangout Chat 的聊天机器人,但将移植到其他聊天平台上。
聊天代码在 Node.js 后端处理,意图识别是使用 DialogFlow 的 Nodejs API 完成的。

环聊聊天响应如下:

{
  thread: {
    name: thread.name
  },
  text: 'The response in text',
  cards:['List of cards to show data']
}
Run Code Online (Sandbox Code Playgroud)

数据工作正常,但我坚持解析从 DialogFlow 获得的响应并决定text响应的属性。有两个选项可以选择作为text属性发送。一个是queryResult.fulfillmentText它只是一个字符串并且很容易分配给text属性,而另一个是queryResult.fulfillmentMessages在某处包含相同文本的对象数组。这就是我的情况:

"fulfillmentText": "We could find few matching products based on your query",
"fulfillmentMessages": [
  {
    "text": {
      "text": [
        "We could find few matching products based on your query"
      ]
    }
  },
  {
    "text": {
      "text": [
        "2nd text"
      ]
    }
  }
],
Run Code Online (Sandbox Code Playgroud)

我的问题是我应该在fulfillmentText和之间使用什么fulfillmentMessages?还有它们之间有什么区别。既然 Hangout Chat 只需要一个文本回复,为什么会有多个文本/消息?

PS:我正在使用 DialogFlow V2 API

noo*_*oob 3

从Dialogflow 文档中获取此内容

  • fulfillmentText(字符串)向用户发音或显示在屏幕上的文本。
  • fulfillmentMessages(对象)向用户显示的丰富消息的集合。

所以我应该使用作为环聊聊天响应的属性fulfillmentText来发送。用于“丰富消息”,例如我从数据库生成的卡片。textfulfillmentMessages