Sai
Sai

Reputation: 2109

Actions SDK conv.hasScreen not working as expected

I am building an action using DialogFlow and Firebase cloud functions. I have a simple check to either ask a question or close the conversation depending on user's device type.

 if (conv.hasScreen) {
      response += `Do you want to see a picture?`;
      conv.ask(response);
      return;
  }
  else{
    conv.close(response);
    return;
  }

I tested using Google Home mini, as expected, the conversation gracefully closed. But when I tested on a phone, the if check failed and the conversation was closed again. I was expecting the contestation to continue and assistant would ask me to show a picture but it did not happen. What am I doing wrong?

Upvotes: 0

Views: 151

Answers (2)

Nick Felker
Nick Felker

Reputation: 11968

It looks like the syntax is simply conv.screen. As the property hasScreen does not exist, the conditional always returns undefined, which is a falsey value.

Upvotes: 3

Abhinav Tyagi
Abhinav Tyagi

Reputation: 5266

Take a look at the following to understand Surface Capabilities.

Are you using the following statement or not?

const hasScreen =
    conv.surface.capabilities.has('actions.capability.SCREEN_OUTPUT');

Upvotes: 1

Related Questions