在模拟器上测试我的应用时,我一直收到错误 它给出了:“APP NAME,现在没有响应,请尽快重试” 我在这里做错了什么?
{
"accountLinking": {
"clientId": "", // SENSITIVE INFORMATION BLANK
"clientSecret": "", // SENSITIVE INFORMATION BLANK
"grantType": "AUTH_CODE",
"authenticationUrl": "", // SENSITIVE INFORMATION BLANK
"accessTokenUrl": "" // SENSITIVE INFORMATION BLANK
},
"actions": [{
"description": "",
"name": "MAIN",
"fulfillment": {
"conversationName": "PASS TEXT"
},
"intent": {
"name": "actions.intent.MAIN",
"trigger": {
"queryPatterns": [
"talk to APP NAME"
]
}
}
}],
"conversations": {
"PASS TEXT": {
"name": "PASS TEXT",
"url": "" // MY FULFILLMENT END POINT
"fulfillmentApiVersion": 2
}
}
}
这只是向用户返回“Sure,thing”的示例。
header('Content-Type: application/json');
$a = array (
'conversationToken' => '{"state":null,"data":{}}',
'expectUserResponse' => true,
'expectedInputs' =>
array (
0 =>
array (
'inputPrompt' =>
array (
'richInitialPrompt' =>
array (
'items' =>
array (
0 =>
array (
'simpleResponse' =>
array (
'textToSpeech' => 'Okay sure',
'displayText' => 'Okay, Sure!',
),
),
),
'suggestions' =>
array (
),
),
),
'possibleIntents' =>
array (
0 =>
array (
'intent' => 'actions.intent.TEXT',
),
),
),
),
);
echo json_encode($a);
PS:也没有任何PHP错误。访问URL时页面运行时没有任何错误。
我还用OAuth PLAYGROUND测试了它,返回的结果就是这个
{
"finalResponse": {
"richResponse": {
"items": [
{
"simpleResponse": {
"displayText": "Sure, thing!",
"textToSpeech": "Sure thing"
}
}
]
}
},
"expectUserResponse": 0,
"isInSandbox": 1
}
答案 0 :(得分:2)
您的原始帖子中有两个问题(您已更新以反映这两个问题):
问题1 - 无效的JSON响应。
“expectUserResponse”的值应该是布尔值,而不是数字。这在JSON中很重要。所以它应该是
"expectUserResponse": true
(“isInSandbox”的值也是如此)
第2期 - 版本不匹配
您发送的响应似乎与规范的版本2匹配,但您的action.json未指定版本,因此默认为版本1.要指定版本2,您的action.json文件“会话”部分应该如下:
"conversations": {
"PASS TEXT": {
"name": "PASS TEXT",
"url": "https://whatever.example.com/endpoint",
"fulfillmentApiVersion": 2
}
}
要查看的其他事项
尝试预先验证会引入并发症。首先要尝试的是删除身份验证要求,并确保您的端点返回有效的响应。完成后,请重新添加身份验证。
沙箱模式与交易相关联。除非您正在进行交易,否则您可以尝试删除此参数。
确保您的webhook是具有有效(非自签名)证书的HTTPS端点。如果您需要创建隧道进行测试,请考虑ngrok
确保在更改时重新上传了action.json文件,并在完成后重新启动模拟器。
我的测试文件
我最少使用以下文件:
action.json
{
"actions": [
{
"description": "Default Welcome Intent",
"name": "MAIN",
"fulfillment": {
"conversationName": "playground"
},
"intent": {
"name": "actions.intent.MAIN",
"trigger": {
"queryPatterns": [
"talk to playground"
]
}
}
}
],
"conversations": {
"playground": {
"name": "playground",
"url": "https://example.ngrok.io/assistant/webhookEnd.php",
"fulfillmentApiVersion": 2
}
}
}
webhookEnd.php 文件:
<?php
header('Content-Type: application/json');
$a = [
"expectUserResponse" => false,
"finalResponse" => [
"richResponse" => [
"items" => [
[
"simpleResponse" => [
"textToSpeech" => "Sure thing!",
"displayText" => "Sure, thing?"
]
]
]
]
]
];
echo json_encode($a);
答案 1 :(得分:0)
我意识到在我的谷歌oauth游乐场,它有一个内部服务器错误
HTTP/1.1 200 Internal Server Error
Content-length: 293
X-powered-by: ASP.NET
Server: Microsoft-IIS/8.5
Date: Tue, 25 Jul 2017 08:10:11 GMT
Content-type: application/json
X-powered-by-plesk: PleskWin
然后我用Google搜索了这个错误,我看到帖子说json的响应格式不正确。所以我去了履行文件,并采取了响应json的样本,将其转换为数组和VOILA,内部服务器错误消失了
HTTP/1.1 200 OK
Content-length: 293
X-powered-by: ASP.NET
Server: Microsoft-IIS/8.5
Date: Tue, 25 Jul 2017 08:10:11 GMT
Content-type: application/json
X-powered-by-plesk: PleskWin
我希望模拟器能够显示有关错误的更多详细信息,而不仅仅是提示“APP NAME没有响应” 祝大家好运!