question

newuser-cecdd7c5-f061-476a-9331-9a2b81cf3257 avatar image

Alexa Proactive Events API returns 403 for unicast type — No enablement for clientId

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


proactive events api


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: *************"

proactive events
10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Amazon_Bernardo Bezerra avatar image
Amazon_Bernardo Bezerra answered

Hello @NewUser-cecdd7c5-f061-476a-9331-9a2b81cf3257 and sorry for the long time without communication.

Are you still facing this issue? When I tried to send a message as unicast I was able to receive on my devices.

Please let me know if this is still a problem for you.

Regards,
Barry

10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Tamer avatar image
Tamer answered

Hello Barry,

I still have the same problem when sending unicast call. (Multicast one returns 202).

Regards,

Tamer

1 comment
10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Amazon_Bernardo Bezerra avatar image Amazon_Bernardo Bezerra commented ·

Hello and thank you for your message.

Can you please share the payload that is being sent to the service?

Regards,
Barry

0 Likes 0 ·