首页 文章

如何在Dialogflow中创建包含丰富消息的响应?

提问于
浏览
1

目前,当调用intent时,我正在调用webhook并从web服务获得响应,如下面的json结构所示 .

{
  "speech": "this text is spoken out loud if the platform supports voice interactions",
  "displayText": "this text is displayed visually"
}

这仅仅是文字 . 或者,例如,我必须以什么样的响应来显示列表 .

我尝试了dialogflow文档的丰富消息部分 . 那些结构不起作用 .

1 回答

  • 0

    要在Google列表中添加操作作为回复的一部分,您需要在回复中使用 data 字段以包含 richResponse 以及应包含的 systemIntent 以及包含列表信息的 systemIntent .

    您可以在github example repository上看到更多示例,但这里是显示列表的示例:

    {
      "data": {
        "google": {
          "expectUserResponse": true,
          "richResponse": {
            "items": [
              {
                "simpleResponse": {
                  "textToSpeech": "Choose an item"
                }
              }
            ]
          },
          "systemIntent": {
            "intent": "actions.intent.OPTION",
            "data": {
              "@type": "type.googleapis.com/google.actions.v2.OptionValueSpec",
              "listSelect": {
                "title": "Hello",
                "items": [
                  {
                    "optionInfo": {
                      "key": "first title"
                    },
                    "description": "first description",
                    "image": {
                      "url": "https://developers.google.com/actions/images/badges/XPM_BADGING_GoogleAssistant_VER.png",
                      "accessibilityText": "first alt"
                    },
                    "title": "first title"
                  },
                  {
                    "optionInfo": {
                      "key": "second"
                    },
                    "description": "second description",
                    "image": {
                      "url": "https://lh3.googleusercontent.com/Nu3a6F80WfixUqf_ec_vgXy_c0-0r4VLJRXjVFF_X_CIilEu8B9fT35qyTEj_PEsKw",
                      "accessibilityText": "second alt"
                    },
                    "title": "second title"
                  }
                ]
              }
            }
          }
        }
      }
    }
    

相关问题