我正在“
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()
)
expectUserResponse
参数不是 Dialogflow 响应 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
)
)
)