Views and Variables

Views

Views are the Voxa way of handling replies to the user, they’re templates of responses that can have a context as defined by your variables and Model

There are 5 responses in the following snippet: LaunchIntent.OpenResponse, ExitIntent.Farewell, HelpIntent.HelpAboutSkill, Count.Say and Count.tell

const views = {
  LaunchIntent: {
    OpenResponse: { tell: 'Hello! Good {time}' },
  },
  ExitIntent: {
    Farewell: { tell: 'Ok. For more info visit {site} site.' },
  },
  HelpIntent: {
    HelpAboutSkill: { tell: 'For more help visit www.rain.agency' },
  },
  Count: {
    Say: { say: '{count}' },
    Tell: { tell: '{count}' },
  },
};

Variables

Variables are the rendering engine way of adding logic into your views. They’re dessigned to be very simple since most of your logic should be in your model or controllers.

A variable signature is:

variable(model, alexaEvent)
Arguments:
  • model – The instance of your model for the current alexa event.
  • AlexaEvent – The current alexa event.
Returns:

The value to be rendered or a promise resolving to a value to be rendered in the view.

const variables = {
  site: function site(model) {
    return Promise.resolve('example.com');
  },

  count: function count(model) {
    return model.count;
  },

  locale: function locale(model, alexaEvent) {
    return alexaEvent.locale;
  }
};