I created a custom skill using Alexa skills SMAPI and enabled the notification while deploying. I gone through the account linking and approving the notifications for the skill. I send notifications to the user(myself). I am able to send notification with multicast, but it does not work for delivery type "Unicast"
SkillId: amzn1.ask.skill.db5481a0-df1f-4e3e-a0e1-c5e727787b65
I am getting HTTP status code: 403 and error message as:
"No enablement for clientId:amzn-*********"
I have followed the Alexa skills proactive API documentation
When sending notification to endpoint
I obtain the accesstoken using skill credentials and add the accesstoken as bearer token to the request.
Note: I have already enabled the skill from https://alexa.amazon.in and I got the Amazon userId, apiAccesstoken, and consentToken. I stored them in my database (mongoDB). I use the Amazon userId to send the notification
var uuid = require('node-uuid'); var accessToken = "This`enter code here` token will be obtained from amazon oauth api."; var userId = "amzn1.ask.account.AH2ZEP5WGJGAEPWPOG3Getc....."; var uuid = require('node-uuid'); var referenceId = uuid.v4(); var now = new Date(); var expiresOn = addMinutes(now, 300); var eventData = { "timestamp": new Date(), "referenceId": uuid, "expiryTime": expiresOn, "event": { "name": "AMAZON.MessageAlert.Activated", "payload": { "state": { "status": "UNREAD", "freshness": "NEW" }, "messageGroup": { "creator": { "name": "Andy" }, "count": 5, "urgency": "URGENT" } } }, "localizedAttributes": [ { "locale": "en-US", "MessageAlert": "UNREAD" }, { "locale": "en-GB", "MessageAlert": "UNREAD" } ], "relevantAudience": { "type": "Unicast", "payload": { "user": userId } } }; var opt = { data: eventData, token: accessToken } sendRequest(opt, function(err, ret, code) { console.log("err : ",JSON.stringify(err, null, 2)); console.log("ret : ",JSON.stringify(ret, null, 2)); console.log("code : ",JSON.stringify(code, null, 2)); }); function sendRequest(options, callback) { var data = options.data; var token = options.token; var headers = { "Content-Type": "application/json", "Authorization":"Bearer "+token }; var opt = { url: "https://api.amazonalexa.com/v1/proactiveEvents/stages/development", method: "POST", headers: headers, body: JSON.stringify(data) }; request(opt, function(error, response, body){ var statusCode = (response && response.statusCode) ? response.statusCode : ""; if(error) { return callback(error); } else if(body) { try { var result = JSON.parse(body); return callback(null, result, statusCode); } catch(e) { console.log("e.message : ",e.message); return callback(null, body, statusCode); } } else { return callback(null, body, statusCode); } }); }
The result should be HTTP status code with 202. But I receive the HTTP status code 403 and the error message as:
"No enablement for clientId: *************"