简体   繁体   English

Alexa App Express在响应中缺少OutputSpeech

[英]Alexa App Express missing OutputSpeech in response

I'm trying to build an alexa app with the npm package "alexa-app". 我正在尝试使用npm包“ alexa-app”构建alexa应用。 I have written the following Intent. 我写了以下意图。

alexaApp.intent("MyIntent", {
    "slots": {},
    "utterances": ["Tell me a quote"]
},
function(request, response) {

    req('http://exampleUrl.com', function (error, res, body) {
        if (!error && res.statusCode == 200) {
            var obj = JSON.parse(body);
            var message = obj.value;
            response.say(message);

        }
    });


});

When I test my Skill the outputSpeech is missing and the service response looks like this. 当我测试我的技能时,缺少outputSpeech,服务响应如下所示。 Getting the data from the url works. 从url获取数据有效。

{ "version": "1.0", "response": { "shouldEndSession": true }, "sessionAttributes": {} }

If I try to use response.say() in the outer function I will get the correct service response like this but of course without the message. 如果我尝试在外部函数中使用response.say(),我将获得这样的正确服务响应,但是当然没有消息。 Can anybody help me please, to return the correct service response with my message? 有人可以帮我,以我的信息返回正确的服务回复吗?

{ "version": "1.0", "response": { "outputSpeech": { "type": "SSML", "ssml": "<speak></speak>" }, "shouldEndSession": true }, "sessionAttributes": {} }

you should add 您应该添加

response.send();

after

response.say(message);

通过使用Promises解决了该问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM