Alexa SimpleCard内容不会更新

时间:2019-08-21 07:39:47

标签: node.js amazon-web-services aws-lambda alexa alexa-skill

我创建了Alexa技能,并希望添加对带有屏幕的设备的支持。我正在withSimpleCard()中使用responseBuilder来显示一些文本,在第一个请求中它可以工作,但是其他用法都没有改变。

我似乎无法找出问题所在。

    canHandle(handlerInput) {
        return handlerInput.requestEnvelope.request.type === 'LaunchRequest';
    },
    handle(handlerInput) {
        var reprompt = '';
        const speakOutput = 'Start';

        return handlerInput.responseBuilder
            .speak(speakOutput)
            .reprompt(reprompt)
            .withSimpleCard('Protokollaufnahme', speakOutput) \\this works
            .withShouldEndSession(false)
            .getResponse();
    },
};

const RecordHandler = {
    canHandle(handlerInput) {
        request = handlerInput.requestEnvelope.request;
        return handlerInput.requestEnvelope.request.type === 'IntentRequest' &&
            handlerInput.requestEnvelope.request.intent.name === 'RecordIntent';
    },
    handle(handlerInput) {

        var speakOutput = 'Aufnahme beendet';
        lastSaid = request.intent.slots.aufnahme.value;

        return handlerInput.responseBuilder
            .speak(speakOutput)
            .reprompt(reprompt)
            .withSimpleCard('Gesprochen: ', lastSaid). \\this doesn't
            .withShouldEndSession(false)
            .getResponse();
    },
};

launchRequestHandler的json输出如下:

    "body": {
        "version": "1.0",
        "response": {
            "outputSpeech": {
                "type": "SSML",
                "ssml": "<speak>Gestartet.</speak>"
            },
            "card": {
                "type": "Simple",
                "title": "Start",
                "content": "Gestartet."
            },
            "reprompt": {
                "outputSpeech": {
                    "type": "SSML",
                    "ssml": "<speak></speak>"
                }
            },
            "shouldEndSession": false,
            "type": "_DEFAULT_RESPONSE"
        },
        "sessionAttributes": {},
        "userAgent": "ask-node/2.5.1 Node/v10.16.0"
    }
}

第二个requestHandler

    "body": {
        "version": "1.0",
        "response": {
            "outputSpeech": {
                "type": "SSML",
                "ssml": "<speak>Aufnahme beendet</speak>"
            },
            "card": {
                "type": "Simple",
                "title": "Gesprochen: ",
                "content": "abc"
            },
            "reprompt": {
                "outputSpeech": {
                    "type": "SSML",
                    "ssml": "<speak>Fehler bei der Aufnahme. Bitte wiederhole.</speak>"
                }
            },
            "shouldEndSession": false,
            "type": "_DEFAULT_RESPONSE"
        },
        "sessionAttributes": {},
        "userAgent": "ask-node/2.5.1 Node/v10.16.0"
    }
}

0 个答案:

没有答案