Returning APL while eliciting slot

amazon-alexa

#1

I’m using the below but the APL response is not returning. Does anyone know how to make this work or is there any documentation on how to do this? Thank you for looking.

if(this.isAlexaSkill() && this.$alexaSkill.hasAPLInterface())
{
this.$alexaSkill.addDirective({
type: ‘Alexa.Presentation.APL.RenderDocument’,
version: ‘1.0’,
document: require(./apl/choice.json),
datasources: {},
});
}
this.$alexaSkill.$dialog.elicitSlot(
‘flightType’,
‘Do you want the first, second or third?’,
‘I’m sorry, I didn’t get that. Do you want the first, second or third?’
);


#2

Hi @Zachary_Hoover, welcome to the Jovo Community :tada:

Could you share the response JSON here? It should be logged in your command line tool.


#3

Please see below, it is not returning any APL information.

{

  • “version”: “1.0”,

“response”: {

  • “shouldEndSession”: false,

“outputSpeech”: {
* “type”: “SSML”,
* “ssml”: “<speak>Do you want the first, second or third?</speak>”},

“reprompt”: {
* -

“outputSpeech”: {
* “type”: “SSML”,
* “ssml”: “<speak>Do you want the first, second or third?</speak>”}},

“directives”: [
* -

{
* “type”: “Dialog.ElicitSlot”,
* “slotToElicit”: “flightType”}]},

“sessionAttributes”: {

  • JOVO_STATE”: “SearchFlightState”}

}


#4

Thanks, that’s helpful.

Can you log this.$output after this.$alexaSkill.$dialog.elicitSlot share its content here please?


#5

It wasn’t letting me paste my log data here. Link to logdata below:


#6

Interesting. So it does list both the APL and Dialog directives in the output.

Is it possible this is a bug @AlexSwe?


#7

Might also be intentional as Amazon might not allow APL with Dialog Directives? https://forums.developer.amazon.com/questions/195803/apl-with-slot-filling-dialog-management.html (old post though)


#8

I have not used this together yet.

The directives-array doesn’t have the APL directive? This could be a bug.

Could you try it with a raw response object with both directives?

Add this json to this.$rawResponseJson

{
   "version": "1.0",
   "response": {
      "shouldEndSession": false,
      "outputSpeech": {
         "type": "SSML",
         "ssml": "<speak>test</speak>"
      },
      "reprompt": {
         "outputSpeech": {
            "type": "SSML",
            "ssml": "<speak>test</speak>"
         }
      },
     directives: [
       {
            "type": "Dialog.ElicitSlot",
            "slotToElicit": "flightType"
        },
        {
                "type": "Alexa.Presentation.APL.RenderDocument",
                "version": "1.0",
                "document": {
                    "type": "APL",
                    "version": "1.4",
                    "settings": {},
                    "theme": "dark",
                    "import": [
                        {
                            "name": "alexa-viewport-profiles",
                            "version": "1.1.0"
                        },
                        {
                            "name": "alexa-styles",
                            "version": "1.1.0"
                        },
                        {
                            "name": "alexa-layouts",
                            "version": "1.1.0"
                        }
                    ],
                    "resources": [],
                    "styles": {},
                    "onMount": [],
                    "graphics": {},
                    "commands": {},
                    "layouts": {},
                    "mainTemplate": {
                        "parameters": [
                            "payload"
                        ],
                        "items": [
                            {
                                "type": "Container",
                                "height": "100vh",
                                "width": "100vw",
                                "items": [
                                    {
                                        "type": "AlexaBackground",
                                        "backgroundColor": "#FFACF8"
                                    },
                                    {
                                        "type": "Image",
                                        "width": "100vw",
                                        "height": "100vh",
                                        "source": "https://alexa-files-20120.s3.us-east-2.amazonaws.com/apl/images/large/jet-bokeh-red.jpg",
                                        "scale": "best-fill",
                                        "align": "left",
                                        "position": "absolute"
                                    },
                                    {
                                        "when": "${@viewportShape == @viewportShapeRectangle}",
                                        "type": "Text",
                                        "width": "100vw",
                                        "height": "auto",
                                        "paddingTop": "15vh",
                                        "text": "Most economical, nonstop, <br>or first-class flight?",
                                        "fontSize": "50dp",
                                        "textAlign": "center",
                                        "textAlignVertical": "top",
                                        "fontWeight": "100",
                                        "color": "white"
                                    },
                                    {
                                        "when": "${@viewportShape == @viewportShapeRound}",
                                        "type": "Text",
                                        "width": "100vw",
                                        "height": "auto",
                                        "paddingTop": "20vh",
                                        "text": "Most economical, <br>nonstop, or first-class flight?",
                                        "fontSize": "40dp",
                                        "textAlign": "center",
                                        "textAlignVertical": "top",
                                        "fontWeight": "100",
                                        "color": "white"
                                    },
                                    {
                                        "when": "${@viewportShape == @viewportShapeRectangle}",
                                        "type": "Text",
                                        "width": "100vw",
                                        "height": "auto",
                                        "paddingTop": "10vh",
                                        "paddingBottom": "7vh",
                                        "position": "absolute",
                                        "text": "Try \"Alexa, book a flight from Boston to JFK\"",
                                        "fontSize": "35dp",
                                        "fontFamily": "Bookerly",
                                        "fontStyle": "italic",
                                        "textAlign": "center",
                                        "textAlignVertical": "bottom",
                                        "color": "white",
                                        "bottom": "7vh"
                                    },
                                    {
                                        "type": "Image",
                                        "width": "100vw",
                                        "height": "32vh",
                                        "paddingLeft": "20vw",
                                        "paddingRight": "20vw",
                                        "paddingTop": "10vh",
                                        "source": "https://alexa-files-20120.s3.us-east-2.amazonaws.com/apl/images/iconswhite.png"
                                    }
                                ]
                            }
                        ]
                    }
                },
                "datasources": {}
            }
    ]
   },
   "sessionAttributes": {
   }
}

#9
Alex,

I’m not entirely sure if I did this correctly but did get an APL response as well as the “test” spoken. It did not ask my question though.