fix InteractionModel generator
This commit is contained in:
@@ -79,6 +79,7 @@ router.put ('/:id', bodyParser.json (), async (req, res, next) => {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
.catch (e => {
|
.catch (e => {
|
||||||
|
console.log(e);
|
||||||
//Update on amazon failed, revert changes in database and send error to user
|
//Update on amazon failed, revert changes in database and send error to user
|
||||||
databaseHelper
|
databaseHelper
|
||||||
.updateSkill (id, currentSkillState)
|
.updateSkill (id, currentSkillState)
|
||||||
|
|||||||
@@ -64,25 +64,12 @@ var generateInteractionModel = function (skill) {
|
|||||||
let result = {};
|
let result = {};
|
||||||
let allIntents = [];
|
let allIntents = [];
|
||||||
|
|
||||||
allIntents.push({
|
|
||||||
"name": "AMAZON.CancelIntent",
|
|
||||||
"samples": []
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "AMAZON.HelpIntent",
|
|
||||||
"samples": []
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "AMAZON.StopIntent",
|
|
||||||
"samples": []
|
|
||||||
},);
|
|
||||||
|
|
||||||
skill.intents.map (intent => {
|
skill.intents.map (intent => {
|
||||||
allIntents.push ({name: intent.intentName, samples: intent.questions, slots:[]});
|
allIntents.push ({name: intent.intentName, samples: intent.questions});
|
||||||
});
|
});
|
||||||
|
|
||||||
//Special intent for sending message (Dialog)
|
//Special intent for sending message (Dialog)
|
||||||
/*
|
|
||||||
allIntents.push ({
|
allIntents.push ({
|
||||||
name: 'SendMessageIntent',
|
name: 'SendMessageIntent',
|
||||||
samples: [
|
samples: [
|
||||||
@@ -108,7 +95,9 @@ var generateInteractionModel = function (skill) {
|
|||||||
},
|
},
|
||||||
],
|
],
|
||||||
});
|
});
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
let customSlotTypes = [
|
let customSlotTypes = [
|
||||||
{
|
{
|
||||||
name: 'EmailSlot',
|
name: 'EmailSlot',
|
||||||
@@ -163,7 +152,7 @@ var generateInteractionModel = function (skill) {
|
|||||||
],
|
],
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
let dialogPrompts = [
|
let dialogPrompts = [
|
||||||
{
|
{
|
||||||
id: 'Elicit.Intent-SendMessageIntent.IntentSlot-Name',
|
id: 'Elicit.Intent-SendMessageIntent.IntentSlot-Name',
|
||||||
@@ -201,7 +190,7 @@ var generateInteractionModel = function (skill) {
|
|||||||
],
|
],
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
let dialogIntents = [
|
let dialogIntents = [
|
||||||
{
|
{
|
||||||
name: 'SendMessageIntent',
|
name: 'SendMessageIntent',
|
||||||
@@ -239,24 +228,24 @@ var generateInteractionModel = function (skill) {
|
|||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
let dialog = {
|
result.interactionModel = {};
|
||||||
intents: dialogIntents,
|
|
||||||
};
|
|
||||||
|
|
||||||
result.languageModel = {
|
result.interactionModel.languageModel = {
|
||||||
invocationName: skill.invocationName,
|
invocationName: skill.invocationName,
|
||||||
//types: customSlotTypes,
|
types: customSlotTypes,
|
||||||
intents: allIntents,
|
intents: allIntents,
|
||||||
};
|
};
|
||||||
|
|
||||||
//result.prompts = dialogPrompts;
|
result.interactionModel.prompts = dialogPrompts;
|
||||||
//result.dialog = dialog;
|
result.interactionModel.dialog = {};
|
||||||
|
result.interactionModel.dialog.intents = dialogIntents;
|
||||||
|
|
||||||
console.log(JSON.stringify(result));
|
|
||||||
return JSON.stringify (result);
|
return JSON.stringify (result);
|
||||||
};
|
};
|
||||||
|
|
||||||
var uploadSkill = function (skill) {
|
var uploadSkill = function (skill) {
|
||||||
|
let generatedInteractionModel = generateInteractionModel(skill);
|
||||||
|
console.log(generatedInteractionModel);
|
||||||
return fetch (
|
return fetch (
|
||||||
`https://api.amazonalexa.com/v0/skills/${skill.skillID}/interactionModel/locales/en-US`,
|
`https://api.amazonalexa.com/v0/skills/${skill.skillID}/interactionModel/locales/en-US`,
|
||||||
{
|
{
|
||||||
@@ -264,7 +253,7 @@ var uploadSkill = function (skill) {
|
|||||||
headers: {
|
headers: {
|
||||||
Authorization: config.TOKEN,
|
Authorization: config.TOKEN,
|
||||||
},
|
},
|
||||||
body: generateInteractionModel (skill),
|
body: generatedInteractionModel,
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user