我正在编写一个按城市返回顶尖大学的 alexa 技能。我希望会话和技能继续,直到用户说停止。TopCollegesByCityIntentHandler 采用城市名称的代码如下:
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();
}
但是如果用户不说话超过 5-10 秒,技能会因为“请求的技能没有发送有效的响应”而死亡。我如何继续会话直到用户说停止?
谢谢