获取用户ID GoogleActions
问题描述:
我试图让火力地堡的用户ID来我的谷歌用户,但显然它是不确定的获取用户ID GoogleActions
dialogflowFirebaseFulfillment
ReferenceError: userId is not defined
at IncomingMessage.resp.on (/user_code/index.js:73:17)
at emitNone (events.js:91:20)
at IncomingMessage.emit (events.js:185:7)
at endReadableNT (_stream_readable.js:974:12)
at _combinedTickCallback (internal/process/next_tick.js:80:11)
at process._tickDomainCallback (internal/process/next_tick.js:128:9)
这是我的代码
const REQUEST_PERMISSION_ACTION = 'request_permission';
const userUID = app.getUser().userId;
const userName = app.getUserName().displayName;
console.log(userUID, 'USERRRRRRID');
我能做些什么来获取用户标识?
答
这是我的代码
function processV1Request (request, response) {
let action = request.body.result.action; // https://dialogflow.com/docs/actions-and-parameters
let parameters = request.body.result.parameters; // https://dialogflow.com/docs/actions-and-parameters
let inputContexts = request.body.result.contexts; // https://dialogflow.com/docs/contexts
let requestSource = (request.body.originalRequest) ? request.body.originalRequest.source : undefined;
const googleAssistantRequest = 'google'; // Constant to identify Google Assistant requests
const app = new DialogflowApp({request: request, response: response});
// Create handlers for Dialogflow actions as well as a 'default' handler
const actionHandlers = {
// The default welcome intent has been matched, welcome the user (https://dialogflow.com/docs/events#default_welcome_intent)
'input.welcome':() => {
sendGoogleResponse(' Bonjour, Que puis je faire pour vous ?');
},
'input.what':() => {
const http = require('http');
const https = require('https');
https.get('https://bnpparibas-api.openbankproject.com/obp/v3.0.0/my/banks/bnpparibas.07.fr/accounts/cbf874f8-9eb1-4fdf-899c-54b8c5e7c2c8/account', (resp) => {
let data = '';
const app = new ActionsSdkApp({request: request, response: response});
// A chunk of data has been recieved.
resp.on('data', (chunk) => {
data += chunk;
});
见https://stackoverflow.com/questions/47749476/i-can-not-get-information-with-dialogflowapp-getuser-method/47752302 – Bart
我试图让我的令牌但显然它是空的(TypeError:无法读取null属性的'accessToken') –
我指的是关于'const app = new App({request:req,response:res})的囚徒的帖子;'尝试添加更多的代码给您的帖子,以便我们可以帮助更好,如果这不起作用。 – Bart