Skip to content

Instantly share code, notes, and snippets.

@manekinekko
Last active July 26, 2018 00:44
Show Gist options
  • Select an option

  • Save manekinekko/da5fae12148c76a803936fb8a49e1f14 to your computer and use it in GitHub Desktop.

Select an option

Save manekinekko/da5fae12148c76a803936fb8a49e1f14 to your computer and use it in GitHub Desktop.
A sample implementation to request and check the user's sign in process.
'use strict';
const {dialogflow, SignIn} = require('actions-on-google');
const functions = require('firebase-functions');
const app = dialogflow({debug: true, clientId: '5da2282196bb4243ba3bfa7f70af0369'});
app.intent('Default Welcome Intent', (conv) => {
console.log('welcomeIntent');
conv.ask(new SignIn('To get your account details'));
});
// Create a Dialogflow intent with the `actions_intent_SIGN_IN` event
app.intent('Get Sign In', (conv, params, signin) => {
console.log('signIn');
if (signin.status === 'OK') {
console.log('userId', conv.user.raw.userId);
conv.ask(`I got your account details. your userId is ${conv.user.raw.userId}. What do you want to do next?`);
} else {
console.log('not signed in');
conv.ask(`I won't be able to save your data, but what do you want to do next?`);
}
});
exports.dialogflowFirebaseFulfillment = functions.https.onRequest(app);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment