【发布时间】:2020-04-15 00:34:43
【问题描述】:
我正在编写一个按城市返回顶尖大学的 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 秒,技能会因为“请求的技能没有发送有效响应”而死亡。如何继续会话直到用户说停止?
谢谢
【问题讨论】:
标签: node.js alexa alexa-skill ask-sdk