In my DialogFlow V1 Webhook, I used to get the user's access token like this (node.js):
exports.voxGoogleHomeWebhook = functions.https.onRequest((req, res) => {
const app = new WebhookClient({request: req, response: res});
var accessToken = app.getUser().accessToken
This does not work in DialogFlow V2. getUser()
is not available on instance of WebhookClient.
I can not find in their documentation, how to get the accessToken of the Logged In user: https://dialogflow.com/docs/fulfillment
I tried getting app.session, but that's just the unique session string Identifier of the user's session. It's not their access token.
How can I get the accessToken in V2?
It looks like the portion of the request object that contains this info isn't (yet) handled by the library. I've opened a bug on the issue, and you may wish to follow or comment on it.
In the meantime, you can access the user information by looking at the req.body
object. Specifically you can look at req.body.originalDetectIntentRequest.payload.user
to get the User object. The accessToken
field there is the one you're looking for.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With