Dee*_*tia 5 alexa alexa-skill alexa-app
我正在为Alexa创建一个自定义技能.我想结束会议AMAZON.StopIntent.如何使用以下代码实现此目的?
const ExitHandler = {
canHandle(handlerInput) {
const request = handlerInput.requestEnvelope.request;
return request.type === 'IntentRequest'
&& (request.intent.name === 'AMAZON.StopIntent');
},
handle(handlerInput) {
return handlerInput.responseBuilder
.speak('bye!')
.reprompt('bye!')
.getResponse();
},
};
Run Code Online (Sandbox Code Playgroud)
Cic*_*mas 19
当响应JSON中的shouldEndSession标志设置为true 时,Alexa结束会话.
...
"shouldEndSession": true
...
Run Code Online (Sandbox Code Playgroud)
在您的响应构建器中,您可以尝试使用辅助函数withShouldEndSession(true)
return handlerInput.responseBuilder
.speak('bye!')
.withShouldEndSession(true)
.getResponse();
Run Code Online (Sandbox Code Playgroud)
在您的代码片段中,您只需删除重新提示行即可结束会话:
return handlerInput.responseBuilder
.speak('bye!')
.getResponse();
Run Code Online (Sandbox Code Playgroud)
所以下面建议的解决方案有效,但它是多余的:
return handlerInput.responseBuilder
.speak('bye!')
.withShouldEndSession(true)
.getResponse();
Run Code Online (Sandbox Code Playgroud)
当您想要保持会话打开而不重新提示时,上面的代码通常用于相反的情况:
return handlerInput.responseBuilder
.speak('bye!')
.withShouldEndSession(false)
.getResponse();
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
4132 次 |
| 最近记录: |