1

Following the design tips on action-on-google developer platform, I'm trying to give a custom welcome response for users who come back in a Google Assistant Voice app. https://developers.google.com/actions/design/tips

To proceed, i started by switch My Default Welcome intent in Dialogflow in the Fullfilment mode. Then deploy my code on firebase. It's work well when i ask for a name permission, but when I try to input the 'AppRequest.User lastSeen', my app shut down? Maybe you know what i missed in my code?

'use strict';

const {
  dialogflow,
  Permission,
} = require('actions-on-google');

const functions = require('firebase-functions');

const app = dialogflow({debug: true});

app.intent('Default Welcome Intent', (conv) => {
  const welcome = (conv) => {
  if (conv.user.last.seen) {
    conv.ask(`Hey you're back...`);
  } else {
    conv.ask('Welcome to World Cities Trivia!...');
  }
}});

// Set the DialogflowApp object to handle the HTTPS POST request.
exports.dialogflowFirebaseFulfillment = functions.https.onRequest(app);
Sairaj Sawant
  • 1,845
  • 1
  • 9
  • 16
Kloaier
  • 13
  • 3

2 Answers2

2

It looks like the code in your welcome Intent Handler doesn't actually do anything.

You setup the handler

app.intent('Default Welcome Intent', (conv) => {
  ...
});

but inside your handler you create another function

  const welcome = (conv) => {
    if (conv.user.last.seen) {
      conv.ask(`Hey you're back...`);
    } else {
      conv.ask('Welcome to World Cities Trivia!...');
    }
  }

that never gets called. It isn't clear why you have this inner function, since it isn't necessary. You just need the body of that function in the outer one. So it can look something like this, perhaps:

app.intent('Default Welcome Intent', (conv) => {
  if (conv.user.last.seen) {
    conv.ask(`Hey you're back...`);
  } else {
    conv.ask('Welcome to World Cities Trivia!...');
  }
});
Prisoner
  • 48,391
  • 6
  • 48
  • 97
1

You should read it from the conv object, it represents a turn in the conversation and exposes the attributes of the individual requests: conv.user.last.

gmolau
  • 2,188
  • 14
  • 34