This Alexa skill provides information about paperback or online books.This is just an example, not the real thing. So, here's an example User: "Alexa, find the best book with one author." Alexa: "OK!, here's the book blah blah." Alexa: "Would you like to hear this again?" User: "Yes!" Alexa: repeat the same information. I want to know how I can implement the code to make Alexa answer to that yes/no question and repeat what was said. I've done an extensive research about this but I still can't understand. Btw I'm new to this.
'booksIntent': function () {
var speechOutput = '';
var speechReprompt = '';
var sourceSlot = resolveCanonical(this.event.request.intent.slots.source);
console.log('User requested source: ' + sourceSlot);
var authorSlot = resolveCanonical(this.event.request.intent.slots.author);
console.log('User requested author: ' + authorSlot);
var sources = {
'basic book' : {
'one author' : "Blah blah one author",
'two authors' : "Blah blah two authors",
'multiple authors' : "blah blah multiple authors"
},
'basic electronic' : {
'one author' : "Blah blah...some electronic information"
},
}
var authors = [
'one author',
'two authors',
'multiple authors'
];
var source =sourceSlot.toLowerCase();
if(sourceSlot && sources[source]){
var standardSource = '';
var author = 'one author'; //default author choice
if(authorSlot && author.indexOf(authorSlot) - 1){
author = authorSlot;
}
var getSource = sources[source][author];
speechOutput = 'Ok! ' + getSource;
speechReprompt= 'Would you like to hear this again?'; //I want the user to answer with a yes or no and the program to respond accordingly.
}
else{
speechOutput = 'Sorry, the information you asked is not supported yet'
speechReprompt = 'I support: this and that!'
}
this.emit(":ask", speechOutput, speechReprompt)
},