我正在使用Amazon Alexa Skill Management API (SMAPI) 来克隆我的一项技能,并更改关键变量(例如技能名称),因此我可以成功做到这一点:我得到了清单,进行一些更改,然后使用更新后的清单创建新技能。
然后,我等待技能状态创建完毕,然后能够成功获取蓝图技能的交互模型,但是当我使用交互模型更新新技能时,会收到此错误:
“ {” message“:”指定的技能或语言环境没有关联的模型。“}”
我一直在搜索API,以寻找一种在更新之前将模型与新技能“关联”的方法,但是我什么都找不到。该API确实说使用 Update Interaction Model “为该技能创建一个InteractionModel。” 因此,我希望它在没有技能的情况下创建模型。尚未关联。
我已经联系但尚未收到Amazon支持的回音。
以下是我尝试的导致上述错误的步骤:
我正在使用自己的内置PHP网页来通过SMAPI管理我的Alexa技能。
首先,我使用Amazon Login获得具有必需权限的access_token:
alexa::ask:skills:read
alexa::ask:skills:readwrite
alexa::ask:models:read
alexa::ask:models:readwrite
alexa::ask:skills:test
这将成功返回access_token
。然后,我使用access_token
获取技能列表。然后使用按钮输出这些技能以将其克隆。它将使用技能的ID作为下面的蓝图skillId
。
//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);
}
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
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;
}
该$result
返回来自Alexa SMAPI的错误:
“ {” message“:”指定的技能或语言环境没有关联的模型。“}”
如何解决此错误?或如何使用SMAPI克隆技能?
答案 0 :(得分:1)
使用ASK CLI更新技能模型时,我得到了相同的错误消息。问题是语言环境。我在命令行中使用en-UK,而该技能仅支持en-US。
示例:
ask api get-model --debug -s "skill id ..."--stage development -l en-US > model.json