Skip to content

Instantly share code, notes, and snippets.

@pschild
Last active May 19, 2019 11:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pschild/288b1135b304dfad75fedd0820455df5 to your computer and use it in GitHub Desktop.
Save pschild/288b1135b304dfad75fedd0820455df5 to your computer and use it in GitHub Desktop.
Alexa Proactive Events API
1) POST to https://api.amazon.com/auth/o2/token
body {
grant_type: client_credentials,
client_id: amzn1.application...,
client_secret: ...,
scope: alexa::proactive_events
}
Response:
{
"access_token": "<ACCESS_TOKEN>",
"scope": "alexa::proactive_events",
"token_type": "bearer",
"expires_in": 3600
}
2) POST to https://api.eu.amazonalexa.com/v1/proactiveEvents/stages/development
headers {
Content-Type: application/json,
Authorization: Bearer <ACCESS_TOKEN>
}
body {
"timestamp": "2019-05-18T19:22:00.00Z",
"referenceId": "unique-id-of-this-instance",
"expiryTime": "2019-05-18T19:22:00.00Z",
"event": {
"name": "AMAZON.MessageAlert.Activated",
"payload": {
"state": {
"status": "UNREAD",
"freshness": "NEW"
},
"messageGroup": {
"creator": {
"name": "Test"
},
"count": 6,
"urgency": "URGENT"
}
}
},
"localizedAttributes": [],
"relevantAudience": {
"type": "Unicast",
"payload": {
"user": "amzn1.ask.account...." // get with console.log(request.context.System.user.userId);
}
}
}
{
"manifest": {
"publishingInformation": {...},
"apis": {...},
"manifestVersion": "1.0",
"permissions": [
{
"name": "alexa::devices:all:notifications:write"
}
],
"events": {
"publications": [
{
"eventName": "AMAZON.MessageAlert.Activated"
}
],
"endpoint": {
"uri": "<DYNAMIC>"
},
"subscriptions": [
{
"eventName": "SKILL_PROACTIVE_SUBSCRIPTION_CHANGED"
}
],
"regions": {
"NA": {
"endpoint": {
"uri": "<DYNAMIC>"
}
}
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment