简体   繁体   English

带有PHP的DialogFlow(API.AI)REST

[英]DialogFlow (API.AI) REST with php

I work on DialogFlow recently and I need to send a POST to my own web services. 我最近在DialogFlow上工作,我需要将POST发送到我自己的Web服务。 It's a Rest services work with Symfony et PHP. 这是Symfony et PHP的Rest服务。

So I tried something and it didn't work. 所以我尝试了一些东西,但是没有用。 In the tutorial it worked with Google Cloud, but I don't want to work with it. 在本教程中,它可以与Google Cloud一起使用,但是我不想使用它。

I changed the URL of Webhook with my own. 我用自己的方式更改了Webhook的URL。 I didn't change anything else in DialogFlow because it was good with google. 我没有对DialogFlow进行任何其他更改,因为它对Google很好。 There it is : 那里是:

/**
 * @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;

}

The JSON of DialogFlow return : DialogFlow的JSON返回:

"status": {
  "code": 206,
  "errorType": "partial_content",
  "errorDetails": "Webhook call failed. Error: Request timeout."
},

I'm sure it can work, I do something bad probably. 我确信它可以正常工作,可能是我做错了。

Thank's for help. 感谢帮助。

According to the official docs the response "should" have the following fields: speech, displayText, data, contextOut adn source. 根据官方文档 ,响应“应该”具有以下字段:语音,displayText,数据,contextOut和源。 You are only sending speech and displayText. 您仅发送语音和displayText。 Maybe adding the others will do the trick. 也许添加其他将解决问题。

Also, the limits stated on the docs for the response are: 此外,文档中规定的响应限制为:

Timeout for service response – 5 seconds. 服务响应超时– 5秒。 Data received in the response from the service – up to 64K. 服务响应中收到的数据–最多64K。

Check if your server can send the response within those parameters 检查您的服务器是否可以在这些参数内发送响应

Ok that's fine, you don't need every parameters. 好的,您不需要每个参数。 My URL was wrong and It seems that DialogFlow doesn't accept https but only http. 我的网址有误,似乎DialogFlow不接受https,而仅接受http。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM