Dialogflow es 在Dialogflow中看不到位置权限

Dialogflow es 在Dialogflow中看不到位置权限,dialogflow-es,actions-on-google,dialogflow-es-fulfillment,Dialogflow Es,Actions On Google,Dialogflow Es Fulfillment,我试图在Dialogfow中检索用户的位置。下面是文档和博客,这是我在index.js文件中写的内容 const functions = require('firebase-functions'); const {WebhookClient} = require('dialogflow-fulfillment'); const {Card, Suggestion} = require('dialogflow-fulfillment'); const {Permission} = require(

我试图在Dialogfow中检索用户的位置。下面是文档和博客,这是我在index.js文件中写的内容

const functions = require('firebase-functions');
const {WebhookClient} = require('dialogflow-fulfillment');
const {Card, Suggestion} = require('dialogflow-fulfillment');
const {Permission} = require('actions-on-google');

process.env.DEBUG = 'dialogflow:debug'; // enables lib debugging statements

exports.dialogflowFirebaseFulfillment = functions.https.onRequest((request, response) => {
  const agent = new WebhookClient({ request, response });
  //const agent = new dialogflow();
  console.log('Dialogflow Request headers: ' + JSON.stringify(request.headers));
  console.log('Dialogflow Request body: ' + JSON.stringify(request.body));

  function welcome(agent) {
    agent.add(`Welcome to my agent!`);
  }

  function fallback(agent) {
    agent.add(`I didn't understand`);
    agent.add(`I'm sorry, can you try again?`);
  }

  const requestPermission = (agent) => {
    //agent.add("Locaation access!");
    //agent.add(new Permission({permissions:'NAME', context:''}));
    agent.requestSource = agent.ACTIONS_ON_GOOGLE;
    const conv = agent.conv();
    conv.ask(new Permission({
        context: '',
        permissions: 'DEVICE_PRECISE_LOCATION',
    }));
    console.log(conv);
    agent.add(conv);
    agent.add("Apple");
  };

  const userInfo = (agent) => {
    if(agent.isPermissionGranted()){
        const address = agent.getDeviceLocation().address;
        if (address){
          agent.add("You are at ${address}");
        }
        else{
            agent.add("Cannot locate you");
        }
    }
    else{
        agent.add("Cannot locate you");
    }
  };

  let intentMap = new Map();
  intentMap.set('Default Welcome Intent', welcome);
  intentMap.set('Default Fallback Intent', fallback);
  intentMap.set('request_permission',requestPermission);
  intentMap.set('user_info', userInfo);
  // intentMap.set('your intent name here', yourFunctionHandler);
  // intentMap.set('your intent name here', googleAssistantHandler);
  agent.handleRequest(intentMap);
});

编辑 这是我得到的JSON响应。 原始API响应:

{
  "responseId": "RESPONSE-ID",
  "queryResult": {
    "queryText": "locate",
    "action": "request_permission",
    "parameters": {},
    "allRequiredParamsPresent": true,
    "fulfillmentMessages": [
      {
        "platform": "ACTIONS_ON_GOOGLE",
        "simpleResponses": {
          "simpleResponses": [
            {
              "textToSpeech": "Apple",
              "displayText": "Apple"
            }
          ]
        }
      }
    ],
    "webhookPayload": {
      "google": {
        "systemIntent": {
          "intent": "actions.intent.PERMISSION",
          "data": {
            "optContext": "",
            "@type": "type.googleapis.com/google.actions.v2.PermissionValueSpec",
            "permissions": [
              "DEVICE_PRECISE_LOCATION"
            ]
          }
        },
        "expectUserResponse": true
      }
    },
    "intent": {
      "name": "projects/MY_PROJECT_NAME",
      "displayName": "request_permission"
    },
    "intentDetectionConfidence": 1,
    "diagnosticInfo": {
      "webhook_latency_ms": 3564
    },
    "languageCode": "en"
  },
  "webhookStatus": {
    "message": "Webhook execution successful"
  }
}
illmentMessages": [
    {
      "platform": "ACTIONS_ON_GOOGLE",
      "simpleResponses": {
        "simpleResponses": [
          {
            "textToSpeech": "Apple",
            "displayText": "Apple"
          }
        ]
      }
    }
  ],
  "payload": {
    "google": {
      "expectUserResponse": true,
      "systemIntent": {
        "intent": "actions.intent.PERMISSION",
        "data": {
          "@type": "type.googleapis.com/google.actions.v2.PermissionValueSpec",
          "optContext": "",
          "permissions": [
            "DEVICE_PRECISE_LOCATION"
          ]
        }
      }
    }
  },
  "outputContexts": []
}
履行请求:

{
  "responseId": "RESPONSE-ID",
  "queryResult": {
    "queryText": "locate",
    "action": "request_permission",
    "parameters": {},
    "allRequiredParamsPresent": true,
    "fulfillmentMessages": [
      {
        "text": {
          "text": [
            ""
          ]
        }
      }
    ],
    "intent": {
      "name": "PROJECT-NAME",
      "displayName": "request_permission"
    },
    "intentDetectionConfidence": 1,
    "languageCode": "en"
  },
  "originalDetectIntentRequest": {
    "payload": {}
  },
  "session": "SESSION-ID"
}
履行响应:

{
  "responseId": "RESPONSE-ID",
  "queryResult": {
    "queryText": "locate",
    "action": "request_permission",
    "parameters": {},
    "allRequiredParamsPresent": true,
    "fulfillmentMessages": [
      {
        "platform": "ACTIONS_ON_GOOGLE",
        "simpleResponses": {
          "simpleResponses": [
            {
              "textToSpeech": "Apple",
              "displayText": "Apple"
            }
          ]
        }
      }
    ],
    "webhookPayload": {
      "google": {
        "systemIntent": {
          "intent": "actions.intent.PERMISSION",
          "data": {
            "optContext": "",
            "@type": "type.googleapis.com/google.actions.v2.PermissionValueSpec",
            "permissions": [
              "DEVICE_PRECISE_LOCATION"
            ]
          }
        },
        "expectUserResponse": true
      }
    },
    "intent": {
      "name": "projects/MY_PROJECT_NAME",
      "displayName": "request_permission"
    },
    "intentDetectionConfidence": 1,
    "diagnosticInfo": {
      "webhook_latency_ms": 3564
    },
    "languageCode": "en"
  },
  "webhookStatus": {
    "message": "Webhook execution successful"
  }
}
illmentMessages": [
    {
      "platform": "ACTIONS_ON_GOOGLE",
      "simpleResponses": {
        "simpleResponses": [
          {
            "textToSpeech": "Apple",
            "displayText": "Apple"
          }
        ]
      }
    }
  ],
  "payload": {
    "google": {
      "expectUserResponse": true,
      "systemIntent": {
        "intent": "actions.intent.PERMISSION",
        "data": {
          "@type": "type.googleapis.com/google.actions.v2.PermissionValueSpec",
          "optContext": "",
          "permissions": [
            "DEVICE_PRECISE_LOCATION"
          ]
        }
      }
    }
  },
  "outputContexts": []
}
我认为这个回答是正确的。但屏幕上没有添加任何内容。它在屏幕上显示这个

控制台中也没有任何错误。但是当我尝试代理的时候,我什么也得不到。
在原始响应中,存在action.intent.PERMISSION,但为什么不添加它或代理询问是/否?

位置权限仅在您使用谷歌助手的谷歌操作时有效。您还需要使用GoogleSimulator上的操作对其进行测试-单击显示“查看GoogleAssistant中的工作原理”的位置


它不适用于其他Dialogflow集成(如Facebook或Slack),也不适用于Dialogflow模拟器(页面右侧的模拟器)。

能否更新您的问题以显示您得到的响应(我假设在模拟器中?)当触发
requestPermission
intent处理程序时,您看到或听到了什么?(它被触发了吗?)在Dialogflow中添加有关意图的屏幕截图也会有所帮助。@谢谢,先生。我已经用JSON响应和模拟器的屏幕截图更新了这个问题。那么我需要更改什么?我不能在Google和Webhook上同时使用动作,对吗?(它在Google assistant中也不起作用。它要求我检查管理员的首选项。我认为这与我的域名admin有关)你当然可以使用AoG、Dialogflow和Webhook。但真正的问题是——你是在写动作吗?如果没有,则不能使用AoG权限。如果您是,您应该使用AoG模拟器进行测试,并且可能需要确保您的帐户被允许这样做。好的,非常感谢。将此标记为正确答案,因为它似乎解决了我的问题。我会更新的情况下,它不工作,即使在联系管理员。