actions-on-googleactions-builder

How to check whether the user is a new user or not in @assistant/conversation package


In the actions-on-google package I have used the following logic to check whether the user is a new user or not.

conv.user.last.seen

But in the new @assistant/conversation package i have used the same logic but it fails stating that the seen is not found. I tried the following logic which shows the current date and time which makes the logic to pass all time.

conv.user.lastSeenTime

Does anyone tried to show whether the user is a new or not in the new @assistant/conversation package?


Solution

  • I ‘m dealing with a similar issue of how to differentiate between new vs returning users with google console’s action builder. The Main invocation is the part of the conversation I'm using this in. (Brand new to the forum so forgive me if I didn’t grasp your question.) I used the same logic as you did, and it did deploy correctly for me using the cloud function's inline editor for the webhook. So I ‘m not entirely sure what’s going on but here are some resources. The following tutorial and code was helpful/ worked for me (https://youtu.be/nVbwk4UKHWw?t=700 )

    const { conversation } = require('@assistant/conversation');
    const functions = require('firebase-functions');
    const app = conversation({debug:true});
    app.handle('greeting', conv => {
      let message = 'Welcome to App';
      if (conv.user.lastSeenTime) {
        message = 'Welcome back to App!';
      }
      conv.add(message);
    });
    exports.ActionsOnGoogleFulfillment = functions.https.onRequest(app);