Search code examples
actions-on-googlegoogle-assist-api

Turn off google assistant mic


I'm implementing an app in "Dialog Flow"

I'm sending request to app like this

$text = "Something";

$data = array(
         "source" =>  $text,
         "speech" =>  $text,
         "displayText" =>$text,
         "contextOut" => array()
     );
header('Content-Type: application/json');
echo json_encode($data);

The text displayed in app. but mic is open I want turn off the mic .

I tried expectUserResponse but not working

array(
         "expectUserResponse" => false,
         "source" =>  $text,
         "speech" =>  $text,
         "displayText" =>$text,
         "contextOut" => array()
     )

Solution

  • The expectUserResponse parameter is not part of the Dialogflow response JSON. Instead, it is part of the Actions on Google specific part of the response. If you're using Dialogflow v1, this will be in the data.google object. If you're using Dialogflow v2, this will be in the payload.google object.

    So if you're using Dialogflow v1, your code might look something like this:

    array(
      "speech" =>  $text,
      "displayText" =>$text,
      "contextOut" => array(),
      "data" => array(
        "google" => array(
          "expectUserResponse": false
        )
      )
    )
    

    while v2 might look like

    array(
      "speech" =>  $text,
      "displayText" =>$text,
      "contextOut" => array(),
      "payload" => array(
        "google" => array(
          "expectUserResponse": false
        )
      )
    )