actions-on-google / dialogflow-helper-intents-nodejs

Helper Intents sample (using Dialogflow) in Node.js
Apache License 2.0
13 stars 8 forks source link

Error Sign In #5

Closed chituca closed 5 years ago

chituca commented 6 years ago

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.'); } });

zehrasubas commented 6 years ago
  1. Client id shouldn't be defined here. It should be defined on AoG console->Account Linking page
  2. you don't need to pass any parameters to new SignIn() function.

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);

chituca commented 6 years ago

It's ok! Thank's a lot