@@ -53,23 +53,33 @@ var handlers = {
53
53
var countryObj = JSON . parse ( res . getBody ( 'utf8' ) ) ;
54
54
console . log ( countryObj ) ;
55
55
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 + "?" ) ;
58
61
} else if ( countryObj . length >= 2 ) {
59
62
60
63
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." ;
63
65
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 ) ;
67
69
}
68
70
}
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
+
73
83
} ,
74
84
'AMAZON.HelpIntent' : function ( ) {
75
85
var speechOutput = HELP_MESSAGE ;
0 commit comments