这是我第一次使用DialogFlow,Firebase和Node JS。因此,我已经正确设置了帮助者意图示例项目(https://github.com/actions-on-google/dialogflow-helper-intents-nodejs)并能够对其进行测试。我有兴趣让用户的移动设备经久耐用。为此,我已经取消注释ask-for-permission.js文件中的行,修改了该文件,并通过CLI将其上传到Firebase云(firebase deploy --only功能),其显示为“ Deploy complete!”。现在卡住了,有人可以帮我吗?
想知道,代码如何通过变量conv.user.display访问用户名,而在json对象中,用户名在user.displayName中?可能有一个不同的变量来获取经纬度。
'ask_for_permission_confirmation': (conv, params, confirmationGranted) => {
const {location} = conv.device;
const {name} = conv.user;
const {latitude} = location.coordinates.latitude;
if (confirmationGranted) {
if (name) {
conv.ask(``I'll send car at your ${latitude} now ${name.display}.``);
}
if (location) {
const {latitude, longitude} = location.coordinates;
conv.ask(``Your coordinates are ${latitude}, ${longitude}``);
// you can uncomment the above lines and use the latitude and longitude
}
} else {
conv.ask(``Okay, yeah that's fine. I... didn't really want it anyway.``);
}
}
此外,请求json对象具有lat-long ..不确定为什么代码无法访问它。
{
"user": {
"userId": "ABwppHGVsLlZdu4TqeXz5Bg5KkajOKx4Fc-DwAZJy8QAC6Mte1vQk-YAX-a_6NEurypZT47KifWt-zuOAPr9KPS05w",
"profile": {
"displayName": "Abc Def",
"givenName": "Abc",
"familyName": "Def"
},
"permissions": [
"NAME",
"DEVICE_PRECISE_LOCATION"
],
"locale": "en-US",
"lastSeen": "2018-08-15T13:55:26Z",
"userStorage": "{\"data\":{}}"
},
"conversation": {
"conversationId": "1534341346228",
"type": "ACTIVE",
"conversationToken": "[\"_actions_on_google\"]"
},
"inputs": [
{
"intent": "actions.intent.PERMISSION",
"rawInputs": [
{
"inputType": "KEYBOARD",
"query": "ok"
}
],
"arguments": [
{
"name": "PERMISSION",
"boolValue": true,
"textValue": "true"
}
]
}
],
"surface": {
"capabilities": [
{
"name": "actions.capability.SCREEN_OUTPUT"
},
{
"name": "actions.capability.WEB_BROWSER"
},
{
"name": "actions.capability.MEDIA_RESPONSE_AUDIO"
},
{
"name": "actions.capability.AUDIO_OUTPUT"
}
]
},
"device": {
"location": {
"coordinates": {
"latitude": 29.1766528,
"longitude": 82.9702399
}
}
},
"isInSandbox": true,
"availableSurfaces": [
{
"capabilities": [
{
"name": "actions.capability.SCREEN_OUTPUT"
},
{
"name": "actions.capability.WEB_BROWSER"
},
{
"name": "actions.capability.AUDIO_OUTPUT"
}
]
}
],
"requestType": "SIMULATOR"
}