大家好~
今天来实作下图架构的简单版吧!
选择一个 Dialogflow 的 Agent,
先点击齿轮,
再点击 Project ID
,
会导向到 Google Cloud Platform
。
点击建立凭证。
建立一个服务帐户。
输入服务帐户名称。
选择角色 Dialogflow 服务代理人
。
点击完成
建立服务帐户。
点击刚刚建立的服务帐号。
金钥
新增金钥
建立新的金钥
选择 JSON
,
点击建立
下载金钥。
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Log;
use Google\Cloud\Dialogflow\V2\TextInput;
use Google\Cloud\Dialogflow\V2\QueryInput;
use Google\Cloud\Dialogflow\V2\SessionsClient;
public function test(Request $request)
{
$textInput = new TextInput();
$textInput->setLanguageCode('zh-TW')
->setText($request->text);
$queryInput = new QueryInput();
$queryInput->setText($textInput);
$sessionsClient = new SessionsClient([
'credentials' => env('GOOGLE_APPLICATION_CREDENTIALS')
]);
$session = $sessionsClient::sessionName(
env('DIALOGFLOW_PROJECT_ID'), uniqid()
);
$detectIntentResponse = $sessionsClient->detectIntent($session, $queryInput);
$queryResult = $detectIntentResponse->getQueryResult();
$fulfillmentText = $queryResult->getFulfillmentText();
return $fulfillmentText;
}
env 介绍:
就用上次 Day27 做的 Intent 做测试吧!
成功~
那麽今天先这样啦~
若文章有任何问题,
还请大家不吝赐教!
大家明天见!
<<: 大共享时代系列_028_云端串流游戏 ( Cloud Gaming )
...
以前年轻时,常说我只是一颗小小的螺丝钉没什麽用处, 接着就会听到家中长一辈的人正向鼓励着说:「每一个...
简略介绍完VR、AR、MR後,把接下要介绍的是SR。 SR(替代实境):是一种裸眼3D,是一种把虚拟...
前面有介绍过 Module 的一些基本使用方式,然而有一项非常强大的功能没有被提及,就是 动态模组(...
In this part, I will compile a simple program call...