Alexa通过访问session.new检查是否启动了新会话

问题描述 投票:0回答:1

[这是Alexa发送到我的技能后端的数据。在后端代码中,我想测试会话是否是新会话,并且基于此信息,我想产生不同的输出。我尝试访问session.new,但是我不知道如何,到目前为止,我现在可以在网上找到有关它的任何信息。

This is the data that is being send by alexa to my skills backend

const { attributesManager } = handlerInput;
const requestAttributes = attributesManager.getRequestAttributes();
requestAttributes.session.new
//this leads to the error "cannot read property new of undefined"

const { attributesManager } = handlerInput;
const requestAttributes = attributesManager.getSessionAttributes();
sessionAttributes.session.new
//this leads to the same error
alexa
1个回答
0
投票

我终于发现,使用AttributesManager不可能做到这一点,因为这仅允许访问请求,会话和永久属性。但是session.new不属于这些。如果要检查Alexa会话是否为新会话,则必须使用所谓的RequestEnvelopeUtils。使用这些语句,可以使用以下语句访问会话是否为新会话。

(Alexa.isNewSession(handlerInput.requestEnvelope))>

© www.soinside.com 2019 - 2024. All rights reserved.