Reputation: 1
I am using the google/cloud-dialogflow library for php.
I can not get the data from $queryResult->getFulfillmentMessages()
; I don't know how.
I have tried:
json_decode($queryResult->getFulfillmentMessages()->serializeToJsonString(), true);
But it shows me a error. I hope you can help me.
Upvotes: 0
Views: 670
Reputation: 11
This solution worked for me. The response that is received from the queryResult is a protobuf repeated field. The payload that is required to be extracted can be accessed by calling the first element of the repeated field and serializing it to JSON string then decoding it.
json_decode($queryResult->getFulfillmentMessages()[0]->serializeToJsonString(), true);
This will give the payload in array format using which you can perform your operations on it.
Upvotes: 1