我想用我的Alexa技能来提醒自己。 但是我收到“错误:连接ECONNREFUSED 127.0.0.1:443”的错误
文档链接-https://developer.amazon.com/docs/smapi/alexa-reminders-api-reference.html
我已在deleloper.amazon.com中启用了我的Alexa技能的提醒权限。
我包括了https模块。
谢谢。
if (event.request.type === 'IntentRequest') {
var response = new Response(context,event.session);
if (event.request.intent.name in intentHandlers) {
intentHandlers['newTimer'](event.request, event.session, response,getSlots(event.request),event);
}
}
// Code to create reminder
intentHandlers['newTimer'] = function(request,session,response,slots,event){
var time = new Date();
let start = time.toISOString();
if (start.substring(start.length - 1) === 'Z') {
start = start.substring(0, start.length - 1);
}
var post_data = JSON.stringify({
"requestTime" : start,
"trigger": {
"type" : "SCHEDULED_ABSOLUTE",
"scheduledTime" : "2018-02-26T19:00:00.000",
"timeZoneId" : "America/Los_Angeles",
"recurrence" : {
"freq" : "WEEKLY",
"byDay": ["MO"]
}
},
"alertInfo": {
"spokenInfo": {
"content": [{
"locale": "en-US",
"text": "walk the dog"
}]
}
},
"pushNotification" : {
"status" : "ENABLED"
}
});
const req_options = {
path: event.context.System.apiEndpoint + '/v1/alerts/reminders',
method: 'POST',
headers: {
"Authorization": 'Bearer'+event.context.System.apiAccessToken,
"content-type": "application/json",
}
}
const req = https.request(req_options, (res) => {
res.on('data', (d) => {
response.speechText = 'Ok, Setting timer for 25 minutes.';
response.repromptText = 'For example, . ';
response.shouldEndSession = false;
response.done();
})
})
req.write(post_data);
req.on('error', (error) => {
response.speechText = 'Sorry Unable to set reminder for you.'+error;
response.repromptText = 'For example, . ';
response.shouldEndSession = false;
response.done();
})
}
答案 0 :(得分:0)
您应在Bearer和访问令牌之间添加一个空格
"Authorization": 'Bearer '+event.context.System.apiAccessToken'
您正在使用哪个版本的alexa-sdk
?