我正在尝试使用 Java DialogFlow API 为 Google Assistant 构建 webhook 响应。我的响应在 DialogFlow 的“立即尝试”功能中运行良好,但 Google 智能助理一直说“现在没有响应。稍后再试”。作为一项实验,我设法通过使用非 webhook 响应(即通过正常的 DialogFlow Intent UI)让 Google Assistant 工作。当我查看我的历史记录时,我看到工作响应如下所示:"queryText": "GOOGLE_ASSISTANT_WELCOME",  "action": "input.welcome",  "fulfillmentMessages": [    {      "text": {    "text": [      "[{\"type\":\"simple_response\",\"platform\":\"google\",\"textToSpeech\":\"Hello\"}]"    ]      }    }这对我来说似乎很奇怪,因为文本正文实际上是一个进一步的 JSON 编码对象(在其他字段中包含 textToSpeech)。当我像这样使用 Java DialogFlow API 时:List<String> texts = new ArrayList<>();texts.add( "Foo" );message.setText( new GoogleCloudDialogflowV2IntentMessageText().setText( texts ));我得到一种不同的格式:  "fulfillmentMessages": [    {      "text": {    "text": [ "Foo" ]      }    }谷歌助理说:MalformedResponse: Failed to parse Dialogflow response into AppResponse because of empty speech response"即使我尝试强制将编码的 JSON 字符串作为我的文本正文,它似乎仍然不起作用。返回默认消息格式以便 Google 智能助理可以阅读的正确方法是什么?我试过simpleResponse了,但也没用
                    
                    
                1 回答
 
                    
                    
                            holdtom
                            
                                
                            
                        
                        
                                                
                    TA贡献1805条经验 获得超10个赞
以下是听到响应所需的最低响应
{
"payload": {
"google": {
"expectUserResponse": true,
"richResponse": {
"items": [
{
"simpleResponse": {
"textToSpeech": "Welcome! Do you want me to change color or pause spinning? You can also tell me to ask you later."
}
}
]
}
}
}
}
当然,对于 java,您可以使用 API 来生成所需的输出响应。另外,如果您将 basicCards 或图像用于智能显示,那么使用 API 肯定会有更多帮助。您还可以检查模拟器的响应。
添加回答
举报
0/150
	提交
		取消
	