3

Current behavior:

  • I can access metrics for each of my Alexa Skills via the developer console, such as "total unique customers over past 7 days"

Desired behavior:

  • do the same but via Amazon's ASK CLI or SMAPI (in order to automate + bulk export for hundreds of skills)
  • I am getting a similar error when I try the ask-cli node.js module. and here is my command line : ask smapi get-skill-metrics --skill-id amzn1.ask.skill.xxxxx --start-time 2020-10-14T12:45:00Z --end-time 2020-10-19T12:45:00Z --period PT1H --metric uniqueCustomers --stage live --skill-type custom --locale en-US > metrics.json [Error]: { "name": "AskSdkModelRuntime.DefaultApiClient Error" } – Rich Elswick Oct 19 '20 at 17:13

1 Answers1

0

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:

  1. Set up an LWA security profile.
  2. 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>.
  3. 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

smapi_guru
  • 51
  • 1