question

gnuhc avatar image
gnuhc asked

Sequential Command Not Functioning Properly

The Sequential command only works for the first 2 to 3 commands inside the sequence. This was previously working roughly two weeks ago, but not anymore. Was hoping this would be fixed along with the Touch Wrapper issue (which has been fixed now) but the problem still exists on my end. Below is how I am structuring the directive. The first SetPage and the first SpeakItem commands are both working, but the response stops after that same SpeakItem command. Any updates would be much appreciated. Thanks!

handlerInput.responseBuilder.addDirective(       
{
    "type" : "Alexa.Presentation.APL.ExecuteCommands",
    "token": handlerInput.requestEnvelope.context.System.apiAccessToken,
    "commands": [
        {
            "type": "Sequential",
            "commands": [
            {
                "type": "SetPage",
                "componentId": "pager",
                "position": "absolute",
                "value": -2
            },
            {
                "type": "SpeakItem",
                "componentId":  "docText",							
            },
            {
                "type": "Idle",
                "delay": 1000
            },
            {
             	"type": "SpeakItem",
             	"componentId": "docFactText",							
            },
            {
             	"type": "Idle",
             	"delay": 1000
            },
            {
                "type": "SetPage",
                "componentId": "pager",
                "position": "absolute",
                "value": -1
            },
            {
                "type": "SpeakItem",
                "componentId": "docQuestionText",							
            },
            {
                "type": "SpeakItem",
                "componentId": "docOptionsText",							
            },
            {
                "type": "AutoPage",
                "componentId": "pager",
                "duration": 2000
            }
        ]
        }
    ]
})

alexa skills kitaplalexa presentation language
1 comment
10 |5000 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.

you set the wrong token in your ExecuteCommands directive.

this is how your response should look like

"directives": [{
  "type": "Alexa.Presentation.APL.RenderDocument",
  "version": "1.0",
  "document": {
    "type": "APL",
    "version": "1.0",
    "theme": "dark",
    "import": [],
    "resources": [],
    "styles": {},
    "layouts": {},
    "mainTemplate": {
      "parameters": [
        "payload"
      ],
      "item": {
        "type": "Text",
        "text": "Hi!"
      }
    }
  },
  "token": "MY_RENDERDOCUMENT_TOKEN"
}, {
  "type" : "Alexa.Presentation.APL.ExecuteCommands",
  "token": "MY_RENDERDOCUMENT_TOKEN",
  "commands": []
}]

the RenderDocument and ExecuteCommands token (mine is "MY_RENDERDOCUMENT_TOKEN") must be the same

0 Likes 0 ·
Arun@Amazon avatar image
Arun@Amazon answered

Hi @gnuhc

Could you provide the APL document and data source that goes with that command as well as the serial number of the device where you see the issue? This will help us debug the issue and validate whether an upcoming update fixes it. If you're not comfortable sharing your content on this forum feel free to direct message me on twitter (my handle below) and I'll give you an email address to mail the information. Another option is to use the contact us form here https://alexa.design/contactus.

Thanks
Arun
@aruntalkstech

10 |5000 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.

decompil3d avatar image
decompil3d answered

@Arun -- I'm seeing the same issue. You can find my APL document and data source here:

APL: https://github.com/decompil3d/alexa-count-to-ten/blob/master/models/apl.json
Data: https://github.com/decompil3d/alexa-count-to-ten/blob/master/models/data.en-US.json

There's a little processing that occurs in the lambda before the data is passed off to the Alexa service, as it adds in ssml and transformers for each language item. But that's not relevant to this issue. The problem is the same as @gnuhc mentions above: the first 2 commands in my sequential list are run, and then processing stops. I'm seeing this in the Alexa simulator in the dev portal.

For reference, here's my sequential list:

"commands": [
  {
      "type": "Sequential",
      "commands": [
          {
              "type": "SetPage",
              "componentId": "rootPager",
              "value": 4
          },
          {
              "type": "SetPage",
              "componentId": "ja-JPnumberPager",
              "value": 0
          },
          {
              "type": "SpeakItem",
              "componentId": "ja-JPnumber0"
          },
          {
              "type": "SetPage",
              "componentId": "ja-JPnumberPager",
              "value": 1
          },
          {
              "type": "SpeakItem",
              "componentId": "ja-JPnumber1"
          },
          {
              "type": "SetPage",
              "componentId": "ja-JPnumberPager",
              "value": 2
          },
          {
              "type": "SpeakItem",
              "componentId": "ja-JPnumber2"
          },
          {
              "type": "SetPage",
              "componentId": "ja-JPnumberPager",
              "value": 3
          },
          {
              "type": "SpeakItem",
              "componentId": "ja-JPnumber3"
          },
          {
              "type": "SetPage",
              "componentId": "ja-JPnumberPager",
              "value": 4
          },
          {
              "type": "SpeakItem",
              "componentId": "ja-JPnumber4"
          },
          {
              "type": "SetPage",
              "componentId": "ja-JPnumberPager",
              "value": 5
          },
          {
              "type": "SpeakItem",
              "componentId": "ja-JPnumber5"
          },
          {
              "type": "SetPage",
              "componentId": "ja-JPnumberPager",
              "value": 6
          },
          {
              "type": "SpeakItem",
              "componentId": "ja-JPnumber6"
          },
          {
              "type": "SetPage",
              "componentId": "ja-JPnumberPager",
              "value": 7
          },
          {
              "type": "SpeakItem",
              "componentId": "ja-JPnumber7"
          },
          {
              "type": "SetPage",
              "componentId": "ja-JPnumberPager",
              "value": 8
          },
          {
              "type": "SpeakItem",
              "componentId": "ja-JPnumber8"
          },
          {
              "type": "SetPage",
              "componentId": "ja-JPnumberPager",
              "value": 9
          },
          {
              "type": "SpeakItem",
              "componentId": "ja-JPnumber9"
          },
          {
              "type": "SetPage",
              "componentId": "rootPager",
              "value": 0
          }
      ]
  }
]
10 |5000 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.

Alexander Martin avatar image
Alexander Martin answered
the skill abruptly ends when the given componentId was not found or is not visible (i.e. within a pager/page that's not visible)
{
    "type": "SpeakItem",
    "componentId": "ja-JPnumber0"
}
ja-JPnumber0 should be ja-JPnumber1 since your APL template set the component id as follows:
"id": "${ietf}number${index + 1}"

index (starts with 0) + 1 = 1

or am I wrong? :)

2 comments
10 |5000 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.

That was one of the problems. And I'm closer now. But the sequential commands seem to always bail out as soon as a SpeakItem command is issued. It successfully speaks the item, but then stops execution. I've verified that when I just do the paging commands and not the speaking ones, it works correctly. So something is wrong with SpeakItem.

0 Likes 0 ·

gnah, just saw in your first comment you already do some pre processing before passing the data to alexa. could you share your complete payload?

----

opps, just checked your sources again. is this your complete payload? https://github.com/decompil3d/alexa-count-to-ten/blob/master/models/data.en-US.json did you specify the transformers property?

https://developer.amazon.com/de/docs/alexa-presentation-language/apl-data-source.html#transformers

this is how your payload should look:
{
  "fooBar": {
    "type": "object",
    "properties": {
      "numbers": [{
        "displayTextValue": 1,
        "ssml": "foo"
      }, {
        "displayTextValue": 2,
        "ssml": "bar"
      }]
    },
    "transformers": [{
      "inputPath": "numbers[*].ssml",
      "outputName": "speech",
      "transformer": "ssmlToSpeech"
    }]
  }
}

and within your component you should use:

{
  "type": "Text",
  "text": "${data.displayTextValue}",
  "speech" "${data.speech}"
}
0 Likes 0 ·
decompil3d avatar image
decompil3d answered

@Alexander Martin -- Yup, I think it's all correct. Here's some clearer payloads:

"document": {
  "styles": {},
  "type": "APL",
  "version": "1.0",
  "theme": "light",
  "import": [
      {
          "name": "alexa-layouts",
          "version": "1.0.0"
      },
      {
          "name": "alexa-styles",
          "version": "1.0.0"
      },
      {
          "name": "alexa-viewport-profiles",
          "version": "1.0.0"
      }
  ],
  "resources": [
      {
          "colors": {
              "accent": "#C00",
              "text": "#333"
          },
          "dimensions": {
              "spacing": "8dp",
              "bodySize": "26dp",
              "titleSize": "40dp",
              "numberSize": "200dp"
          }
      },
      {
          "when": "${@viewportProfile == @hubLandscapeLarge}",
          "dimensions": {
              "bodySize": "36dp",
              "headingSize": "40dp",
              "hintSize": "34dp",
              "titleSize": "50dp"
          }
      },
      {
          "when": "${@viewportProfile == @tvLandscapeXLarge}",
          "dimensions": {
              "bodySize": "23dp",
              "headingSize": "27dp",
              "hintSize": "23dp",
              "titleSize": "38dp"
          }
      },
      {
          "when": "${@viewportProfile == @hubRoundSmall}",
          "dimensions": {
              "bodySize": "18dp",
              "headingSize": "22dp",
              "hintSize": "18dp",
              "titleSize": "25dp"
          }
      }
  ],
  "layouts": {
      "LanguagePage": {
          "description": "Language page showing a pager that has numbers",
          "parameters": [
              {
                  "name": "language",
                  "type": "string"
              },
              {
                  "name": "ietf",
                  "type": "string"
              },
              {
                  "name": "numbers",
                  "type": "any"
              }
          ],
          "items": [
              {
                  "type": "Container",
                  "items": [
                      {
                          "type": "Frame",
                          "backgroundColor": "#FFFFFF66",
                          "height": "15vh",
                          "item": {
                              "type": "Container",
                              "justifyContent": "spaceBetween",
                              "alignItems": "center",
                              "direction": "row",
                              "height": "100%",
                              "paddingLeft": "5vw",
                              "paddingRight": "5vw",
                              "items": [
                                  {
                                      "type": "TouchWrapper",
                                      "item": {
                                          "type": "Text",
                                          "text": "←",
                                          "fontSize": "@titleSize"
                                      },
                                      "onPress": {
                                          "type": "SendEvent",
                                          "arguments": [
                                              "choosePage",
                                              0
                                          ]
                                      }
                                  },
                                  {
                                      "type": "Text",
                                      "color": "@text",
                                      "fontSize": "@titleSize",
                                      "textAlign": "${@viewportProfile != @hubRoundSmall ? 'auto' : 'center'}",
                                      "text": "${language}",
                                      "grow": 1
                                  }
                              ]
                          }
                      },
                      {
                          "type": "Container",
                          "grow": 1,
                          "item": {
                              "type": "Pager",
                              "id": "numberPager",
                              "grow": 1,
                              "width": "100vw",
                              "data": "${numbers}",
                              "item": {
                                  "type": "Container",
                                  "alignItems": "center",
                                  "paddingTop": "10vh",
                                  "items": [
                                      {
                                          "type": "Text",
                                          "fontSize": "@numberSize",
                                          "text": "${index + 1}",
                                          "speech": "${data.numberSpeech}",
                                          "id": "number${index + 1}"
                                      },
                                      {
                                          "type": "Text",
                                          "fontSize": "@titleSize",
                                          "text": "${data.word}"
                                      }
                                  ]
                              }
                          }
                      }
                  ]
              }
          ]
      }
  },
  "mainTemplate": {
      "parameters": [
          "payload"
      ],
      "items": [
          {
              "type": "Container",
              "items": [
                  {
                      "type": "Container",
                      "position": "absolute",
                      "top": 0,
                      "left": 0,
                      "width": "100vw",
                      "height": "100vh",
                      "items": [
                          {
                              "type": "Image",
                              "overlayColor": "#FFFFFFCC",
                              "scale": "best-fill",
                              "height": "100vh",
                              "width": "100vw",
                              "source": "https://decompil3d.github.io/alexa-count-to-ten/bg.jpg"
                          }
                      ]
                  },
                  {
                      "type": "Container",
                      "height": "100vh",
                      "items": [
                          {
                              "type": "Frame",
                              "when": "${@viewportProfile != @hubRoundSmall}",
                              "backgroundColor": "@accent",
                              "height": "2vh",
                              "width": "100vw"
                          },
                          {
                              "type": "LanguagePage",
                              "numbers": "${payload.selectedNumbers.properties.numbers}",
                              "ietf": "${payload.selectedNumbers.properties.ietf}",
                              "language": "${payload.selectedNumbers.properties.name}",
                              "width": "100vw",
                              "grow": 1
                          }
                      ]
                  }
              ]
          }
      ]
  }
},
"datasources": {
  "selectedNumbers": {
      "transformers": [
          {
              "inputPath": "numbers[*].numberSsml",
              "outputName": "numberSpeech",
              "transformer": "ssmlToSpeech"
          }
      ],
      "type": "object",
      "properties": {
          "numbers": [
              {
                  "numberSsml": "<speak><lang xml:lang=\"ja-JP\"><say-as interpret-as=\"cardinal\">1</say-as></lang></speak>",
                  "word": "一 (ichi)"
              },
              {
                  "numberSsml": "<speak><lang xml:lang=\"ja-JP\"><say-as interpret-as=\"cardinal\">2</say-as></lang></speak>",
                  "word": "二 (ni)"
              },
              {
                  "numberSsml": "<speak><lang xml:lang=\"ja-JP\"><say-as interpret-as=\"cardinal\">3</say-as></lang></speak>",
                  "word": "三 (san)"
              },
              {
                  "numberSsml": "<speak><lang xml:lang=\"ja-JP\"><say-as interpret-as=\"cardinal\">4</say-as></lang></speak>",
                  "word": "四 (yon)"
              },
              {
                  "numberSsml": "<speak><lang xml:lang=\"ja-JP\"><say-as interpret-as=\"cardinal\">5</say-as></lang></speak>",
                  "word": "五 (go)"
              },
              {
                  "numberSsml": "<speak><lang xml:lang=\"ja-JP\"><say-as interpret-as=\"cardinal\">6</say-as></lang></speak>",
                  "word": "六 (roku)"
              },
              {
                  "numberSsml": "<speak><lang xml:lang=\"ja-JP\"><say-as interpret-as=\"cardinal\">7</say-as></lang></speak>",
                  "word": "七 (nana)"
              },
              {
                  "numberSsml": "<speak><lang xml:lang=\"ja-JP\"><say-as interpret-as=\"cardinal\">8</say-as></lang></speak>",
                  "word": "八 (hachi)"
              },
              {
                  "numberSsml": "<speak><lang xml:lang=\"ja-JP\"><say-as interpret-as=\"cardinal\">9</say-as></lang></speak>",
                  "word": "九 (ku)"
              },
              {
                  "numberSsml": "<speak><lang xml:lang=\"ja-JP\"><say-as interpret-as=\"cardinal\">10</say-as></lang></speak>",
                  "word": "十 (jū)"
              }
          ],
          "name": "Japanese",
          "ietf": "ja-JP"
      }
  }
}

And the commands being executed:

"commands": [
    {
        "type": "Sequential",
        "commands": [
            {
                "type": "SetPage",
                "componentId": "numberPager",
                "value": 0
            },
            {
                "type": "SpeakItem",
                "componentId": "number1"
            },
            {
                "type": "SetPage",
                "componentId": "numberPager",
                "value": 1
            },
            {
                "type": "SpeakItem",
                "componentId": "number2"
            },
            {
                "type": "SetPage",
                "componentId": "numberPager",
                "value": 2
            },
            {
                "type": "SpeakItem",
                "componentId": "number3"
            },
            {
                "type": "SetPage",
                "componentId": "numberPager",
                "value": 3
            },
            {
                "type": "SpeakItem",
                "componentId": "number4"
            },
            {
                "type": "SetPage",
                "componentId": "numberPager",
                "value": 4
            },
            {
                "type": "SpeakItem",
                "componentId": "number5"
            },
            {
                "type": "SetPage",
                "componentId": "numberPager",
                "value": 5
            },
            {
                "type": "SpeakItem",
                "componentId": "number6"
            },
            {
                "type": "SetPage",
                "componentId": "numberPager",
                "value": 6
            },
            {
                "type": "SpeakItem",
                "componentId": "number7"
            },
            {
                "type": "SetPage",
                "componentId": "numberPager",
                "value": 7
            },
            {
                "type": "SpeakItem",
                "componentId": "number8"
            },
            {
                "type": "SetPage",
                "componentId": "numberPager",
                "value": 8
            },
            {
                "type": "SpeakItem",
                "componentId": "number9"
            },
            {
                "type": "SetPage",
                "componentId": "numberPager",
                "value": 9
            },
            {
                "type": "SpeakItem",
                "componentId": "number10"
            },
            {
                "type": "Idle",
                "delay": 1500
            }
        ]
    }
  ]

It's been fairly consistent that as soon as a SpeakItem command is issued, it speaks and then bails out. No additional commands are executed and the skill appears to no longer accept intent input (I have to ask Alexa to open it again).

5 comments
10 |5000 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.

(Note: I had to post this as an answer as the code blocks exceeded the max length for comments)

0 Likes 0 ·

can you add "position": "absolute" to your SetPage commands? i.e.

{
  "type": "SetPage",
  "componentId": "numberPage",
  "position": "absolute",
  "value": 1
}
0 Likes 0 ·

No change -- docs say that `position` defaults to `absolute` anyway.

0 Likes 0 ·
Show more comments
Alexander Martin avatar image
Alexander Martin answered

:(

one more last thing I want to test, can you replace your current LanguagePage layout with mine?

I added a new container outside of the current pager.
    {
      "type": "Container",
      "position": "absolute",
      "left": "100%",
      "width": "0%",
      "height": "0%",
      "top": "100%",
      "item": {
        "type": "Text",
        "text": ".",
        "id": "number${data.number}",
        "speech": "${data.numberSpeech}"
      },
      "data": "${numbers}"
    }
and removed the speech property from the Text items within the pager
"LanguagePage": {
  "description": "Language page showing a pager that has numbers",
  "parameters": [
    {
      "name": "language",
      "type": "string"
    },
    {
      "name": "ietf",
      "type": "string"
    },
    {
      "name": "numbers",
      "type": "any"
    }
  ],
  "items": [
    {
      "type": "Container",
      "position": "absolute",
      "left": "100%",
      "width": "0%",
      "height": "0%",
      "top": "100%",
      "item": {
        "type": "Text",
        "text": ".",
        "id": "number${data.number}",
        "speech": "${data.numberSpeech}"
      },
      "data": "${numbers}"
    },
    {
      "type": "Container",
      "items": [
        {
          "type": "Frame",
          "backgroundColor": "#FFFFFF66",
          "height": "15vh",
          "item": {
            "type": "Container",
            "justifyContent": "spaceBetween",
            "alignItems": "center",
            "direction": "row",
            "height": "100%",
            "paddingLeft": "5vw",
            "paddingRight": "5vw",
            "items": [
              {
                "type": "TouchWrapper",
                "item": {
                  "type": "Text",
                  "text": "←",
                  "fontSize": "@titleSize"
                },
                "onPress": {
                  "type": "SendEvent",
                  "arguments": [
                    "choosePage",
                    0
                  ]
                }
              },
              {
                "type": "Text",
                "color": "@text",
                "fontSize": "@titleSize",
                "textAlign": "${@viewportProfile != @hubRoundSmall ? 'auto' : 'center'}",
                "text": "${language}",
                "grow": 1
              }
            ]
          }
        },
        {
          "type": "Container",
          "grow": 1,
          "item": {
            "type": "Pager",
            "id": "numberPager",
            "grow": 1,
            "width": "100vw",
            "data": "${numbers}",
            "item": {
              "type": "Container",
              "alignItems": "center",
              "paddingTop": "10vh",
              "items": [
                {
                  "type": "Text",
                  "fontSize": "@numberSize",
                  "text": "${data.number}"
                },
                {
                  "type": "Text",
                  "fontSize": "@titleSize",
                  "text": "${data.word}"
                }
              ]
            }
          }
        }
      ]
    }
  ]
}
(sorry, my current comment exceeds character limit)
2 comments
10 |5000 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.

Same problem -- reads the first number and then stops. So it looks like the paging part is not related. It's just SpeakItem that's causing it to bail out.

0 Likes 0 ·

I think we did our best, time to raise a bug report :)

0 Likes 0 ·
sungyoo avatar image
sungyoo answered

Hey everyone, thank you for chiming in! I will bring this to our internal team and raise it as a bug!

10 |5000 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.

Arun@Amazon avatar image
Arun@Amazon answered

Hi

I have raised 2 bugs based on @gnuhc and @decompil3d's skill responses. This skill response manifests differently (and incorrectly) both on the simulator and on devices with the latest builds:

1. On the simulator, the first page is shown, the item is spoken and the command sequence stops. This is what you all are seeing and our team is investigating the root cause.

2. On an Echo Show device, the first page is shown, the first item is spoken and then any SpeakItem commands are ignored and the device pages through the contents of the Pager. In other words, it runs the SetPage commands.

I'll update this thread once these issues have been resolved and the fixes are available in a subsequent release. Thanks for reporting!

Arun

@aruntalkstech

4 comments
10 |5000 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 Arun -- any update on these tickets? I'm still seeing the bad behavior in the simulator. And I don't have a device to test with. Hoping to get this skill submitted for the APL competition, so I need this resolved ahead of the 1/22 deadline. Thanks!

0 Likes 0 ·

@Arun -- any update?

0 Likes 0 ·

Hi

Sorry it's taken so long. Here's the fixed version of the response that renders the sequence of Pager items and pronounces each number: https://pastebin.com/M7wBCY55. The problem was that the Text component rendering the number/speech was using an identifier based on its index. Because the Text component was the first component in a Container its index would always be 0. This meant that all the Text components had the id "number1". I based the name on a datasource value so it was more predictable.


Arun

@aruntalkstech

0 Likes 0 ·
Show more comments
Arun@Amazon avatar image
Arun@Amazon answered

Hi @Alexander Martin / @decompil3d

Sorry it's taken so long. Here's the fixed version of the response that renders the sequence of Pager items and pronounces each number: https://pastebin.com/M7wBCY55. The problem was that the Text component rendering the number/speech was using an identifier based on its index. Because the Text component was the first component in a Container its index would always be 0. This meant that all the Text components had the id "number1". I based the name on a datasource value so it was more predictable.

Our documentation for {index} here https://developer.amazon.com/docs/alexa-presentation-language/apl-data-binding-evaluation.html#component-child-extension says that it is only applicable to Sequence. This might have been part of the confusion and I apologize for that. This isn't correct and we're working on fixing it. {index} applies to Sequence, Container and Pager.

Arun
@aruntalkstech

10 |5000 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.