question

newuser-1eac503d-c611-431a-8afa-0d83c7f96b28 avatar image
newuser-1eac503d-c611-431a-8afa-0d83c7f96b28 asked ·

ProactiveEvents "something wrong in the service"

Hi,


I would like to add the ProactiveEvents API to my Skill. When I try to send a notification I always get a "There is something wrong in the service" error.

What I have done so far:


I have added the events

"events": {
  "publications": [
    {
      "eventName": "AMAZON.MessageAlert.Activated"
    },
    {
      "eventName": "AMAZON.OrderStatus.Updated"
    }
  ],
  "endpoint": {
    "uri": "https://MY-SKILL-ENDPOINT",
    "sslCertificateType": "Trusted"
  }
}


"permissions": [
  {
    "name": "alexa::profile:email:read"
  },
  {
    "name": "alexa::devices:all:notifications:write"
  }
],

and saved these changes.

The skill is enabled in dev mode in my account and the notifications are enabled.


To get the the Authorization token, I do the following:

curl --location --request POST 'https://api.amazon.com/auth/o2/token' \
--header 'Content-Type: application/x-www-form-urlencoded' \
--data-urlencode 'grant_type=client_credentials' \
--data-urlencode 'client_id=amzn1.application-oa2-client.XXXXXXX' \
--data-urlencode 'client_secret=YYYYYYYY' \
--data-urlencode 'scope=alexa::proactive_events'

This request works correctly and I receive the access_token.

Next, I try to send a Unicast notification to myself. In the example below I am using the North American development endpoint. I have tried the other endpoints (EU and Far East) and all give the same error.

curl --location --request POST 'https://api.eu.amazonalexa.com/v1/proactiveEvents/' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer Atc|ZZZZZZZZZZZZZZ' \
--data-raw '{"timestamp":"2020-07-18T17:45:49+00:00","referenceId":"foobar1231595094349","expiryTime":"2020-07-19T13:45:49+00:00","event":{"name":"AMAZON.MessageAlert.Activated","payload":{"state":{"status":"UNREAD","freshness":"NEW"},"messageGroup":{"creator":{"name":"User"},"count":1}}},"localizedAttributes":[{"locale":"en-US","providerName":"Notification","contentName":"New Message Received"}],"relevantAudience":{"type":"Unicast","payload":{"user":"amzn1.ask.account.XXXXXXXXXX"}}}'


With this request, I always receive a 500 Internal Server Error and the response is:

 There is something wrong in the service, please retry


Thanks!

alexa skills kitproactive events
10 |2000 characters needed characters left characters exceeded

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 and thank you for your message.

I noticed a couple of things that might be causing issues for your skill:

  • You are using the https://api.eu.amazonalexa.com/v1/proactiveEvents/. Is your skill already live? Note that according to the documentation, there are specific endpoints that you need to use when your skill is still under development;
  • Your localizedAttributes object contains information about the en-US locale, yet the endpoint you are using is for EU. Is this a deliberate choice? Note that for each user, you can retrieve the correct endpoint from the request: handlerInput.requestEnvelope.context.System.apiEndpoint;

Using my skill and your payload (with the appropriate access token, of course) I was able to send notifications to my user.

If after checking the points above you are still unable to send notifications, please share your skill ID so I can look further into it.

Regards,
Barry

3 comments
10 |2000 characters needed characters left characters exceeded

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

Hi Barry,

Had to reply as an anwer as it did not let me submit code blocks in a comment :(

0 Likes 0 ·
Amazon_Bernardo Bezerra avatar image Amazon_Bernardo Bezerra ♦♦ newuser-1eac503d-c611-431a-8afa-0d83c7f96b28 ·

Hi,

I am not following. Did you post your reply somewhere else?

Regards,
Barry

0 Likes 0 ·

I posted it as an answer here, but it said that it was awaiting moderation by an moderator of the forum. So I guess/hope, it will be public soon?

0 Likes 0 ·
newuser-1eac503d-c611-431a-8afa-0d83c7f96b28 avatar image
newuser-1eac503d-c611-431a-8afa-0d83c7f96b28 answered ·

Hi,

thank you for your reply.


My skill is not live yet.

I literally tried every endpoint and all show the same error.

https://api.amazonalexa.com/v1/proactiveEvents/stages/development (North America)
https://api.eu.amazonalexa.com/v1/proactiveEvents/stages/development (Europe)
https://api.fe.amazonalexa.com/v1/proactiveEvents/stages/development (Far East)
https://api.amazonalexa.com/v1/proactiveEvents/   (North America)
https://api.eu.amazonalexa.com/v1/proactiveEvents/ (Europe)
https://api.fe.amazonalexa.com/v1/proactiveEvents/ (Far East)


The request contains the api.eu.amazonalexa.com endpoint; so, I tried to specifically use

https://api.eu.amazonalexa.com/v1/proactiveEvents/stages/development

but I am still seeing the same 500 HTTP error. To be precise this is the request:


> curl --location --request POST 'https://api.eu.amazonalexa.com/v1/proactiveEvents/stages/development' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer Atc|MQEBID3TXXXXXXXX' \
--data-raw '{"timestamp":"2020-07-18T17:45:49+00:00","referenceId":"foobar1231595094349","expiryTime":"2020-07-19T13:45:49+00:00","event":{"name":"AMAZON.MessageAlert.Activated","payload":{"state":{"status":"UNREAD","freshness":"NEW"},"messageGroup":{"creator":{"name":"User"},"count":1}}},"localizedAttributes":[{"locale":"en-US","providerName":"Notification","contentName":"New Message Received"}],"relevantAudience":{"type":"Unicast","payload":{"user":"amzn1.ask.account.XXXXXXXXXX"}}}'
There is something wrong in the service, please retry%  


Currently, the skill is en-US only but my account is European. For my other en-US-only skills I have set my Echo device to en-US. That seems to work perfectly. However this is probably why I am getting the EU endpoint in the request json.


My skill ID is:

amzn1.ask.skill.3f0d0f87-5861-4e16-85ce-397d5c6c6616


(I tried to post this reply as a comment but apparently it did not like the 'code' elements of the post and would not let me submit it. So I guess I have to add it as an answer?)

3 comments
10 |2000 characters needed characters left characters exceeded

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

Hello and thanks for the information.

I was able to reproduce the issue by setting the user as amzn1.ask.account.XXXXXXXXXX, as you did in the example provideed. Please note that this has to be the a valid userID of the user you want to send the notification to. This can be retrieved from the request: handlerInput.requestEnvelope.context.System.user.userId.

Also, I couldn't help but notice that the timestamp and expiryTime are both in the past. It didn't trigger an error before because that verification is done afterwards, but it would also prevent you to send the message.

Let me know if this help.

Regards,
Barry

0 Likes 0 ·

Hi,

turn out I've been stupid (once more) :)

I saved the userId to a SQL database and always copied it from there. I've set the datatype for that column to Varchar(200) so the userIds got truncated after 200 characters... and apparently they are much longer than that. So, when I use the complete userId it works.

Thanks for your help!

1 Like 1 ·
Amazon_Bernardo Bezerra avatar image Amazon_Bernardo Bezerra ♦♦ newuser-1eac503d-c611-431a-8afa-0d83c7f96b28 ·

Thanks for coming back and letting us know you were able to fix your issue!

Regards,
Barry

0 Likes 0 ·