Vielen Dank für deinen Besuch. Diese Seite ist nur in Englisch verfügbar.

APL RenderDocument Skill Directive

When a skill receives a request from the Alexa service, it can respond with the Alexa.Presentation.APL.RenderDocument directive. The RenderDocument directive contains an APL document along with any associated data sources needed to render that document on the screen of an Alexa-enabled device. The RenderDocument skill directive supports the following properties.

The RenderDocument directive cannot be used in conjunction with a directive from any of the AudioPlayer, VideoApp, Dialog, or Display interfaces.

RenderDocument properties

Here are the properties of the RenderDocument directive.

Property Type Required Description
type Directive Yes Set to "Alexa.Presentation.APL.RenderDocument".
token String Yes String that you can use to issue subsequent directives that reference the document being rendered. For example, the ExecuteCommands directive.
document APL Document Yes Object that contains the APL document being sent to the Alexa device.
datasources Map of data source objects No Object that can contain other objects that you can use to bind data to the APL document.

The minimal sample skill response shown below contains a RenderDocument directive. The mainTemplate object inside the APL document inflates into a hierarchy of primitive APL components that contain text, graphical images, simple graphical primitives, scrolling regions, and several types of layout components that position child components. Data-binding expressions set the properties of the primitive APL components. The data-binding expressions combine the data referenced by the APL document with the structure of the component hierarchy.

In this example, the Text and Image component, each of which are inside a Container component, are bound to properties inside the templateData data source using APL binding expressions.

{
    "version": "1.0",
    "response": {
        "outputSpeech": {
            "type": "SSML",
            "ssml": "<speak>This is a minimal APL document</speak>"
        },
        "directives": [{
            "type": "Alexa.Presentation.APL.RenderDocument",
            "token": "anydocument",
            "document": {
                "type": "APL",
                "version": "1.0",
                "theme": "dark",
                "mainTemplate": {
                    "description": "********* Minimal APL document **********",
                    "parameters": [
                        "payload"
                    ],
                    "items": [{
                        "type": "Container",
                        "width": "100%",
                        "height": "100%",
                        "alignItems": "center",
                        "justifyContent": "center",
                        "items": [{
                                "type": "Image",
                                "source": "${payload.templateData.backgroundImage}",
                                "position": "absolute",
                                "width": "100vw",
                                "height": "100vh",
                                "scale": "best-fill"
                            },
                            {
                                "type": "Text",
                                "color": "#FFFFFF",
                                "text": "${payload.templateData.title}"
                            }
                        ]
                    }]
                }
            },
            "datasources": {
                "templateData": {
                    "title": "Minimal APL document",
                    "backgroundImage": "https://www.example.com/images/BT1_Background.png"
                }
            }
        }]
    },
    "sessionAttributes": {},
    "userAgent": "ask-node/2.0.7 Node/v6.10.3"
}