【问题标题】:Turn off google assistant mic关闭谷歌助理麦克风
【发布时间】:2018-04-18 11:48:56
【问题描述】:

我正在“Dialog Flow”中实现一个应用程序

我正在向这样的应用发送请求

$text = "Something";

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

应用中显示的文字。但是麦克风是打开的,我想关掉麦克风。

我尝试了expectUserResponse,但没有工作

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

请帮忙。

【问题讨论】:

  • 您使用的是 Dialogflow 还是 Action SDK?
  • 我正在使用对话流

标签: actions-on-google google-assist-api


【解决方案1】:

expectUserResponse 参数不是Dialogflow response JSON 的一部分。相反,它是 Actions on Google 响应的特定部分的一部分。如果您使用的是 Dialogflow v1,它将位于 data.google 对象中。如果您使用的是 Dialogflow v2,它将位于 payload.google 对象中。

因此,如果您使用的是 Dialogflow v1,您的代码可能如下所示:

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

而 v2 可能看起来像

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

【讨论】:

  • 我稍微修改了一下。它奏效了。 "data"=> array("google" => array("expect_user_response" => false ))
  • 使用下划线可能会在下个月停止工作,因为它是已弃用的 AoG v1 API 的一部分。对它的支持将于 5 月结束。 (这与仍受支持但不再接收新功能更新的 Dialogflow v1 API 无关。)
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2018-01-09
  • 2014-01-27
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多