PHP Dialogflow V2 API Example (DetectIntent method)
A working PHP Dialogflow V2 API example using the DetectIntent method (SessionsClient::detectIntent()
).
git clone https://bitbucket.org/labonte/php-dialogflow-api.git
cd php-dialogflow-api
cp .env.dist .env
vim .env
)composer install
php -S 127.0.0.1:8080 -t .
cp .htaccess.dist .htaccess
vim .htaccess
)composer install --no-dev
Take a look into the .htaccess.dist file. You have to reproduce the those statements. The resulting config for your nginx location section should look something like this:
location /DetectIntent {
# Fill in!!!
# Supply your Google Project ID and path to the credentials file.
fastcgi_param GOOGLE_PROJECT_ID [YOUR PROJECT ID]
fastcgi_param GOOGLE_APPLICATION_CREDENTIALS [YOUR GOOGLE APPLICATION CREDENTIALS FILE PATH]
# Optionally change the maximum nesting level of your custom payload objects.
fastcgi_param FULFILLMENT_MESSAGE_MAX_NESTING 64
fastcgi_pass php;
fastcgi_index DetectIntent.php;
...
}
I have not tested this!! The php upstream config is up to you.