I am writing an alexa skill which returns top colleges by city. I want session and the skill to continue till the user says stop. The code for TopCollegesByCityIntentHandler which takes city name is as below:
const TopCollegesByCityIntentHandler = {
canHandle(handlerInput) {
return handlerInput.requestEnvelope.request.type === 'IntentRequest'
&& handlerInput.requestEnvelope.request.intent.name === 'TopCollegesByCity';
},
handle(handlerInput) {
console.log('handlerInput.requestEnvelope.request', JSON.stringify(handlerInput.requestEnvelope.request));
let speechText = '';
const cityName = handlerInput.requestEnvelope.request.intent.slots.cityName.value;
// logic to get top colleges by city name and modify speechText
speechText += 'To know top colleges in your city say, top colleges in your city. To stop say, stop.';
return handlerInput.responseBuilder
.speak(speechText)
.withSimpleCard('Top Colleges', speechText)
.withShouldEndSession(false)
.getResponse();
}
But if the user doesn't speak for more than 5-10 seconds, the skill dies by saying "the requested skill did not send a valid response". How do I continue the session till the user says stop ?
Thanks
You can not keep Alexa's mic open for more than 8 seconds.
However what I would suggest is to use the reprompt method, which would ask a question again if the user doesn't respond within the first 8 seconds.
Here is how it would look like