Request user location without nodejs library

Viewed 304

I was successfully able to request user location with help of action-on-google nodejs library, but I am more of java guy, and I need to do this in java.

https://developers.google.com/actions/assistant/helpers#json

How can I request the user's location in API.ai?

Requesting User Location from Google Actions with Api.ai

From above links, I find out that it is possible with just json reponses.

I've created my poc app in api.ai, which returns below json reponses

1

{
    "conversationToken": {
        "state": null,
        "data": {}
    },
    "expectUserResponse": true,
    "expectedInputs": [
        {
            "inputPrompt": {
                "initialPrompts": [
                    {
                        "textToSpeech": "PLACEHOLDER_FOR_PERMISSION"
                    }
                ],
                "noInputPrompts": null
            },
            "possibleIntents": [
                {
                    "intent": "actions.intent.PERMISSION",
                    "inputValueData": {
                        "@type": "type.googleapis.com/google.actions.v2.PermissionValueSpec",
                        "optContext": "Requesting Location.",
                        "permissions": [
                            "DEVICE_COARSE_LOCATION"
                        ]
                    }
                }
            ]
        }
    ]
}

This returns : Unparseable Json Response

2

{
    "contextOut": [
        {
            "lifespan": 100,
            "name": "_actions_on_google_",
            "parameters": null
        },
        {
            "lifespan": 5,
            "name": "requesting_permission",
            "parameters": null
        }
    ],
    "data": {
        "google": {
            "expect_user_response": true,
            "is_ssml": false,
            "no_input_prompts": null,
            "permissions_request": {
                "opt_context": "Requesting Location.",
                "permissions": [
                    "DEVICE_COARSE_LOCATION"
                ]
            }
        }
    },
    "speech": "PLACEHOLDER_FOR_PERMISSION"
}

This return : PLACEHOLDER TEXT

I wanted to know that way I am doing it is possible or not. If yes, what I am doing wrong ?

Please help.

1 Answers
Related