Alexa主动通知功能报错:expiryTime参数不符合要求求助
Hey Ester, I’ve dealt with similar Alexa notification validation headaches before, so let’s walk through this together!
The error message spells out the core issue clearly: Amazon requires expiryTime to be at least 5 minutes in the future and no more than 24 hours from the current time. Looking at your payload example, there’s a critical mistake in the time values:
{ "timestamp": "2019-01-30T00:11:20", "referenceId": "98871463", "expiryTime": "2019-01-30T00:11:30", "event": { "name": "Alerted", "payload": { "type": "AMAZON.MessageGroup.Alerted", "messageState": { "type": "AMAZON.MessageState", "status": "UNREAD", "freshness": "NEW" }, "message": { "type": "AMAZON.Message", "creator": { "type": "AMAZON.Person", "name": "eve" }, "count": 1, "urgency": "URGENT" } } }, "relevantAudience": { "type": "Multicast", "payload": { } } }
- Your
timestampis2019-01-30T00:11:20 - Your
expiryTimeis2019-01-30T00:11:30
That’s only a 10-second gap—way below the required 5-minute minimum. You mentioned you intended to set an expiry 10 minutes after the timestamp, so this is almost certainly a bug in your time calculation logic: maybe you accidentally added 10 seconds instead of 10 minutes, or there’s a unit conversion error (like using seconds where you meant minutes in your code).
Here’s how to fix this:
- Correct the expiryTime calculation: Make sure you’re adding 10 full minutes (600 seconds) to your timestamp. For your example, the valid expiryTime should be
2019-01-30T00:21:20. - Validate time zones: Amazon’s servers use UTC time. If your server runs on a different time zone, your "current time" might be offset relative to Amazon’s—leading the expiryTime to look too close even if you think you added 5 minutes. Always use UTC for both
timestampandexpiryTime. - Log and verify values: Before sending the notification, print out both timestamps to confirm their difference is between 300 seconds (5 minutes) and 86400 seconds (24 hours).
- Test the adjusted payload: After fixing the expiryTime, resend the notification. You should see the Echo’s yellow light flash, and "Alexa, check my notifications" should retrieve the alert as expected.
Since you said the skill worked before, this was probably a small oversight in a recent code change—easy to fix once you spot the time gap issue!
内容的提问来源于stack exchange,提问作者Ester Gonzalez De Langarica

