これは要注意です: まず、私が "DeparmentLocation"というインテントを求めたら、developer.amazon.comに問題なく動作します。私が実際のデバイスを使用するとき、それは 'unhandledIntent'を呼び出します。 第2に、は "Hey Alexa、呼び出し名"と再入力すると、が動作するかどうかを確認します。それが未処理のメッセージで応答するまでは何も言わない。それから私は発話を正常に言うことができ、それは応答するでしょう。 最後に、は "facilityLocation"インテントで作業するです。私は何が起こっているのか、何が違うのかは分かりません。 ここにコードがあります。 ありがとう!Alexaのスキルはdeveloper.amazonで動作しますが、デバイスでは動作しませんか?
var doc = require('dynamodb-doc');
var db = new doc.DynamoDB();
var Alexa = require('alexa-sdk');
exports.handler = function(event, context) {
var alexa = Alexa.handler(event, context);
var handlers = {
'sessionStartedRequest' : function(){
this.emit(':talk', "welcome.")
},
'AMAZON.StopIntent': function() {
this.emit(':tell', "Goodbye!");
},
'AMAZON.CancelIntent': function() {
this.emit(':tell', "Goodbye!");
},
'Unhandled': function() {
this.emit(':ask', "I'm sorry. I didn't get that. Could you repeat it?", "Ask me a question.");
},
'SessionEndedRequest': function() {
this.emit(":tell", "Goodbye!");
},
'DepartmentLocationIntent': function() {
var name = "";
if (this.event.request.intent.slots.department.value) {
name = this.event.request.intent.slots.department.value.toLowerCase().trim();
}
var key = {
'name': name
};
var tableName = "Department";
var params = {
TableName: tableName,
Key: key,
ProjectionExpression: 'loc'
};
db.getItem(params, function (err, data) {
//alexa.emit(":tell", name);
if (err) {
console.log(err);
//alexa.emit(':tell', "Sorry! I did not catch that!");
alexa.emit(':tell', err);
} else {
var loc = JSON.stringify(data.Item.loc);
alexa.emit(':tell', "The " + name + " department is in " + loc);
}
}, context.done);
},
'FacilityLocationIntent': function() {
var name = "";
if (this.event.request.intent.slots.facility.value) {
name = this.event.request.intent.slots.facility.value.toLowerCase().trim();
}
var key = {
'name': name
};
var tableName = "Facility";
var params = {
TableName: tableName,
Key: key,
ProjectionExpression: 'loc'
};
db.getItem(params, function(err, data) {
if (err) {
console.log(err);
alexa.emit(':tell', "Sorry! This facility does not exist!");
} else {
var response = JSON.stringify(data.Item.loc);
alexa.emit(':tell', name + " is located in " + response);
}
}, context.done);
}
};
alexa.registerHandlers(handlers);
alexa.execute();
};
`