为什么此特定的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"
答案 0 :(得分:1)
对于Google Assistant,响应不是fulfillmentMessages
的一部分,而是在payload
对象中,该对象应位于响应的顶层。
请注意,quickReplies
和text
对Dialogflow履行消息有效,但对Google Assistant无效。相反,您应该使用simpleResponse
和suggestions
字段并将其放入响应中。
例如,这是对Google Assistant的回复,它由建议芯片和一个简单的回复组成:
{
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: [...]
}
希望有帮助。