簡體   English   中英

HTTP / HTTPS GET請求Alexa技能-“響應無效” Lambda響應

[英]HTTP / HTTPS GET Request Alexa Skill - “The Response is Invalid” Lambda Response

我正在建立一種Alexa技能,該技能可以告訴用戶離Kaiser Permanente最近的醫院,診所或葯房。 當我使用三個關鍵字之一進行測試時,出現錯誤: The response is invalid.

給出無效的響應(不使用三個關鍵字中的任何一個)給我錯誤: The remote endpoint could not be called, or the response it returned was invalid.

我不知道如何找出問題所在或出處,因為我沒有得到有關該問題的任何詳細信息。

 function getWelcomeResponse(callback) { var speechOutput = "Welcome to the Kaiser Permanente Alexa Skill. Allow me to help you find the nearest Kaiser hospital, pharmacy, or clinic."; var reprompt = "Would you like me to help you find the nearest Kaiser hospital, pharmacy, or clinic?"; var header = "Kaiser Permanente Skill"; var shouldEndSession = false; var sessionAttributes = { "speechOutput" : speechOutput, "repromptText" : reprompt, }; callback(sessionAttributes, buildSpeechletResponse(header, speechOutput, reprompt, shouldEndSession)); } function handleGetKaiserBuildingIntent(intent, session, callback) { var buildingType = intent.slots.Building.value.toLowerCase(); var speechOutput = "We have an error fam."; if (buildingType != BLDG_TYPE.PHARMACY || buildingType != BLDG_TYPE.CLINIC || buildingType != BLDG_TYPE.HOSPITAL) { speechOutput = "Please try again. I can help you find the nearest Kaiser hospital, clinic, or pharmacy."; var repromptText = "Please try again. I can help you find the nearest Kaiser hospital, clinic, or pharmacy."; var header = "Error fam."; } else { getJSON(function(data) { if (data != "ERROR") { speechOutput = data; } callback(session.attributes, buildSpeechletResponseWithoutCard(speechOutput, "", true)); }, buildingType); } } function getJSON(callback, building) { request.get(url(building), function(error, response, body) { var d = JSON.parse(body); var result = d.list[0].contents.title; if (result != null) { callback(result); } else { callback("ERROR"); } }); } function url(building) { switch (building) { case BLDG_TYPE.HOSPITAL: return "http://xjzxdss0040x.dta.kp.org/search/cgi-bin/query-meta?v%3Aproject=kp-mg-facdir-project&v:sources=kp-mg-facdir-proximity&query=hospital&user_lat=37.928243&user_lon=-121.9700594&render.function=json-feed-display-brief&content-type=application-json"; break; case BLDG_TYPE.PHARMACY: return "http://xjzxdss0040x.dta.kp.org/search/cgi-bin/query-meta?v%3Aproject=kp-mg-facdir-project&v:sources=kp-mg-facdir-proximity&query=pharmacy&user_lat=37.928243&user_lon=-121.9700594&render.function=json-feed-display-brief&content-type=application-json"; break; case BLDG_TYPE.CLINIC: return "http://xjzxdss0040x.dta.kp.org/search/cgi-bin/query-meta?v%3Aproject=kp-mg-facdir-project&v:sources=kp-mg-facdir-proximity&query=clinic&user_lat=37.928243&user_lon=-121.9700594&render.function=json-feed-display-brief&content-type=application-json"; break; default: break; } } 

很難說您所提供的問題是什么。 可能是Lambda函數上傳不正確,或者您的JSON響應太大,因此達到了響應大小限制。 解決此問題的最佳開始是查看Cloudwatch中的錯誤日志,然后查看顯示的內容。

您還可以嘗試在GET請求返回時返回一個簡單的硬編碼字符串,以確保到目前為止所有內容均正常運行。 然后用響應中的數據替換硬編碼的字符串。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM