Alexa Integration with REST API
Create a Skill API key
Each Skill needs its own API key for tracking.
Integrate the REST API
There are two integration points as outlined below.
1. When Alexa posts to your webhook endpoint
When Alexa posts to your webhook endpoint, post the same data Alexa sent to you to the following endpoint:
https://tracker.dashbot.io/track?platform=alexa&v=11.1.0-rest&type=incoming&apiKey=API_KEY_HERE
Make sure to set the 'Content-Type' header to 'application/json'
The data to POST should pass the following data:
{
"event": {
"version": "1.0",
"session": {
"new": false,
"sessionId": "amzn1.echo-api.session.abcde1b7-aee0-41e6-8192-f6faaed9f5ef",
"application": {
"applicationId": "amzn1.echo-sdk-ams.app.123456-d0ed-0000-ad00-000000d00ebe"
},
"attributes": {},
"user": {
"userId": "amzn1.account.AM12347HF3FAM1B261HK7FFM3A2"
}
},
"request": {
"type": "IntentRequest",
"requestId": "amzn1.echo-api.request.123123a-733e-4e89-893a-fdcb77e2ef0d",
"timestamp": "2015-05-13T12:34:56Z",
"intent": {
"name": "airportinfo",
"slots": {
"AIRPORTCODE": {
"value": "JFK",
"name": "AIRPORTCODE"
}
}
}
}
}
}
Sample cURL
curl -X POST -H "Content-Type: application/json" \
-d '{"event":{"version":"1.0","session":{"new":false,"sessionId":"amzn1.echo-api.session.abcde1b7-aee0-41e6-8192-f6faaed9f5ef","application":{"applicationId":"amzn1.echo-sdk-ams.app.123456-d0ed-0000-ad00-000000d00ebe"},"attributes":{},"user":{"userId":"amzn1.account.AM12347HF3FAM1B261HK7FFM3A2"}},"request":{"type":"IntentRequest","requestId":"amzn1.echo-api.request.123123a-733e-4e89-893a-fdcb77e2ef0d","timestamp":"2015-05-13T12:34:56Z","intent":{"name":"airportinfo","slots":{"AIRPORTCODE":{"value":"JFK","name":"AIRPORTCODE"}}}}}}' \
'https://tracker.dashbot.io/track?platform=alexa&v=11.1.0-rest&type=incoming&apiKey=API_KEY_HERE'
Note
This is just an example — we accept any rich media that Alexa accepts.
2. When your Skill sends a message
When your bot sends a message, POST to the following endpoint:
https://tracker.dashbot.io/track?platform=alexa&v=11.1.0-rest&type=outgoing&apiKey=API_KEY_HERE
Make sure to set the 'Content-Type' header to 'application/json'
The data to POST should pass the following data:
{
"event": {
"version": "1.0",
"session": {
"new": false,
"sessionId": "amzn1.echo-api.session.abcde1b7-aee0-41e6-8192-f6faaed9f5ef",
"application": {
"applicationId": "amzn1.echo-sdk-ams.app.123456-d0ed-0000-ad00-000000d00ebe"
},
"attributes": {},
"user": {
"userId": "amzn1.account.AM12347HF3FAM1B261HK7FFM3A2"
}
},
"request": {
"type": "IntentRequest",
"requestId": "amzn1.echo-api.request.6919844a-733e-4e89-893a-fdcb77e2ef0d",
"timestamp": "2015-05-13T12:34:56Z",
"intent": {
"name": "airportinfo",
"slots": {
"AIRPORTCODE": {
"value": "JFK",
"name": "AIRPORTCODE"
}
}
}
}
},
"response": {
"version": "1.0",
"sessionAttributes": {},
"response": {
"shouldEndSession": true,
"outputSpeech": {
"type": "SSML",
"ssml": "<speak>The weather at JFK is 68 and sunny.</speak>"
}
}
}
}
Sample cURL
curl -X POST -H "Content-Type: application/json" \
-d '{"event":{"version":"1.0","session":{"new":false,"sessionId":"amzn1.echo-api.session.abcde1b7-aee0-41e6-8192-f6faaed9f5ef","application":{"applicationId":"amzn1.echo-sdk-ams.app.123456-d0ed-0000-ad00-000000d00ebe"},"attributes":{},"user":{"userId":"amzn1.account.AM12347HF3FAM1B261HK7FFM3A2"}},"request":{"type":"IntentRequest","requestId":"amzn1.echo-api.request.6919844a-733e-4e89-893a-fdcb77e2ef0d","timestamp":"2015-05-13T12:34:56Z","intent":{"name":"airportinfo","slots":{"AIRPORTCODE":{"value":"JFK","name":"AIRPORTCODE"}}}}},"response":{"version":"1.0","sessionAttributes":{},"response":{"shouldEndSession":true,"outputSpeech":{"type":"SSML","ssml":"The weather at JFK is 68 and sunny."}}}}' \
'https://tracker.dashbot.io/track?platform=alexa&v=11.1.0-rest&type=outgoing&apiKey=API_KEY_HERE'
Note
This is just an example — we accept any rich media that Alexa accepts.
3. Outbound Intents (Optional)
With Intents, you can roll up similar messages your bot sends to quickly see the combined metrics.
Define Intent
{
"name": "WEATHER_RESPONSE",
"inputs": [
{
"name": "forecast",
"value": "68 and sunny"
}
]
}
Append the Intent JSON to the original message
{
"event": {
"version": "1.0",
"session": {
"new": false,
"sessionId": "amzn1.echo-api.session.abcde1b7-aee0-41e6-8192-f6faaed9f5ef",
"application": {
"applicationId": "amzn1.echo-sdk-ams.app.123456-d0ed-0000-ad00-000000d00ebe"
},
"attributes": {},
"user": {
"userId": "amzn1.account.AM12347HF3FAM1B261HK7FFM3A2"
}
},
"request": {
"type": "IntentRequest",
"requestId": "amzn1.echo-api.request.6919844a-733e-4e89-893a-fdcb77e2ef0d",
"timestamp": "2015-05-13T12:34:56Z",
"intent": {
"name": "airportinfo",
"slots": {
"AIRPORTCODE": {
"value": "JFK",
"name": "AIRPORTCODE"
}
}
}
}
},
"response": {
"intent": {
"name": "WEATHER_RESPONSE",
"inputs": [
{
"name": "forecast",
"value": "68 and sunny"
}
]
},
"version": "1.0",
"sessionAttributes": {},
"response": {
"shouldEndSession": true,
"outputSpeech": {
"type": "SSML",
"ssml": "<speak>The weather at JFK is 68 and sunny.</speak>"
}
}
}
}
Post the complete message to Dashbot
https://tracker.dashbot.io/track?platform=alexa&v=11.1.0-rest&type=outgoing&apiKey=API_KEY_HERE
Make sure to set the 'Content-Type' header to 'application/json'
Sample cURL
curl -X POST -H "Content-Type: application/json" \
-d '{"event":{"version":"1.0","session":{"new":false,"sessionId":"amzn1.echo-api.session.abcde1b7-aee0-41e6-8192-f6faaed9f5ef","application":{"applicationId":"amzn1.echo-sdk-ams.app.123456-d0ed-0000-ad00-000000d00ebe"},"attributes":{},"user":{"userId":"amzn1.account.AM12347HF3FAM1B261HK7FFM3A2"}},"request":{"type":"IntentRequest","requestId":"amzn1.echo-api.request.6919844a-733e-4e89-893a-fdcb77e2ef0d","timestamp":"2015-05-13T12:34:56Z","intent":{"name":"airportinfo","slots":{"AIRPORTCODE":{"value":"JFK","name":"AIRPORTCODE"}}}}},"response":{"intent":{"name":"WEATHER_RESPONSE","inputs":[{"name":"forecast","value":"68 and sunny"}]},"version":"1.0","sessionAttributes":{},"response":{"shouldEndSession":true,"outputSpeech":{"type":"SSML","ssml":"The weather at JFK is 68 and sunny."}}}}' \
'https://tracker.dashbot.io/track?platform=alexa&v=11.1.0-rest&type=outgoing&apiKey=API_KEY_HERE'
Example
View a complete example.