Alexa Proactive Events & Notifications with Jovo
The Alexa Proactive Events API lets your skill send notifications to users even when they haven't opened the skill. This tutorial shows how to request the necessary permissions, obtain a proactive access token, and send events using Jovo.
1. Enable Proactive Events in the Skill Manifest
In your jovo.project.ts, add the proactive events permission to your Alexa skill manifest:
manifest: {
permissions: [
{ name: 'alexa::devices:all:notifications:write' }
],
events: {
publications: [
{ eventName: 'AMAZON.MessageAlert.Activated' }
]
}
}
2. Get a Proactive Access Token
Call the Alexa API with your client credentials to get a Bearer token valid for proactive event calls:
const response = await axios.post('https://api.amazon.com/auth/o2/token', {
grant_type: 'client_credentials',
client_id: process.env.ALEXA_CLIENT_ID,
client_secret: process.env.ALEXA_CLIENT_SECRET,
scope: 'alexa::proactive_events'
});
const accessToken = response.data.access_token;
3. Send the Proactive Event
await axios.post('https://api.eu.amazonalexa.com/v1/proactiveEvents/stages/development', {
timestamp: new Date().toISOString(),
referenceId: 'unique-event-id',
expiryTime: new Date(Date.now() + 3600000).toISOString(),
event: {
name: 'AMAZON.MessageAlert.Activated',
payload: { messageGroup: { creator: { name: 'Jovo' }, count: 1 } }
},
relevantAudience: { type: 'Unicast', payload: { user: { userId: USER_ID } } }
}, { headers: { Authorization: `Bearer ${accessToken}` } });