Hi, this is my first bug report, please tell me if anything's wrong with it.
I'm not even sure if this is a bug or simply an error on my part but I've been trying to solve this for three days and I have run out of ideas.
<?php
namespace AppBundle\Controller;
use Ramsey\Uuid\Uuid;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
use Google\Cloud\Dialogflow\V2\SessionsClient;
use Google\Cloud\Dialogflow\V2\TextInput;
use Google\Cloud\Dialogflow\V2\QueryInput;
class DefaultController extends Controller
{
/**
* @Route("/messenger", name="homepage")
*
*/
public function indexAction(Request $request)
{
return $this->render('@App/messenger.twig', array());
}
/**
* @param Request $request
*
* @Route("/messenger/call/{intent}", options={"expose"=true}, name="call_assistant")
* @throws \Google\ApiCore\ValidationException
* @throws \Google\ApiCore\ApiException
* @throws \Exception
*/
public function callAssistantAction(Request $request, $intent) {
$sessionDialogFlow = $this->get('session')->get('dialogFlow_session');
if ($sessionDialogFlow === null) {
$sessionDialogFlow = Uuid::uuid4()->toString();
$this->get('session')->set('dialogFlow_session', $sessionDialogFlow);
}
$sessionClient = new SessionsClient(array(
'credentials' => realpath($this->getParameter('kernel.root_dir'). "/../web/authentDialogFlow.json")
));
$session = $sessionClient->sessionName("<my session name>", $sessionDialogFlow);
$textInput = new TextInput();
$textInput->setText($intent);
$textInput->setLanguageCode('fr-FR');
$queryInput = new QueryInput();
$queryInput->setText($textInput);
$response = $sessionClient->detectIntent($session, $queryInput); // <- this line is where the crash happens
$queryResult = $response->getQueryResult();
$fulfillmentText = $queryResult->getFulfillmentText();
return new JsonResponse(array("response" => $fulfillmentText));
}
}
{
"queryText": "hey",
"action": "input.welcome",
"parameters": {},
"fulfillmentText": "Salutations !",
"fulfillmentMessages": [
{
"text": {
"text": [
"Salutations !"
]
},
"lang": "fr"
}
],
"intent": {
"id": "<id>",
"displayName": "Default Welcome Intent",
"priority": 500000,
"events": [
"WELCOME"
],
"action": "input.welcome",
"messages": [
{
"text": {
"text": [
"Hi! How are you doing?",
"Hello! How can I help you?",
"Good day! What can I do for you today?",
"Greetings! How can I assist?"
]
},
"lang": "en"
},
{
"text": {
"text": [
"Salut !",
"Bonjour !",
"Salutations !",
"Bienvenue !"
]
},
"lang": "fr"
}
]
},
"intentDetectionConfidence": 1,
"languageCode": "fr",
"slotfillingMetadata": {
"allRequiredParamsPresent": true
},
"id": "<id>",
"sessionId": "<id>",
"timestamp": "2019-07-15T07:41:28.778Z",
"source": "agent",
"webhookStatus": {
"webhookEnabledForAgent": true
},
"agentEnvironmentId": {
"agentId": "<id>",
"cloudProjectId": "<id>"
}
}
{
"queryText": "aide",
"parameters": {},
"fulfillmentText": "<long text>",
"fulfillmentMessages": [
{
"text": {
"text": [
"<long text>"
]
},
"lang": "fr"
}
],
"intent": {
"id": "<id>",
"displayName": "Help",
"priority": 500000,
"messages": [
{
"text": {
"text": [
"<long text>"
]
},
"lang": "fr"
}
]
},
"intentDetectionConfidence": 1,
"languageCode": "fr",
"slotfillingMetadata": {
"allRequiredParamsPresent": true
},
"id": "<id>",
"sessionId": "<id>",
"timestamp": "2019-07-15T13:05:25.255Z",
"source": "agent",
"webhookStatus": {
"webhookEnabledForAgent": true
},
"agentEnvironmentId": {
"agentId": "<id>",
"cloudProjectId": "<id>"
}
}
(Alas no one answered yet)
Thanks for your help !
Thanks for the report @Mania-1024, let's see what we can do to get you back on track.
Would you be able to share the error output you get when the application crashes?
Hi @dwsupplee ,
Unfortunately the only output I get is very generic :
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<title>An Error Occurred: Internal Server Error</title>
</head>
<body>
<h1>Oops! An Error Occurred</h1>
<h2>The server returned a "500 Internal Server Error".</h2>
<div>
Something is broken. Please let us know what you were doing when this error occurred. We will fix it as soon as possible. Sorry for any inconvenience caused.
</div>
</body>
</html>
I can't seem to catch the error with a try/catch block either, the catch block seems ignored, maybe because it's an http request... (I'm not used to PHP or Symfony though) And I didn't find any useful log on my server either.
Is there any solution for this. I am facing the same issue here. It works fine when call it locally, but just not printing out anything on the website when put it into the server.
Any update ? :( This is a really big problem for me... I can't figure out why it doesn't work, it makes no sense.
@Mania-1024, @boshng95 - taking a look today.
I set up a fresh symfony project and attempted to replicate this, but was not able to.
Would you be able to wrap the network request in a try/catch block so you could capture the error message to help give me a little more to go off of?
try {
$response = $sessionClient->detectIntent($session, $queryInput);
} catch (\Exception $ex) {
// capture the exception here
}
@dwsupplee Thank you for your time :)
I had issues logging the error because as a total rookie, I was still working in the production environment.
So, here is the caught error :
<br />
<b>Fatal error</b>: Uncaught Symfony\Component\Debug\Exception\UndefinedFunctionException: Attempted to call function "bccomp" from namespace "Google\Protobuf\Internal". in <my root directory>/vendor/google/protobuf/src/Google/Protobuf/Internal/Message.php:900
Stack trace: #0 <my root directory>/vendor/google/protobuf/src/Google/Protobuf/Internal/Message.php(1218): Google\Protobuf\Internal\Message->convertJsonValueToProtoValue(5, Object(Google\Protobuf\Internal\FieldDescriptor)) #1 <my root directory>/vendor/google/protobuf/src/Google/Protobuf/Internal/Message.php(1167):
Google\Protobuf\Internal\Message->mergeFromArrayJsonImpl(Array) #2 <my root directory>/vendor/google/protobuf/src/Google/Protobuf/Internal/Message.php(815): Google\Protobuf\Internal\Message->mergeFromJsonArray(Array) #3 <my root directory>/vendor/google/protobuf/src/Google/Protobuf/Internal/Message.php(1211):
Google\Protobuf\Internal\Message->convertJsonValueToProtoValue(Array, Object(Google\Protobuf\Internal\FieldDes in <b><my root directory>/vendor/symfony/symfony/src/Symfony/Bundle/TwigBundle/Resources/views/layout.html.twig</b> on line <b>15</b><br
/>
Does that ring a bell to you ?
Hi @Mania-1024,
It looks like your server is missing the bcmath PHP extension. In Debian, you should be able to install it via apt-get install php-bcmath.
Hi @jdpedrie ,
Thank you so much for the tip. bcmath was pre-installed on the server but not enabled. I added it to my php.ini and it's finally working !!
Great!
For future reference, we're tracking this issue here.
Most helpful comment
Hi @jdpedrie ,
Thank you so much for the tip.
bcmathwas pre-installed on the server but not enabled. I added it to myphp.iniand it's finally working !!