【问题标题】:Getting skill did not provide a valid response in alexa development获得技能在 Alexa 开发中没有提供有效的响应
【发布时间】:2021-04-18 04:01:26
【问题描述】:

我正在尝试创建一个 alexa 技能。在 lambda 函数测试中,我得到了正确的响应。但是在开发帐户测试中,我遇到了The requested skill did not provide a valid response 之类的错误。

Lambda 函数

exports.handler =function(event,context){
    // TODO implement
    
    var request = event.request;
    
    if(request.type === "LaunchRequest"){
        let options={};
        options.SpeachText = "Welcome to Wishing Skill.whom you want to wish?"
        options.repromptText = "whom you want to wish?"
        options.endSession = false;
        context.succeed(buildResponse(options));
        
    } else if(request.type === "IntentRequest"){
        let options={};
        if(request.intent.name === "HelloIntent"){
        let name=request.intent.slots.FirstName.value;
        options.SpeachText="Hello "+name+". ";
        options.SpeachText+=getWish();
        options.endSession=false;
        context.succeed(buildResponse(options));
        }else{
            context.fail("Unknown Intent");
        }
        
    }else if(request.type === "IntentRequest"){
        let options={};
        options.SpeachText="Thank you. ";
        context.succeed(buildResponse(options));
    }else{
        context.fail("Unknown Intent Type");
        
    }
};
function getWish(){
    let date= new Date();
    var hours= date.getUTCHours() - 8;
    if(hours<0){
        hours=hours+24;
    }
    if(hours<12){
        return "Good Morning.";
    }else if(hours<18){
        return "Good afternoon.";
    }else{
        return "Good evening.";
    }
};
function buildResponse(options){
    var response= {
      version: "1.0",
      response: {
        outputSpeech: {
          type: "PlainText",
          text: options.SpeachText
        },
        shouldEndSession: options.endSession
      }
    }
    if(options.repromptText){
         response.response.reprompt={
            outputSpeech: {
                type: "PlainText",
                text: options.repromptText
              }
        }
    }
    return response;
};



在测试响应中

Response
{
  "version": "1.0",
  "response": {
    "outputSpeech": {
      "type": "PlainText",
      "text": "Hello chandu. Good evening."
    },
    "shouldEndSession": false
  }
}

Function Logs
START RequestId: d05e0869-495f-471b-9c51-3693badd2690 Version: $LATEST
END RequestId: d05e0869-495f-471b-9c51-3693badd2690
REPORT RequestId: d05e0869-495f-471b-9c51-3693badd2690  Duration: 18.85 ms  Billed Duration: 19 ms  Memory Size: 128 MB Max Memory Used: 65 MB  Init Duration: 126.07 ms

Request ID
d05e0869-495f-471b-9c51-3693badd2690

但是当我在开发者帐户中尝试时,它给出了The requested skill did not provide a valid response

reference image

请帮我解答。提前谢谢你。

【问题讨论】:

    标签: aws-lambda alexa


    【解决方案1】:

    在给出我的建议之前,我必须问你一个问题: 为什么要在响应之外创建重新提示语音部分然后添加它? 我只是在创建响应时添加该部分。此外,我在响应 json 中添加了更多元素,以使其对用户更具吸引力。卡片元素提供 Alexa 设备的视觉响应(如果它有屏幕)。

    function buildSpeechletResponseImage() {
    return {
        outputSpeech: {
            type: "PlainText",
            text: "Hello"
        },
        card: {
            type: 'Standard',
            text: "Hellooo",
            image: {
                "smallImageUrl": String("your-image-url.jpg"),
                "largeImageUrl": String("your-image-url.jpg")
            }
        },
        reprompt: {
            outputSpeech: {
                type: 'PlainText',
                text: 'Session will end soon'
            }
        },
        shouldEndSession: false
    };
    

    }

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2023-01-02
      • 1970-01-01
      • 2018-04-21
      • 2020-07-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-01-23
      相关资源
      最近更新 更多