Injecting Model Data

Often it is useful to pass data from the fulfillment to a template to be rendered. This keeps the display from being static and helps provide useful visual information to the user. A skill that deals with weather forecasts, for example, could display a five-day forecast while Alexa speaks the current weather conditions. It would be less useful if the display only showed a fixed logo or text while Alexa speaks the weather.

You can pass data to an APL template using the datasources property of the Alexa.Presentation.APL.RenderDocument directive. For the “enjoy your trip” screen, we could pass along the trip details as well as some text from the intent handler to the APL template like this:

Get Build Talking Apps for Alexa now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.