Skip to content

Commit a40e7f0

Browse files
author
Sreedhar Pamidiparthi
committed
Added More details confirmation
1 parent 4459ec6 commit a40e7f0

File tree

1 file changed

+21
-11
lines changed

1 file changed

+21
-11
lines changed

index.js

+21-11
Original file line numberDiff line numberDiff line change
@@ -53,23 +53,33 @@ var handlers = {
5353
var countryObj =JSON.parse(res.getBody('utf8'));
5454
console.log(countryObj);
5555
if(countryObj.length == 1){
56-
data = countryObj[0].name + " is from "+ countryObj[0].region + " region with "+ countryObj[0].capital + " as the capital city. It's currency is " +
57-
countryObj[0].currencies[0].name +". It has around "+countryObj[0].population+" in population.";
56+
data = countryObj[0].name + " is from "+ countryObj[0].region + " region with "+ countryObj[0].capital + " as the capital city.";
57+
// " It's currency is " + countryObj[0].currencies[0].name +". It has around "+countryObj[0].population+" in population.";
58+
this.attributes['countryName']=countryObj[0].name;
59+
this.attributes[countryObj[0].name]=countryObj[0];
60+
this.emit(':ask', data+ " Do you like to know more about "+countryObj[0].name+"?");
5861
} else if (countryObj.length >= 2){
5962

6063
data = "Found multiple matches with country name " +slotCountry + ". Here is the information for first two matches: "
61-
+ countryObj[0].name + " is from "+ countryObj[0].region + " region with "+ countryObj[0].capital + " as the capital city. It's currency is " +
62-
countryObj[0].currencies[0].name +". It has around "+countryObj[0].population+" in population."
64+
+ countryObj[0].name + " is from "+ countryObj[0].region + " region with "+ countryObj[0].capital + " as the capital city.";
6365

64-
+ "And, " + countryObj[1].name +
65-
" is from "+ countryObj[1].region + " region with "+ countryObj[1].capital + " as the capital city. It's currency is " +
66-
countryObj[1].currencies[0].name +". It has around "+countryObj[1].population+" in population.";
66+
+ " And, " + countryObj[1].name +
67+
" is from "+ countryObj[1].region + " region with "+ countryObj[1].capital + " as the capital city.";
68+
this.emit(':tell', data);
6769
}
6870
}
69-
var randomFact = data;
70-
//console.log("Output Text:" + randomFact);
71-
var speechOutput = randomFact;
72-
this.emit(':tellWithCard', speechOutput, SKILL_NAME, randomFact)
71+
},
72+
'AMAZON.NoIntent': function () {
73+
this.emit('AMAZON.StopIntent');
74+
},
75+
'AMAZON.YesIntent': function () {
76+
var countryName = this.attributes['countryName'];
77+
var countryDetails = this.attributes[countryName];
78+
79+
data = "Here is more about "+ countryName +". It's currency is " + countryDetails.currencies[0].name +". It has around "+countryDetails.population+" in population. Good bye !!";
80+
81+
this.emit(':tellWithCard', data, countryName, data);
82+
7383
},
7484
'AMAZON.HelpIntent': function () {
7585
var speechOutput = HELP_MESSAGE;

0 commit comments

Comments
 (0)