DialogFlow:为什么此Webhook响应失败并显示“空语音响应” [英] DialogFlow: why does this Webhook Response fail with 'empty speech response'

查看:79
本文介绍了DialogFlow:为什么此Webhook响应失败并显示“空语音响应”的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

为什么这个特定的webhook响应(由DialogFlow返回给Google Assistant)

Why does this specific webhook response (passed by DialogFlow back to Google Assistant)

    {
      "fulfillmentMessages" : [ {
        "payload" : {
          "google" : {
        "richResponse" : {
          "items" : [ {
            "simpleResponse" : {
              "textToSpeech" : "And are you male or female?"
            }
          } ]
        },
        "expectUserResponse" : true
          }
        },
        "text" : {
          "text" : [ "And are you male or female?" ]
        }
      }, {
        "quickReplies" : {
          "quickReplies" : [ "Male", "Female" ]
        }
      } ],
      "fulfillmentText" : "And are you male or female?",
      "outputContexts" : [ ... ]
    }

错误为:

"MalformedResponse: Failed to parse Dialogflow response into AppResponse because of empty speech response" 


推荐答案

对于Google Assistant,响应不是 fulfillmentMessages 的一部分,而是在 payload 对象中,该对象应位于

In the case of Google Assistant, the responses are not part of fulfillmentMessages but are in a payload object which should be located at the top level of your response.

请注意,快速回复文本对Dialogflow履行消息有效,但对Google Assistant无效。相反,您应该使用 simpleResponse 建议字段并将其放入响应中。

Note that quickReplies and text are valid for Dialogflow fulfillment messages but not for Google Assistant too. Instead, you should use simpleResponse and suggestions fields and put them in the response.

因此,例如,这是对Google Assistant的响应,它由建议芯片和一个简单的响应组成:

So, for example here is a response for Google Assistant which is made of suggestion chips and a simple response:

{
  payload: {
    google: {
      richResponse: {
        items: [{
          simpleResponse: {
            textToSpeech: "Are you male or female"
          }
        }],
        suggestions: [
          { title: 'Male' },
          { title: 'Female' }
        ]
      }
    }
  },
  outputContexts: [...]
}

对于Dialogflow履行消息(例如在Dialogflow控制台中),应该是这样的:

For Dialogflow fulfillment messages (in the Dialogflow console for example), it would have been something like that:

{
  fulfillmentMessages: [
    { text: { text: ['Are you male or female'] } },
    { quickReplies: { quickReplies: ['Male', 'Female'] } } 
  ],
  outputContexts: [...]
}

希望有帮助。

这篇关于DialogFlow:为什么此Webhook响应失败并显示“空语音响应”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆