Dialogflow API: Retrieve extracted parameters from Detect intent response

dialogflow list response
dialogflow conditional response
dialogflow detect intent api
dialogflow intent json format
dialogflow get parameter from context
dialogflow get response
dialogflow fulfillment response
dialogflow multiple responses

I'm using the Dialogflow PHP library to work with the Dialogflow API. The detect intent API request returns a complex Google\Protobuf\Struct object for the parameters. Is there an easy way to retrieve the extracted parameters returned in the Detect Intent response?

Here is the part of the code:

$response = $sessionsClient->detectIntent($session, $queryInput);
$queryResult = $response->getQueryResult();
$parameters = $queryResult->getParameters(); // ==> Returns Google\Protobuf\Struct object

These are the parameters returned as seen in the Dialogflow history tab:

"parameters": {
    "integer": "",
    "number": "",
    "currency": "{amount=400000, currency=USD}"

I would like retrieve the parameters in the same format(or array is fine).

Call serializeToJsonString() on the Struct object, or on any other protobuf object.

It can be used to locate a response in the training example set or for reporting The collection of extracted parameters. The intent detection confidence. The action name from the matched intent. parameters: object (Struct format) The collection of extracted parameters. Depending on your protocol or client library language, this is a map, associative array, symbol table, dictionary, or JSON object composed of a collection of (MapKey, MapValue) pairs: MapKey type: string; MapKey value: parameter name

I tried serializeToJsonString() but it didn't work. I extract the parameters like this:


$fields = $queryResult->getParameters()->getFields();

$parameters = [];
foreach($fields as $key => $field) {
    $parameters[$key] = self::get_field_value($field);


private static function get_field_value($field) 
    $kind = $field->getKind();
    if ($kind == "string_value")
        return $field->getStringValue();
    else if ($kind == "number_value")
        return $field->getNumberValue();
    else if ($kind == "bool_value")
        return $field->getBoolValue();
    else if ($kind == "null_value")
        return $field->getNullValue();
    else if ($kind == "list_value") {
        $list_values = $field->getListValue()->getValues();
        $values = [];
        foreach($list_values as $list_value)
            $values[] = self::get_field_value($list_value);

        return $values;    
    else if ($kind == "struct_value")
        return $field->getStructValue();

In many occasions we want to get information from Dialogflow response, like the Response - Intent Name; Query Response - Intent Detection Confidence  Dialogflow provides a feature called slot-filling that ensures an intent obtains all the necessary information from a user. To activate this feature, we need to mark the parameters as required . When an intent has required parameters, but it is matched with a user utterance that lacks any of the required parameters, the intent asks prompt questions in order to retrieve all the required parameters from the user.

$queryResult = $response->getQueryResult();
$jsonString = $queryResult->serializeToJsonString();

The /intents endpoint is used to create, retrieve, update, and delete intent objects. An action is essentially an extraction of the user command or sentence semantics. Note: You can still use the previous base URL https://api.api.ai/v1/ . key/value pairs and objects related to responses for the intent. When an intent is matched at runtime, Dialogflow provides the action value to your fulfillment webhook request or the API interaction response. It can be used to trigger specific logic in your service. Parameters When an intent is matched at runtime, Dialogflow provides the extracted values from the end-user expression as parameters.

Hi, I am creating intents using api v2 with training phrases. i am able to detecting entities i tried with one of training phrase and i am able to detect intent and acti. Alright so after some digging. https://cloud.google.com/dialogflow- the field parameters must be set with entities you expect in the response. The instructions below focus on using the console. To access intent response data: Go to the Dialogflow Console. Select an agent. Select Intents in the left sidebar menu. Select an intent. Scroll down to the Responses section. If you are building an agent using the API instead of the console, see the Intents reference. The API field names are similar to the console field names.

false if the matched intent has required parameters and not all of the required parameter values public bool AllRequiredParamsPresent { get; set; } Free-​form diagnostic information for the associated detect intent request. webhook call, this field is set to the value of the payload field returned in the webhook response. {id} is the ID of the intent to retrieve. One intent is used across all languages/locales and it uses the same name and ID. To retrieve an intent's content for a specific language, add the lang parameter and the language/locale code to the request URL.

into an action. An action is an extraction of a user command or sentence semantics. Optional. The collection of rich messages corresponding to the Response field in the Dialogflow console. Types.Parameter> Parameters { get; } If the supplied value is negative, the intent is ignored in runtime detect intent requests. You build dialogs by creating Dialogflow intents, specifying training phrases to define the grammar or what users need to say to trigger an intent and the corresponding response to the intent. Dialogflow also supports Assistant rich responses, like basic cards , lists , and more .

  • have yoo tried to typecast it into dictionary or array
  • Hi @sid8491 how do I do that?