I have a travel skill that gives me information on a country if it exists. If it does not exist. I want to call the Travel Intent error message but it gives me 'there was a problem with the requested skill's response' Here is the example dialogue below:
User: "Alexa open travel costs"
Skill: " Welcome to the travel costs guide. Tell me what country you are going to and I will tell you how much you need on average to spend on food and accommodation. "
User: "how much is it to go to Mauritius"
Skill: "There was a problem with the requested skill's response"
index.js
var Alexa = require('alexa-sdk');
const APP_ID = '';
const skillData = [
{
country: "FRANCE",
costs: "$175 is the average daily price for traveling in France. The average price of food for one day is $36. The average price of a hotel for a couple is $206"
},
{
country: "SPAIN",
costs: "$135 is the average daily price for traveling in Spain. The average price of food for one day is $32. The average price of a hotel for a couple is $118"
{
country: "IRELAND",
costs: "$125 is the average daily price for traveling in Ireland. The average price of food for one day is $36. The average price of a hotel for a couple is $122"
},
{
country: "HUNGARY",
costs: "$84 is the average daily price for traveling in Hungary. The average price of food for one day is $19. The average price of a hotel for a couple is $95"
},
{
country: "CANADA",
costs: "$127 is the average daily price for traveling in Canada. The average price of food for one day is $27. The average price of a hotel for a couple is $130"
},
{
country: "VIETNAM",
costs: "$41 is the average daily price for traveling in Vietnam. The average price of food for one day is $9.66. The average price of a hotel for a couple is $42"
}
];
var handlers = {
'LaunchRequest': function () {
this.emit(':askWithCard', 'Welcome to Travel Helper. Tell me what country your going to. I will tell you how much you need on average to spend on food and accommodation. ', 'Tell me what country your are going to and I will tell you much you need on average to spend on food and accomodation', 'Travel Helper Guide', 'What country are you going to? I will tell you much you need on average to spend on food and accomodation');
},
'TravelCosts': function() {
var countrySlot = this.event.request.intent.slots.country.value;
if(countrySlot === "undefined") {
this.emit(':tell', 'Sorry this does not exist');
} else {
this.emit(':tellWithCard', getSuggestion(skillData, 'country', countrySlot.toUpperCase()).costs, 'country','costs');
}
}
};
exports.handler = function(event, context){
var alexa = Alexa.handler(event, context);
alexa.registerHandlers(handlers);
alexa.execute();
};
function getSuggestion(data, propName, propValue) {
for (var i=0; i < data.length; i++) {
if (data[i][propName] == propValue) {
return data[i];
}
}
}
I am using the AMAZON.County slot.