DialogFlow (API.AI) REST 与 php
DialogFlow (API.AI) REST with php
我最近在使用 DialogFlow,我需要向我自己的 Web 服务发送一个 POST。
这是一个与 Symfony 等 PHP.
一起工作的 Rest 服务
所以我尝试了一些方法但没有用。
在教程中,它使用 Google Cloud,但我不想使用它。
Webhook 的 URL 我自己改了。我没有更改 DialogFlow 中的任何其他内容,因为它与 google 配合得很好。在那里:
/**
* @Rest\View()
* @Rest\Post("/testDialogBot")
*/
public function testDialogBotAction( Request $request )
{
$re = "Test reponse";
$response = new Response(json_encode( array( "speech" => $re, "displayText" => $re )));
$response->headers->set('Content-Type', 'application/json');
return $response;
}
DialogFlow JSON return :
"status": {
"code": 206,
"errorType": "partial_content",
"errorDetails": "Webhook call failed. Error: Request timeout."
},
我确定它可以工作,我可能做了一些坏事。
感谢您的帮助。
根据 official docs 响应 "should" 具有以下字段:speech、displayText、data、contextOut 和 source。您只发送语音和显示文本。也许添加其他的就可以了。
此外,文档中规定的响应限制为:
Timeout for service response – 5 seconds. Data received in the
response from the service – up to 64K.
检查您的服务器是否可以在这些参数范围内发送响应
好的,没关系,您不需要所有参数。我的 URL 错了,似乎 DialogFlow 不接受 https,只接受 http。
我最近在使用 DialogFlow,我需要向我自己的 Web 服务发送一个 POST。 这是一个与 Symfony 等 PHP.
一起工作的 Rest 服务所以我尝试了一些方法但没有用。 在教程中,它使用 Google Cloud,但我不想使用它。
Webhook 的 URL 我自己改了。我没有更改 DialogFlow 中的任何其他内容,因为它与 google 配合得很好。在那里:
/**
* @Rest\View()
* @Rest\Post("/testDialogBot")
*/
public function testDialogBotAction( Request $request )
{
$re = "Test reponse";
$response = new Response(json_encode( array( "speech" => $re, "displayText" => $re )));
$response->headers->set('Content-Type', 'application/json');
return $response;
}
DialogFlow JSON return :
"status": {
"code": 206,
"errorType": "partial_content",
"errorDetails": "Webhook call failed. Error: Request timeout."
},
我确定它可以工作,我可能做了一些坏事。
感谢您的帮助。
根据 official docs 响应 "should" 具有以下字段:speech、displayText、data、contextOut 和 source。您只发送语音和显示文本。也许添加其他的就可以了。
此外,文档中规定的响应限制为:
Timeout for service response – 5 seconds. Data received in the response from the service – up to 64K.
检查您的服务器是否可以在这些参数范围内发送响应
好的,没关系,您不需要所有参数。我的 URL 错了,似乎 DialogFlow 不接受 https,只接受 http。