php - 在 Laravel + SQLite 上使用 DialogFlow ES EventInput
问题描述
我是 DialogFlow API 的新手并创建了 Laravel 沙盒应用程序,它需要一些查询数据并将其发送到数据库。我想使用 HTTP 协议通过 EventQuery 开始对话,但无法弄清楚整个方法。
有一个 JavaScript 应用程序使用硬编码的事件查询参数并将其发送到一个简单的 UI。这几乎是它,但没有分贝。
EventQuery 类:https ://github.com/googleapis/google-cloud-php-dialogflow/blob/master/src/V2/EventInput.php
Laravel 沙盒应用:https ://phpsandbox.io/e/x/gziyh?layout=EditorPreview&defaultPath=%2F&theme=dark&showExplorer=no&openedFiles=
带有 eventQuery 的 JavaScript 应用程序:https ://github.com/fitwist/chatbot-app
如何发送由表单数据组成的 EventQuery 请求,同时将数据发送到 SQLite 并在简单的 UI 中继续对话?
可能的模板:
<?php
namespace Google\Cloud\Dialogflow\V2;
use Google\Protobuf\Internal\GPBType;
use Google\Protobuf\Internal\RepeatedField;
use Google\Protobuf\Internal\GPBUtil;
class EventInput extends \Google\Protobuf\Internal\Message
{
private $name = '';
private $parameters = null;
private $language_code = '';
public function __construct($data = NULL) {
\GPBMetadata\Google\Cloud\Dialogflow\V2\Session::initOnce();
parent::__construct($data);
}
public function getName()
{
return $this->name;
}
public function setName($var)
{
GPBUtil::checkString($var, True);
$this->name = $var;
return $this;
}
public function getParameters()
{
return isset($this->parameters) ? $this->parameters : null;
}
public function hasParameters()
{
return isset($this->parameters);
}
public function clearParameters()
{
unset($this->parameters);
}
public function setParameters($var)
{
GPBUtil::checkMessage($var, \Google\Protobuf\Struct::class);
$this->parameters = $var;
return $this;
}
public function getLanguageCode()
{
return $this->language_code;
}
public function setLanguageCode($var)
{
GPBUtil::checkString($var, True);
$this->language_code = $var;
return $this;
}
}
?>
<!DOCTYPE html>
<html>
<section class="container grey-text">
<h4 class="center">Add a Pizza</h4>
<form class="white" action="add.php" method="POST">
<label>Your Email</label>
<input type="text" name="email">
<label>Your Name</label>
<input type="text" name="name">
<label>Company</label>
<input type="text" name="company">
<div class="center">
<input type="submit" name="submit" value="Submit" class="btn brand z-depth-0">
</div>
</form>
</section>
</html>
我将感谢您的任何帮助,因为这场斗争已经进行了三个月。