question

gabbiano69 avatar image
gabbiano69 asked

add APL to skill

i have a an alexa skill that is online built with the repository "skill-sample-nodejs-audio-player/*multiple-streams*/"

and i tryed to added it the APL language.

i added APL support from alexa developper console (interface) i made a new file in lambda welcomeView.json with apl support (the file is ok),

and i added the render directive in lanchrequest in index.js but this not work.

can you see down.

But not work i see undefined in test

const alexa = require('ask-sdk');
 const constants = require('./constants');
 const welcomeView = require("./welcomeView.json"); 

 const card = { 
 title: 'Pillole di Coaching', 

text: 'di: Massimo Binelli.\n \n www.massimobinelli.it\n \n \
www.atletavincente.com\n \ninfo@massimobinelli.it',                 cardcontent: '
https://www.artigianiinfiera.it/wp-content/uploads/oroscopo/pillole-di-coaching/immagini/logo.png
', 

 image: { 

largeImageUrl: '
https://www.artigianiinfiera.it/wp-content/uploads/oroscopo/pillole-di-coaching/immagini/logo.png
', 

smallImageUrl: '
https://www.artigianiinfiera.it/wp-content/uploads/oroscopo/pillole-di-coaching/immagini/logo.png
' 

 
  } 
}; 

/* INTENT HANDLERS */

const LaunchRequestHandler = {
  canHandle(handlerInput) {
    return handlerInput.requestEnvelope.request.type === 'LaunchRequest';
  },
  async handle(handlerInput) {
    const playbackInfo = await getPlaybackInfo(handlerInput);
    let message;
    let reprompt;

    if (!playbackInfo.hasPreviousPlaybackSession) {
      message = 'Benvenuti in pillole di coaching a cura di Massimo Binelli. Puoi chiedere, inizia, per far partire lultimo episodio del podcast.';
      reprompt = 'Puoi dire:, inizia, per iniziare.';
    } else {
      playbackInfo.inPlaybackSession = false;
      message = `Stavi ascoltando ${constants.audioData[playbackInfo.playOrder[playbackInfo.index]].title}.Vorresti riprendere da dove avevi interrotto?`;
      reprompt = 'Puoi dire si per riprendere da dove avevi lasciato o no per ricominciare dallultimo episodio';
    }

    


    return handlerInput.responseBuilder
      .speak(message)
      .reprompt(reprompt)
      .withStandardCard(card.title, card.text, card.cardcontent, card.smallImageUrl, card.largeImageUrl)
      .addDirective({
                    type: 'Alexa.Presentation.APL.RenderDocument',
                    version: '1.0',
                    document: welcomeView.document,
                    datasources: welcomeView.dataSources
})

.getResponse();
  },
};


can anyone help me please

here there are the two file.

index.js

welcomeView.json

alexa skills kitalexaapl
10 |5000

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

Rokas avatar image
Rokas answered

You have a typo. Instead of welcomeView.dataSources, it should be welcomeView.datasources.

Basically, just make 'Sources' lowercase.

12 comments
10 |5000

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

thanks now i see it in developer console test but i submitted the skill and failed the certification because... this is the message:

Issue observed on devices without display (Echo, Echo Dot)


When attempting to invoke the skill using an example present in the example phrases or the skill’s description, the skill returns a non- contextualized response or error. All customer facing example phrases must function without error since these are interactions that users are most likely to try.


Issue: First Example phrase


Steps To Reproduce:


User: "Alexa, apri massimo binelli coach"

Skill: "Si è verificato un problema con la risposta della Skill richiesta"



can you help me this is the file



index.js


0 Likes 0 ·

Well, you shouldn't add APL directive if device doesn't support the screen, so my best guess that this is the problem. Fix is quite easy though.

Basically add this function:

function supportsDisplay(handlerInput) {
  return handlerInput.requestEnvelope.context &&
    handlerInput.requestEnvelope.context.System &&
    handlerInput.requestEnvelope.context.System.device &&
    handlerInput.requestEnvelope.context.System.device.supportedInterfaces &&
    (handlerInput.requestEnvelope.context.System.device.supportedInterfaces['Alexa.Presentation.APL'] ||
      handlerInput.requestEnvelope.context.System.device.supportedInterfaces.Display) &&
    handlerInput.requestEnvelope.context.Viewport
}

And before adding directive do the check and if it passes, only then add APL directive, otherwise, skip it.

if (supportsDisplay(handlerInput)) {
  handler.responseBuilder.addDirective({
                 type: 'Alexa.Presentation.APL.RenderDocument',
                 version: '1.0',
                 document: welcomeView.document,
                datasources: welcomeView.dataSources
  })
}
0 Likes 0 ·

some thing no work this certied fallback with this code

function supportsAPL(handlerInput) {
    const supportedInterfaces = handlerInput.requestEnvelope.context.System.device.supportedInterfaces;
    const aplInterface = supportedInterfaces['Alexa.Presentation.APL'];
    return aplInterface != null && aplInterface != undefined;
}


......

/* INTENT HANDLERS */
const LaunchRequestHandler = {
  canHandle(handlerInput) {
    return handlerInput.requestEnvelope.request.type === 'LaunchRequest';
  },
  async handle(handlerInput) {
    const playbackInfo = await getPlaybackInfo(handlerInput);
    let message;
    let reprompt;

    if (!playbackInfo.hasPreviousPlaybackSession) {
      message = 'Benvenuti in pillole di coaching a cura di Massimo Binelli. Puoi chiedere, inizia, per far partire lultimo episodio del podcast.';
      reprompt = 'Puoi dire:, inizia, per iniziare.';
    } else {
      playbackInfo.inPlaybackSession = false;
      message = `Stavi ascoltando ${constants.audioData[playbackInfo.playOrder[playbackInfo.index]].title}.Vorresti riprendere da dove avevi interrotto?`;
      reprompt = 'Puoi dire si per riprendere da dove avevi lasciato o no per ricominciare dallultimo episodio';
    }
 if (supportsAPL(handlerInput)) {
    return handlerInput.responseBuilder
      .speak(message)
      .reprompt(reprompt)
      .withStandardCard(card.title, card.text, card.cardcontent, card.smallImageUrl, card.largeImageUrl)
      .addDirective({
                    type: 'Alexa.Presentation.APL.RenderDocument',
                    version: '1.0',
                    document: welcomeView.document,
                    datasources: welcomeView.datasources
})
.getResponse();
} else {
            
return handlerInput.responseBuilder
      .speak(message)
      .reprompt(reprompt)
      .withStandardCard(card.title, card.text, card.cardcontent, card.smallImageUrl, card.largeImageUrl)
}
  },
};
0 Likes 0 ·
Show more comments
gabbiano69 avatar image
gabbiano69 answered

please help me, i rewrite the code and i make this new file that i share here:

index.js

please look this i think it's all ok, but my skill submission has failed the certification process.


Issue with skill in Italian (Italy)

_________________________________________________________________________________________________________


Issue observed on devices without display (Echo, Echo Dot)


When attempting to invoke the skill using an example present in the example phrases or the skill’s description, the skill returns a non- contextualized response or error. All customer facing example phrases must function without error since these are interactions that users are most likely to try.


Issue: First Example phrase


User: "Alexa, apri massimo binelli coach"
Skill: "Siamo spiacenti, questo non è un comando valido. Per favore, puoi dire, aiuto, per sapere cosa puoi chiedere ad Alexa"
 
                
Please note that in the description it is mentioned that if you want to listen the content "Pillole di coaching" you have to ask : “Alexa, apri Massimo Binelli Coach”. This is why the user should receive a reponse without any error and relevant to the user request.
10 |5000

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