I've been trying to get Lazy loading working using the Python SDK. I've referenced the following documentation (java script):
I think where I'm having a problem is generating the correct response to the "Alexa.Presentation.APL.LoadIndexListData" request.
Here is the example from the above Java
return handlerInput.responseBuilder .addDirective({ type: "Alexa.Presentation.APL.SendIndexListData", token: TOKEN, correlationToken: requestObject.correlationToken, listId: requestObject.listId, startIndex: requestObject.startIndex, minimumInclusiveIndex: 0, maximumExclusiveIndex: colors.length, items: getColorsFromIndex(requestObject.startIndex, requestObject.count, colors) }).getResponse();
Here is my attempt to re-write it in python, where recipeSummeryData is my set of new data:
return ( handler_input.response_builder .add_directive( object_type="Alexa.Presentation.APL.SendIndexListData", token="myRecipes", correlation_token=requestObject.correlation_token, document=_load_apl_document("./documents/launchDocument.json"), list_id=requestObject.list_id, startIndex=requestObject.start_index, minimumInclusiveIndex=0, maximumExclusiveIndex=len(recipeSummeryData), items=recipeSummeryData ) .response )
When I run the above code it keeps failing saying all the variables I'm setting (object_type, token, correlation_token, list_ied, startIndex, etc...) don't exist. I tried using the naming convention of those variables shown in the javascript version too (correlationToken instead of correlation_token as an example). I'm assuming I'm messing up the response format in some manner. I've listed my complete LoadIndexListData handler below for completeness.
class LoadIndexListDataRequestHandler(AbstractRequestHandler): def can_handle(self, handler_input): return is_request_type("Alexa.Presentation.APL.LoadIndexListData")(handler_input) def handle(self, handler_input): access_token = handler_input.request_envelope.context.system.user.access_token credentials = AccessTokenCredentials(access_token, 'alexa-skill/1.0') requestObject = handler_input.request_envelope.request self.recipeDat = recipes(credentials) recipeSummeryData = self.recipeDat.GetRecipesDescFromFolder(requestObject.start_index, requestObject.start_index+ 5 - 1) handler_input.response_builder.add_directive(t return ( handler_input.response_builder .add_directive( object_type="Alexa.Presentation.APL.SendIndexListData", token="myRecipes", correlation_token=requestObject.correlation_token, document=_load_apl_document("./documents/launchDocument.json"), list_id=requestObject.list_id, startIndex=requestObject.start_index, minimumInclusiveIndex=0, maximumExclusiveIndex=len(recipeSummeryData), items=recipeSummeryData ) .response