我正在创建一个 Alexa 事实技能,要求用户提供一些有关其健康状况的信息,用户根据不同区域的疼痛程度给出 1-10 的分数。然后,我将数据输入到 DynamoDB 表中,该表存储四个健康问题(肿胀、感觉、睡眠、呼吸)的信息(满分 10 分)和用户 ID。但是,这些条目没有给出创建时间的时间戳。我想知道是否有一种方法可以为每个健康问题响应制作时间戳,而且为整个条目制作时间戳也会有所帮助。我是否必须使用任何外部 SDK,因为我正在查找 DynamoDB 文档,但没有找到任何添加时间戳的方法。
下面是我的 Lambda 函数的 index.js 代码,该函数用于我的 Alexa 技能。
'use strict';
const Alexa = require('alexa-sdk');
const SKILL_NAME = 'Home Assist';
const HELP_MESSAGE = 'You can say I want to input my data';
const HELP_REPROMPT = 'What can I help you with?';
const STOP_MESSAGE = 'Goodbye!';
const handlers = {
'LaunchRequest': function () {
this.emit('HomeAssistQuestions');
},
'HomeAssistQuestions': function () {
this.attributes.healthscores = {
'patientID' : 0,
'scores': {
'feeling': {
'score': 0
},
'sleeping': {
'score': 0
},
'breathing': {
'score': 0
},
'swollen': {
'score': 0
}
}
};
if(this.event.request.dialogState !== 'COMPLETED'){
this.emit(':delegate');
}
else{
const feelingScore = this.event.request.intent.slots.feelingRating.value;
const sleepingScore = this.event.request.intent.slots.sleepingRating.value;
const breathingScore = this.event.request.intent.slots.breathingRating.value;
const swollenScore = this.event.request.intent.slots.SwollenRating.value;
const id = this.event.request.intent.slots.id.value;
this.attributes.healthscores.patientID = id;
this.attributes.healthscores.scores['feeling'].score = feelingScore;
this.attributes.healthscores.scores['sleeping'].score = sleepingScore;
this.attributes.healthscores.scores['breathing'].score = breathingScore;
this.attributes.healthscores.scores['swollen'].score = swollenScore;
this.response.speak("Health Scores Recorded");
this.emit(':responseReady');
}
},
'AMAZON.HelpIntent': function () {
const speechOutput = HELP_MESSAGE;
const reprompt = HELP_REPROMPT;
this.response.speak(speechOutput).listen(reprompt);
this.emit(':responseReady');
},
'AMAZON.CancelIntent': function () {
this.response.speak(STOP_MESSAGE);
this.emit(':responseReady');
},
'AMAZON.StopIntent': function () {
this.response.speak(STOP_MESSAGE);
this.emit(':responseReady');
},
'SessionEndedRequest': function(){
this.emit('saveState', true);
}
};
exports.handler = function (event, context, callback) {
const alexa = Alexa.handler(event, context, callback);
alexa.dynamoDBTableName = 'HealthScores';
alexa.APP_ID = "amzn1.ask.skill.d5b8d597-eb50-41c6-a22d-b0f18c23b544";
alexa.registerHandlers(handlers);
alexa.execute();
};
你可以尝试这样的事情:
...
this.attributes.healthscores.scores['swollen'].score = swollenScore;
this.attributes.healthscores.timestamp = Date.now();
this.response.speak("Health Scores Recorded");
...
在线购买氢可酮是一种强效阿片类药物,通常用于治疗中度至重度疼痛。它的作用是改变大脑和神经系统对疼痛的反应方式