question

GuillaumePelouas avatar image
GuillaumePelouas asked ·

APL: Update document without submiting a new one ?

I have a skill that will display quite always the same APL document, having on texts updated.

These texts are part of the APL data part.

My current solution is to send a render directive with a new document after each intent, but that's heavy, and provoke a blinking effect during the time of the reloading.


Is there a way, instead of sending a full rendering directive, to send only an update of APL data, and eventually to run animations.

I was thinking about something like a way to include in the intent response a command or a sequence of commands to apply on the APL document.

alexa skills kitapldisplay templates
10 |2000 characters needed characters left characters exceeded

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Gaetano@Amazon avatar image
Gaetano@Amazon answered ·

Hi,

thanks for your post.

A strict datasources{} update will always require a RenderDocument directive.

However, you can update the values of your components by sending a sequence of SetValue commands from the backend, to change the value of your components that have been already rendered.

You will then send different SetValue commands, into a Parallel command. Here is an example:

return handlerInput.responseBuilder
.addDirective({
    type : 'Alexa.Presentation.APL.ExecuteCommands',
    token: "documentToken",
    commands: [
        {
            "type": "Parallel",
            "delay": 500,
            "commands": [
                {
                    "type": "SetValue",
                    "componentId": "myComponent",
                    "property": "text",
                    "value": "Value 1"
                },
                {
                    "type": "SetValue",
                    "componentId": "myOtherComponent",
                    "property": "text",
                    "value": "Value 2"
                }
            ]
          }
          ],
})  
  .getResponse();

Make sure you set the same token on the initial RenderDocument directive, "documentToken" in this case.

Kind regards,
Gaetano

4 comments
10 |2000 characters needed characters left characters exceeded

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

@Gaetano@Amazon is it possible to trigger animations like this?

0 Likes 0 ·
Gaetano@Amazon avatar image Gaetano@Amazon ♦ newuser-299332f3-7805-42f4-8cfa-ffb331d490d4 ·

AnimateItem is actually a command, so you can send it from the backend.

Just make sure that the component you want to animate has an ID set.

Regards,
Gaetano

0 Likes 0 ·

so am i doing something like:

commands: [{"type": "AnimateItem", "componentId":"myComponent", "command": "myAnimations"}]

Where myAnimations is defined within the APL doc under commands?

0 Likes 0 ·
Show more comments
GuillaumePelouas avatar image
GuillaumePelouas answered ·

Thanks for your answer, but does that means this SetValue command can be used to update datasources ? Il no, then there is no possibility to update a list content with this method I think...

3 comments
10 |2000 characters needed characters left characters exceeded

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Hi,

I can confirm. A SetValue command from backend is only able to update the values for already rendered components.

Datasources are immutable unless you send another RenderDocument directive.

Kind regards,
Gaetano

0 Likes 0 ·

Then how can we create a smooth transition when updating a list content ?

0 Likes 0 ·

Hi,

it depends on how the document is made. For example you have all the child components under one Container, (let's say with "mainContainer" as ID), then you could do the following in a Parallel command:

1) Send an AnimateItem command against "mainContainer" that can move the whole container out of the screen or smoothly the components opacity to 0 (when applicable.

2) Send all the SetValue commands to change the values you need to change

1) Send another AnimateItem command against "mainContainer" that will revert the animation made on the point 1.

Hope it helps!

Regards,
Gaetano

0 Likes 0 ·