github alexa/alexa-skills-kit-sdk-for-nodejs 1.0.17
Device Address API Helper

latest releases: v2.14.0, v2.12.1, v2.12.0...
6 years ago

This release includes a new helper class: DeviceAddressService that helps developers to better utilize the device address api.

To get user device address information, simply call one of the following functions:

DeviceAddressService.getFullAddress(deviceId, apiEndpoint, token);
DeviceAddressService.getCountryAndPostalCode(deviceID, apiEndpoint, token);

An example to get user full address information is as follows:

const Alexa = require('alexa-sdk');
'DeviceAddressIntent': function () {
        if (this.event.context.System.user.permissions) {
              let token = this.event.context.System.user.permissions.consentToken;
              let apiEndpoint = this.event.context.System.apiEndpoint;
              let deviceId = this.event.context.System.device.deviceId;

              let das = new Alexa.services.DeviceAddressService();
              das.getFullAddress(deviceId, apiEndpoint, token)
                    .then((data) => {
                             this.response.speak('<address information>');
                             console.log('Address get: ' + JSON.stringify(data));
                     })
                   .catch((error) => {
                             this.response.speak('I'm sorry. Something went wrong.');
                             console.log(error.message);
                     });
        } else {
              this.response.speak('Please grant skill permissions to access your device address.') 
        }
        this.emit(':responseReady');
}

Don't miss a new alexa-skills-kit-sdk-for-nodejs release

NewReleases is sending notifications on new releases.