Sure @AlexSwe
Here’s a condensed version of my code where I get the key press:
ON_ELEMENT_SELECTED() {
const requestType = this.$request.request.type;
const requestArg = this.$request.request.arguments[0];
if (requestType === 'Alexa.Presentation.APL.UserEvent') {
if (requestArg === 'ListItemSelected') {
// Get the category
const categoryIdx = this.$request.request.arguments[1] - 1; // turn it to '0'-based
const category = Spreadsheet.getCategories()[categoryIdx];
this.$session.$data.chosenCategory = category;
console.log(`GOT CATEGORY LIST TOUCH EVENT! Category: ${category}`);
return this.toStateIntent('GetCategoryState', 'ChooseCategoryIntent');
}
}
}
…and here’s a snippet of the code where I try to use the Progressive Response:
GetCategoryState: {
async ChooseCategoryIntent() {
var route = this.getRoute();
var keyPressEntry = typeof route.from != 'undefined'
&& route.from.includes('ON_ELEMENT_SELECTED');
// Get the input from the user
var userCategory;
if (keyPressEntry) {
userCategory = this.$session.$data.chosenCategory;
} else {
userCategory = this.$inputs.category.value;
console.log(`CHOOSE CATEGORY: value->${userCategory}, key->${this.$inputs.category.key}`);
}
// Check if the user said "random"
if (userCategory.toLowerCase() === 'random') {
if (this.isAlexaSkill() && !keyPressEntry) {
// Let user know this could take a little bit
await this.$alexaSkill.progressiveResponse
(`Please wait while I generate a random mix of words.`);
}
await Spreadsheet.loadRandomMix();
}
.
.
.
I get the error when the progressive response line is executed and I don’t have the check for keyPressEntry - (I have the check for keyPressEntry in the code right now so I can continue testing). Fortunately, it’s not a huge deal, since the response is not necessary for the skill to work properly. I just like to use them when I have to call an API that’s going to take a few seconds.
Finally, here’s the relevant portion of the APL JSON:
{
"type": "AlexaTextList",
"theme": "${viewport.theme}",
"headerTitle": "${textListData.headerTitle}",
"headerSubtitle": "${textListData.headerSubtitle}",
"headerAttributionImage": "${textListData.headerAttributionImage}",
"headerDivider": true,
"headerBackButtonAccessibilityLabel": "back",
"headerBackButtonCommand": {
"type": "SendEvent",
"arguments": [
"goBack"
]
},
"backgroundImageSource": "${textListData.backgroundImageSource}",
"backgroundScale": "best-fill",
"backgroundAlign": "center",
"primaryAction": {
"type": "SendEvent",
"arguments": [
"ListItemSelected",
"${ordinal}"
]
},
"listItems": "${textListData.listItemsToShow}"
}
Let me know if you need anything else or if you’d like me to clarify anything.
I appreciate you guys looking into this.