Gactions project is sending version 1 request sche

2019-09-13 17:01发布

问题:

According to this document Actions on Google - Overview

Google is now using version 2 JSON schema, but the requests my server is receiving from the simulator is version 1. Is there something I need to do to get version 2 JSON schema?

I have updated my gactions project action.json file to the new format and uploaded it.

This is my action.json

{
"actions": [
    {
        "description": "Default Welcome Intent",
        "name": "MAIN",
        "fulfillment": {
            "conversationName": "welcome"
        },
        "intent": {
            "name": "actions.intent.MAIN"
        }
    },
    {
        "description": "Example response",
        "name": "Raw input",
        "fulfillment": {
            "conversationName": "rawInput"
        },
        "intent": {
            "name": "raw.input",
            "parameters": [
                {
                    "name": "requestText",
                    "type": "SchemaOrg_Text"
                }
            ],
            "trigger": {
                "queryPatterns": [
                    "$SchemaOrg_Text:requestText"
                ]
            }
        }
    }
],
"conversations": {
    "welcome": {
        "name": "welcome",
        "url": "https://myserver.com/api/request/gactions",
        "fulfillmentApiVersion": 2
    },
    "rawInput": {
        "name": "rawInput",
        "url": "https://myserver.com/api/request/gactions",
        "fulfillmentApiVersion": 2
    }
}

}

回答1:

The simulator now sends version 2 and my application has not been approved yet. Here is what I get:

Request headers:
host: gactions.example.com
accept-encoding: gzip,deflate,br
content-type: application/json
google-actions-api-version: 2
user-agent: Mozilla/5.0 (compatible; Google-Cloud-Functions/2.1; +http://www.google.com/bot.html)
content-length: 380
x-forwarded-port: 443
x-forwarded-proto: https
x-forwarded-host: example.com
x-forwarded-server: ip-10-0-0-36.ec2.internal
connection: Keep-Alive
--------
Body of request: 
{
    "user": {
        "userId": "1500679128193",
        "locale": "en-US"
    },
    "conversation": {
        "conversationId": "1500679128193",
        "type": "NEW"
    },
    "inputs": [{
            "intent": "actions.intent.MAIN",
            "rawInputs": [{
                    "inputType": "KEYBOARD",
                    "query": "talk to tom's applicaiton"
                }
            ]
        }
    ],
    "surface": {
        "capabilities": [{
                "name": "actions.capability.AUDIO_OUTPUT"
            }, {
                "name": "actions.capability.SCREEN_OUTPUT"
            }
        ]
    },
    "device": {},
    "isInSandbox": true
}