question

Mohamed Sayed avatar image
Mohamed Sayed asked

sendEvent is not working after speakItem

In my python skill, I'm displaying APL document that uses onMount to run a speech followed by a sendEvent to the back-end skill

the problem is that the sendEvent is never fired.
If I removed the url from the speech and the speech ignored, I see the sendEvent is fired.
here is my complete APL


{
    "type": "APL",
    "version": "2022.1",
    "license": "Copyright 2021 Amazon.com, Inc. or its affiliates. All Rights Reserved.\nSPDX-License-Identifier: LicenseRef-.amazon.com.-AmznSL-1.0\nLicensed under the Amazon Software License  http://aws.amazon.com/asl/",
    "settings": {},
    "theme": "dark",
    "import": [
        {
            "name": "alexa-layouts",
            "version": "1.6.0"
        }
    ],
    "resources": [],
    "styles": {},
    "onMount": [
        {
            "type": "Sequential",
            "commands": [
                {
                    "type": "SpeakItem",
                    "componentId": "title"
                },
                {
                    "type": "SendEvent",
                    "arguments": [
                        "playbackFinished"
                    ]
                }
            ]
        }
    ],
    "graphics": {},
    "commands": {},
    "layouts": {},
    "mainTemplate": {
        "parameters": [
            "payload"
        ],
        "items": [
            {
                "alignItems": "center",
                "direction": "column",
                "justifyContent": "center",
                "type": "Container",
                "disabled": true,
                "width": "100%",
                "height": "100%",
                "items": [
                    {
                        "type": "AlexaBackground",
                        "backgroundImageSource": "${payload.data.backgroundImage}",
                        "colorOverlay": true
                    },
                    {
                        "id": "title",
                        "type": "Text",
                        "text": "${payload.data.mainText}",
                        "fontFamily": "georgia",
                        "fontSize": "80dp",
                        "textAlign": "center",
                        "textAlignVertical": "center",
                        "color": "yellow",
                        "speech": "${payload.data.verseAudio}"
                    },
                    {
                        "id": "subTitle",
                        "fontSize": "30dp",
                        "text": "${payload.data.subText}",
                        "type": "Text",
                        "textAlign": "center",
                        "textAlignVertical": "center",
                        "width": "400dp",
                        "height": "32dp",
                        "paddingTop": "12dp",
                        "paddingBottom": "12dp"
                    }
                ]
            }
        ]
    }
}


apl
10 |5000

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

1 Answer

Andy Whitworth avatar image
Andy Whitworth answered
Try moving the SendEvent to a "finally" command block so it gets executed even if there is an error.


{
            "type": "Sequential",
            "commands": [
                {
                    "type": "SpeakItem",
                    "componentId": "title"
                }
            ],
            "finally": {
                    "type": "SendEvent",
                    "arguments": [
                        "playbackFinished"
                    ]
             }
}


10 |5000

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