1
votes

I am using the Amazon Alexa Skill Management API (SMAPI) for the goal of cloning one of my skills, and changing key variables such as the skill name and I can do that successfully: I GET the manifest, make some changes, and CREATE a new skill using that updated manifest.

Then I wait for the skill status to finish being created, and then I am able to successfully GET my blueprint skill's interaction model, but when I UPDATE the new skill with the interaction model, I receive this error:

"{"message": "The specified skill or locale does not have a model associated."}"

I've been searching through the API for a way to "associate" a model for the new skill before updating, but I can't find anything. The API does say that using Update Interaction Model "Creates an InteractionModel for the skill." So I am expecting it to create the model if the skill does not have one associated yet.

I have contacted and not yet heard back from Amazon Support.

DETAILS

Here are the steps I am attempting which result in the above error:

I'm using my own webpage built in PHP to manage my Alexa Skills using SMAPI.

First I use Amazon Login to gain an access_token with required permissions:

 alexa::ask:skills:read  
 alexa::ask:skills:readwrite 
 alexa::ask:models:read 
 alexa::ask:models:readwrite 
 alexa::ask:skills:test

This successfully returns an access_token. I then use the access_token to get the list of skills. Then ouput those skills with a button to clone it. That will use the skill's ID as the blueprint skillId below.

Clone Skill code:

//GET THE MANIFEST OF THE BLUEPRINT SKILL
$manifestObj = getAlexaSkillManifest($access_token, $skillId);

//CHANGE THE NAME IN THE SKILL MANIFEST
$manifestObj['manifest']['publishingInformation']['locales']['en-US']['name'] = "clone test";

//CREATE NEW SKILL USING BLUEPRINT MANIFEST
$createdSkill = createAlexaSkillManifest($access_token, $vendorId, $manifestObj['manifest'], $body);
$newSkillId = $createdSkill['skillId'];

//SUCCESSFUL SO FAR

//GET BLUEPRINT SKILL'S INTERACTION MODEL
$blueprintSkillIntents = getAlexaSkillIntents($access_token, $skillId);

//CHECK AND WAIT FOR THE NEW SKILL TO BE COMPLETELY CREATED BEFORE ATTEMPTING TO UPDATE THE NEW SKILL'S INTERACTION MODEL
for ($i=0; $i <= 3; $i++) {
    $status = getAlexaSkillStatus ($access_token, $newSkillId);
    if($status['manifest']['lastUpdateRequest']['status']=="SUCCEEDED") {

        //LOGGING HERE SHOWS THIS FIRES AFTER NEW SKILL STATUS IS COMPLETE

        //UPDATE NEW SKILL INTERACTION MODEL
        $newSkillIntents = updateAlexaSkillIntents($access_token, $newSkillId, $blueprintSkillIntents);
        break;
    }
    sleep(1);
}

Get the blueprint interaction model function (SUCCESSFUL):

function getAlexaSkillIntents ($access_token, $skillId, $stage="development", $version="~current") {

    $locale="en-US";
    $url = "https://api.amazonalexa.com/v1/skills/$skillId/stages/$stage/interactionModel/locales/$locale/versions/$version";

    $ch = curl_init($url);
    curl_setopt($ch, CURLOPT_HTTPHEADER, array('Authorization: '.$access_token));
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
    curl_setopt($ch, CURLOPT_HTTP_VERSION, 'CURLOPT_HTTP_VERSION_NONE');
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    $result = curl_exec($ch);
    curl_close($ch);

    $result = json_decode($result, true);
    return $result;
}

//SUCCESSFULLY RETURNS THE INTERACTION MODEL OF THE BLUEPRINT SKILL

Update the new skill Interaction Model function (ERRORS):

function updateAlexaSkillIntents ($access_token, $skillId, $intentModel, $stage="development") {

    $intentModel=json_encode($intentModel);

    $locale="en-US";
    $url = "https://api.amazonalexa.com/v1/skills/$skillId/stages/$stage/interactionModel/locales/$locale";

    $fp = fopen('php://temp/maxmemory:256000', 'w');

    if (!$fp) { die('could not open temp memory data'); }

    fwrite($fp, $intentModel);
    fseek($fp, 0);

    $ch = curl_init($url);
    curl_setopt($ch, CURLOPT_BINARYTRANSFER, true);
    curl_setopt($ch, CURLOPT_INFILE, $fp); // file pointer
    curl_setopt($ch, CURLOPT_INFILESIZE, strlen($intentModel));
    curl_setopt($ch, CURLOPT_HTTPHEADER, array('Authorization: '.$access_token));
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
    curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
    curl_setopt($ch, CURLOPT_HTTP_VERSION, 'CURLOPT_HTTP_VERSION_NONE');
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    $result = curl_exec($ch);
    curl_close($ch);

    $result = json_decode($result, true);
    return $result;
}

That $result returns the error from Alexa SMAPI:

"{"message": "The specified skill or locale does not have a model associated."}"

How can I resolve this error? or How should I go about using SMAPI to clone a skill?

1

1 Answers

1
votes

I got the same error message when using ASK CLI to update my skill model. The problem was the locale. I was using en-UK in the command line while the skill supported only en-US.

Example:

ask api get-model --debug -s "skill id ..."--stage development -l en-US > model.json