如何在DialogFlow请求中找到JSON错误?

时间:2017-10-26 12:48:39

标签: json dialogflow

我将以下intent创建json发送到DialogFlow API hook并继续收到错误“JSON语法错误”。有没有办法可以得到更详细的错误描述?

{
"templates": [],
"lastUpdate": 1508084934,
"fallbackIntent": "false",
"name": "address-intent",
"contexts": [
    "order-intent-order-done-confirm-followup"
],
"auto": "true",
"webhookUsed": "true",
"events": [],
"priority": 500000,
"userSays": [
    {
        "count": 0,
        "isTemplate": "false",
        "data": [
            {
                "text": "deliver to ",
                "userDefined": "false"
            },
            {
                "text": "washington square",
                "meta": "@sys.address",
                "userDefined": "false",
                "alias": "address"
            }
        ]
    },
    {
        "count": 0,
        "isTemplate": "false",
        "data": [
            {
                "text": "please deliver it to ",
                "userDefined": "false"
            },
            {
                "text": "washington square",
                "meta": "@sys.address",
                "userDefined": "false",
                "alias": "address"
            }
        ]
    },
    {
        "count": 0,
        "isTemplate": "false",
        "data": [
            {
                "text": "34 1st street",
                "meta": "@sys.address",
                "userDefined": "false",
                "alias": "address"
            }
        ]
    },
    {
        "count": 0,
        "isTemplate": "false",
        "data": [
            {
                "text": "deliver it to ",
                "userDefined": "false"
            },
            {
                "text": "washington square",
                "meta": "@sys.address",
                "userDefined": "false",
                "alias": "address"
            }
        ]
    }
],
"webhookForSlotFilling": "false",
"responses": [
    {
        "affectedContexts": [
            {
                "name": "address-intent-followup",
                "parameters": {},
                "lifespan": 1
            }
        ],
        "parameters": [
            {
                "name": "address",
                "dataType": "@sys.address",
                "required": "true",
                "value": "$address",
                "prompts": [
                    {
                        "lang": "en",
                        "value": "What's the address for the delivery?"
                    },
                    {
                        "lang": "en",
                        "value": "Where should we send the order to?"
                    },
                    {
                        "lang": "en",
                        "value": "What's your address?"
                    }
                ],
                "isList": "false"
            }
        ],
        "messages": [
            {
                "lang": "en",
                "speech": [],
                "type": 0
            }
        ],
        "defaultResponsePlatforms": {},
        "action": "address-intent",
        "speech": [],
        "resetContexts": "false"
    }
]
}

要清楚,其他意图创建请求可以正常工作(以及获取请求),所以我很确定我的JSON中的某些内容是错误的。 JSON是有效的JSON(经过验证的here

2 个答案:

答案 0 :(得分:1)

这是prompts集合。 它应该是字符串列表而不是对象列表。 一个体面的错误信息本来不错。

答案 1 :(得分:0)

您提供的JSON是Dialogflow将在您的webhook请求正文中发送给您的webhook的JSON。要回复您的用户,您必须使用如下响应来回复此请求:

rank

Headers: Content-type: application/json Body: { "speech": "Barack Hussein Obama II was the 44th and current President of the United States.", "displayText": "Barack Hussein Obama II was the 44th and current President of the United States, and the first African American to hold the office. Born in Honolulu, Hawaii, Obama is a graduate of Columbia University and Harvard Law School, where ", "data": {...}, "contextOut": [...], "source": "..." } datacontextOut属性是可选的。 sourcespeech是必需的,分别对应于用户说出和显示的内容。