Echolocate is a function to help you get an Echo device's physical location and timezone using the Alexa and Geo-location API's. It's especially useful when building Alexa skills that return time information. The skill request will only give you GMT times, so you can use this library to help you figure out the timezone of your user's echo device and relay the time correctly.
In your Alexa Skill:
;// Get the deviceId and consentToken from the Alexa Skill Request objectconst deviceLocation = await
Or alternatively if you want to use the command-line for whatever reason:
echolocate --device-id "amzn1.ask.device..." --consent-token "Atza|..."
deviceId:"amzn1.ask.device...."countryCode: "US"postalCode: "11215"city: "New York"country: "United States"formattedAddress: "Brooklyn, NY 11215, USA"latitude: 406986772longitude: -739859414timezone:dstOffset: 3600rawOffset: -18000timeZoneId: "America/New_York"timeZoneName: "Eastern Daylight Time"
Echolocate will use the Alexa API to get the Echo device's location and timezone based on the
you have set for you Alexa Skill. To perform an echolocation, you must supply two pieces of
information from your Skill's request: the
deviceId and the
will only be present if you request location permission in your skill. You can find more information
about this on Amazon's Developer Portal
In order to keep the number of geolocation requests to a minimum, you can configure Echolocate to
store the location information it retrieves in an AWS Dynamo DB. To do so, create a config file at
config/default.js and fill in the required information.
moduleexports =echolocate:awsConfig:accessKeyId: "<AWS ACCESS KEY>"secretAccessKey: "<AWS SECRET ACCESS KEY>"region: "<AWS REGION>"dbTableName: "<DYNAMO DB TABLE NAME>";
Echolocate will actually use the
config library under the hood
so just follow that project's guidelines if you want to customize the config file.
Once set up correctly, Echolocate will store locations for a particular
deviceId in the database
and will retrieve that if it's available. If not, it will save the values it finds via geolocation
to the DB for the next time it's retrieved. This should make subsequent location calls much faster.