This release includes a new helper class: ListManagementService
that helps developers to better utilize the Alexa List API.
The ListManagmentService
provides the following functions to access Alexa List API:
getListsMetadata(token)
createList(listObkect, token)
getList(listId, itemStatus, token)
updateList(listId, listObject, token)
deleteList(listId, token)
createListItem(listId, listItemObject, token)
getListItem(listId, itemId, token)
updateListItem(listId, itemId, listItemObject, token)
deleteListItem(listId, itemId, token)
An example to create a named list is as follows:
const Alexa = require('alexa-sdk');
'CreateListIntent': function () {
if (this.event.context.System.user.permissions) {
let token = this.event.context.System.user.permissions.consentToken;
let lms = new Alexa.services.ListManagementService();
let listObject = {
name : 'My Test List',
state : 'active',
version : 1
};
lms.createList(listObject, token)
.then((data) => {
this.response.speak('List successfully created!');
this.emit(':responseReady');
})
.catch((error) => {
console.log(error.message);
this.response.speak('Unable to create List!');
this.emit(':responseReady');
});
} else {
this.response.speak('Please grant skill permissions to access Alexa List API.');
this.emit(':responseReady');
}
}