In the actions on google request object I have accessToken that I'm setting via account linking
{
"user": {
"userId": "user_id",
"accessToken": "access_token",
"locale": "en-US",
"lastSeen": "2018-06-05T09:52:35Z",
"userStorage": "{\"data\":{}}"
},
etc
My firebase function allows to look for values in the Firebase database when the intent is triggered.
import * as admin from 'firebase-admin'
import * as functions from 'firebase-functions'
import { dialogflow } from 'actions-on-google'
const dialogApp = dialogflow();
dialogApp.intent("request_value", async (conv, {devices}) => {
console.log(devices);
let device_name = devices;
const snapshot = await admin.database().ref(`/system/ecofarmTest/component/${device_name}/data`).orderByChild("timestamp").limitToFirst(1).once('value');
snapshot.forEach(function(childSnapshot) {
console.log("Test child timestamp " + childSnapshot.val().timestamp)
console.log("Test child value " + childSnapshot.val().value)
const value_object = childSnapshot.val();
conv.ask(`The ${device_name} is ${value_object.value}.\nWould you like to check anything else?`);
return;
})
});
export const receiveAssistantRequest = functions.https.onRequest(dialogApp);
Before the API change I new how to access the request object. But now, how do I access the request object to get the accessToken?
帐户链接完成后,您可以使用访问您的access_token
conv.user.access.token
我找到了方法:
let access_token = conv.request.user.accessToken
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.