我已成功地通過action-on-google nodejs庫請求用戶位置,但我更多的是java小夥子,我需要在java中執行此操作。在沒有nodejs庫的情況下請求用戶位置
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
從上面的鏈接,我發現這是可能的只是JSON反應變量。
我創建了一個api.ai我POC的應用程序,它返回以下JSON反應變量
{
"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"
]
}
}
]
}
]
}
這將返回: Unparseable Json Response
{
"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"
}
此退貨: PLACEHOLDER TEXT
我想知道我這樣做的方式是否可行。如果是,我做錯了什麼?
請幫忙。
現在有一個非官方的Java /科特林SDK。它具有nodejs和非常類似的API的所有功能。我維護這個項目,並且很快就會更新文檔和自述文件,但它已經可以使用並且處於Maven核心。 https://github.com/TicketmasterMobileStudio/actions-on-google-kotlin – Patrick
@Patrick謝謝,我會看看 – Sukh