One way to accomplish this is to hit SMAPI through JavaScript using the SMAPI Node.js SDK, with docs available here.
In order to authenticate with SMAPI, you're going to need to do the following:
- Set up an LWA security profile.
- Use the ASK CLI to exchange your LWA Client ID and Client Secret for an LWA refresh token using
ask util generate-lwa-tokens --client-id <Client ID> --client-confirmation <Client Secret>
.
- Use this refresh token when you initialize the SMAPI node SDK:
const Alexa = require('ask-smapi-sdk');
// specify the refreshTokenConfig with clientId, clientSecret and refreshToken generated in the previous step
const refreshTokenConfig = {
clientId,
clientSecret,
refreshToken
}
const smapiClient = new Alexa.StandardSmapiClientBuilder()
.withRefreshTokenConfig(refreshTokenConfig)
.client();
You will then be able to hit SMAPI through function calls on the SDK!
Helpful resource on this (it shows pretty much what you're asking for, which is automating skill metric retrieval):
https://levelup.gitconnected.com/email-yourself-daily-alexa-skill-metrics-updates-using-lambda-smapi-and-ses-9c16ac97c1f8