Closed chituca closed 5 years ago
I'm sharing a sample code below.
'use strict';
const {dialogflow} = require('actions-on-google'); const functions = require('firebase-functions'); const {SignIn} = require('actions-on-google'); const app = dialogflow({debug: true});
app.intent('ask_for_sign_in', (conv) => { conv.ask(new SignIn()); });
app.intent('ask_for_sign_in_confirmation', (conv, params, signin) => { if (signin.status !== 'OK') { return conv.ask('You need to sign in before using the app.'); } // const access = conv.user.access.token; // possibly do something with access token conv.ask('Great! Thanks for signing in.'); });
exports.functionName = functions.https.onRequest(app);
It's ok! Thank's a lot
I got the sample, but I'm not able to get success signin. I recived a status error this is my code const {dialogflow, Suggestions, SignIn} = require('actions-on-google'); const aog = dialogflow({clientId: '5XXXXXX'});
aog.intent('login', conv => { conv.ask(new SignIn('test')); });
aog.intent('Get Signin', (conv, params, signin) => { console.log('status: '+signin.status+'\n'+signin.user+'\n'+signin); if(signin.status === 'OK'){ const payload = conv.user.profile.payload; conv.ask(
Ok, ${payload.name}. Thank's
); } else { conv.ask('Thank's.'); } });