I'm trying to add my own responses to custom intents. The LaunchRequest text works, but other than the AMAZON.HelpIntent and other default intents, my own do not get recognized.
Intents:
{
"interactionModel": {
"languageModel": {
"invocationName": "my personal heartbeat",
"intents": [
{
"name": "AMAZON.FallbackIntent",
"samples": []
},
{
"name": "AMAZON.CancelIntent",
"samples": []
},
{
"name": "AMAZON.HelpIntent",
"samples": []
},
{
"name": "AMAZON.StopIntent",
"samples": []
},
{
"name": "start",
"slots": [],
"samples": [
"Talk to my personal heartbeat"
]
},
{
"name": "currentbpm",
"slots": [],
"samples": [
"what's my current BPM",
"how fast is my heart beating right now",
"How many beats per minute is my heart making at the moment"
]
}
],
"types": []
}
}
}
index.js (adapted example from the nodejs tutorial found here: https://github.com/alexa/skill-sample-nodejs-fact/blob/en-US/lambda/custom/index.js I added the CurrentBPM function and added it to the addRequestHandlers at the bottom. The intent name it looks to match is the currentbpm intent in the list above.
/* eslint-disable func-names */
/* eslint-disable no-console */
const Alexa = require('ask-sdk');
const GetNewFactHandler = {
canHandle(handlerInput) {
const request = handlerInput.requestEnvelope.request;
return request.type === 'LaunchRequest'
|| (request.type === 'IntentRequest'
&& request.intent.name === 'GetNewFactIntent');
},
handle(handlerInput) {
const speechOutput = "Welcome to your personal heart health monitor. What would you like to know?";
return handlerInput.responseBuilder
.speak(speechOutput)
.withSimpleCard(speechOutput)
.getResponse();
},
};
const CurrentBPMHandler = {
canHandle(handlerInput) {
const request = handlerInput.requestEnvelope.request;
return request.type === 'IntentRequest'
&& request.intent.name === 'currentbpm';
},
handle(handlerInput) {
return handlerInput.responseBuilder
.speak('seventy five bpm')
.reprompt('seventy five bpm')
.getResponse();
},
};
const HelpHandler = {
canHandle(handlerInput) {
const request = handlerInput.requestEnvelope.request;
return request.type === 'IntentRequest'
&& request.intent.name === 'AMAZON.HelpIntent';
},
handle(handlerInput) {
return handlerInput.responseBuilder
.speak(HELP_MESSAGE)
.reprompt(HELP_REPROMPT)
.getResponse();
},
};
const ExitHandler = {
canHandle(handlerInput) {
const request = handlerInput.requestEnvelope.request;
return request.type === 'IntentRequest'
&& (request.intent.name === 'AMAZON.CancelIntent'
|| request.intent.name === 'AMAZON.StopIntent');
},
handle(handlerInput) {
return handlerInput.responseBuilder
.speak(STOP_MESSAGE)
.getResponse();
},
};
const SessionEndedRequestHandler = {
canHandle(handlerInput) {
const request = handlerInput.requestEnvelope.request;
return request.type === 'SessionEndedRequest';
},
handle(handlerInput) {
console.log(`Session ended with reason: ${handlerInput.requestEnvelope.request.reason}`);
return handlerInput.responseBuilder.getResponse();
},
};
const ErrorHandler = {
canHandle() {
return true;
},
handle(handlerInput, error) {
console.log(`Error handled: ${error.message}`);
return handlerInput.responseBuilder
.speak('Sorry, an error occurred.')
.reprompt('Sorry, an error occurred.')
.getResponse();
},
};
const HELP_MESSAGE = 'You can say tell me a space fact, or, you can say exit... What can I help you with?';
const HELP_REPROMPT = 'What can I help you with?';
const STOP_MESSAGE = 'Goodbye!';
const skillBuilder = Alexa.SkillBuilders.standard();
exports.handler = skillBuilder
.addRequestHandlers(
GetNewFactHandler,
CurrentBPMHandler,
HelpHandler,
ExitHandler,
SessionEndedRequestHandler
)
.addErrorHandlers(ErrorHandler)
.lambda();
When I invoke the skill: 'Alexa start my personal heartbeat.' It does speak the welcome sentence from the script. But when I ask then 'how fast is my heart beating right now', it only responds 'Sorry, not sure' instead of speaking the hardcoded response.