I have two speeches to select from for outputting in Alexa SDK e.g
const HI = 'Hi Trump';
const HELLO = 'Hello Trump';
I store the variable name in an array:
const speech = [HI, HELLO];
I process and get the index number of the speech I want to output. Now the problem is how to output the speech - 'Hello' in the following line of codes:
return handlerInput.responseBuilder
.speak($speech[1]);
},
You can output the array index as speech response by using template strings. Try the following:
return handlerInput.responseBuilder
.speak(`${speech[1]}`);
},