亚马逊Alexa错误“响应无效”

时间:2017-02-28 05:52:03

标签: firebase firebase-realtime-database aws-lambda alexa-skills-kit

面对aws lambda和alexa的问题,我有aws lambda函数:

               function firebaseData(callback)
                {
                    if(firebase.apps.length == 0) {
                        firebase.initializeApp({
                       serviceAccount: "******",
                       databaseURL:"********"
                        });
                        }
                        var ref = firebase.database().ref();
                        var usersRef = ref.child('users');


                        usersRef.once('value').then(function (snap) {

                       snap.forEach(function(childSnapshot) {

                       var childKey = childSnapshot.val();
                       var contact = childKey.Contact;
                      firebase.database().goOffline();
                        callback(contact); 

                       });

                        });
                }

      **************************************************

         function getContactFromSession(intent, session, callback) {
                  const repromptText = null;
                  const sessionAttributes = {};
                  let shouldEndSession = false;

                  firebaseData(function (contact) {
                    let speechOutput = "amy's contact is " + contact;
                    callback(
                      sessionAttributes,
                      buildSpeechletResponse(intent.name, speechOutput, repromptText, shouldEndSession)
                     );
                  })    
                }

通过调用

中的firebaseData(function(contact){})来使用联系人值
getContactFromSession(intent, session, callback) using callback(
                      sessionAttributes,
                      buildSpeechletResponse(intent.name, speechOutput, repromptText, shouldEndSession)
                     );                  

将Alexa技能输出中的错误视为:

Unable to call remote endpoint or the response is invalid

回调可能有什么问题?无法理解。

0 个答案:

没有答案