DialogFlow:为什么此 Webhook 响应失败 'empty speech response'
DialogFlow: why does this Webhook Response fail with 'empty speech response'
为什么这个特定的 webhook 响应(由 DialogFlow 传递回 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 助手的情况下,响应不是 fulfillmentMessages
的一部分,而是在 payload
对象中,该对象应位于响应的顶层。
请注意,quickReplies
和 text
对 Dialogflow fulfillment 消息有效,但对 Google Assistant 也无效。相反,您应该使用 simpleResponse
和 suggestions
字段并将它们放在响应中。
因此,例如这里是 Google 助手的回复,它由建议卡片和一个简单的回复组成:
{
payload: {
google: {
richResponse: {
items: [{
simpleResponse: {
textToSpeech: "Are you male or female"
}
}],
suggestions: [
{ title: 'Male' },
{ title: 'Female' }
]
}
}
},
outputContexts: [...]
}
对于 Dialogflow 实现消息(例如在 Dialogflow 控制台中),它应该是这样的:
{
fulfillmentMessages: [
{ text: { text: ['Are you male or female'] } },
{ quickReplies: { quickReplies: ['Male', 'Female'] } }
],
outputContexts: [...]
}
希望对您有所帮助。
为什么这个特定的 webhook 响应(由 DialogFlow 传递回 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 助手的情况下,响应不是 fulfillmentMessages
的一部分,而是在 payload
对象中,该对象应位于响应的顶层。
请注意,quickReplies
和 text
对 Dialogflow fulfillment 消息有效,但对 Google Assistant 也无效。相反,您应该使用 simpleResponse
和 suggestions
字段并将它们放在响应中。
因此,例如这里是 Google 助手的回复,它由建议卡片和一个简单的回复组成:
{
payload: {
google: {
richResponse: {
items: [{
simpleResponse: {
textToSpeech: "Are you male or female"
}
}],
suggestions: [
{ title: 'Male' },
{ title: 'Female' }
]
}
}
},
outputContexts: [...]
}
对于 Dialogflow 实现消息(例如在 Dialogflow 控制台中),它应该是这样的:
{
fulfillmentMessages: [
{ text: { text: ['Are you male or female'] } },
{ quickReplies: { quickReplies: ['Male', 'Female'] } }
],
outputContexts: [...]
}
希望对您有所帮助。