node.js - Firebase Realtime database updated but still works with old value -
pre script: issue occurred earlier also, mysteriously got fixed on it's own 2 days later.
i using firebase , api.ai create updated firebase db in console importing json file. changed every key, every value.
this function fetching values:
function quotes_start(assistant) { //assistant.tell("end here"); //* console.log('quotes_start ---------- started'); var person = assistant.getargument(quotes_start_parameter); console.log("person " + person); const parameters = {}; parameters[quotes_start_parameter_person] = person; assistant.setcontext(quotes_start_parameter_context, 1, parameters); const businesspeople = ['author1', 'author2', 'author3', 'author4']; const rrr = businesspeople[math.floor(math.random() * (businesspeople.length - 1 + 1))]; console.log("part 2"); var c1 = ""; var c2 = ""; if (person == "anyone") { person = rrr; console.log("choosing random "+person); } const graph = know.child(person); //also tried using graph.once graph.on('value', snap => { const ffirst = snap.val(); console.log("first" + ffirst[0]); const qo = math.floor(math.random() * (ffirst[0] - 2 + 1)) + 2; c1 = ffirst[qo]; c2 = ffirst[1]; var simpleresponse = { speech: c2 + ' said "' + c1 + '"', displaytext: '"' + c1 + '" ' + c2 }; var richresponse = assistant.buildrichresponse(); richresponse.addsimpleresponse(simpleresponse); richresponse.addsimpleresponse('do want another?'); assistant.ask(richresponse); //*/ }); }
and these logs:
7:09:30.787 pm
typeerror: cannot read property '0' of null @ graph.on.snap (/user_code/index.js:122:41) @ /user_code/node_modules/firebase-admin/lib/database/database.js:126:791 @ ac (/user_code/node_modules/firebase-admin/lib/database/database.js:63:165) @ jf (/user_code/node_modules/firebase-admin/lib/database/database.js:126:215) @ kf (/user_code/node_modules/firebase-admin/lib/database/database.js:125:539) @ object.g (/user_code/node_modules/firebase-admin/lib/database/database.js:226:93) @ /user_code/node_modules/firebase-admin/lib/database/database.js:209:503 @ kh.h.ud (/user_code/node_modules/firebase-admin/lib/database/database.js:214:104) @ zg.ud (/user_code/node_modules/firebase-admin/lib/database/database.js:205:364) @ qg.xf (/user_code/node_modules/firebase-admin/lib/database/database.js:203:281)
7:09:30.787 pm
uncaught exception
7:09:30.785 pm
firebase warning: exception thrown user callback. typeerror: cannot read property '0' of null @ graph.on.snap (/user_code/index.js:122:41) @ /user_code/node_modules/firebase-admin/lib/database/database.js:126:791 @ ac (/user_code/node_modules/firebase-admin/lib/database/database.js:63:165) @ jf (/user_code/node_modules/firebase-admin/lib/database/database.js:126:215) @ kf (/user_code/node_modules/firebase-admin/lib/database/database.js:125:539) @ object.g (/user_code/node_modules/firebase-admin/lib/database/database.js:226:93) @ /user_code/node_modules/firebase-admin/lib/database/database.js:209:503 @ kh.h.ud (/user_code/node_modules/firebase-admin/lib/database/database.js:214:104) @ zg.ud (/user_code/node_modules/firebase-admin/lib/database/database.js:205:364) @ qg.xf (/user_code/node_modules/firebase-admin/lib/database/database.js:203:281)
7:09:30.239 pm
body: {"originalrequest":{"source":"google","version":"2","data":{"isinsandbox":true,"surface":{"capabilities":[{"name":"actions.capability.audio_output"},{"name":"actions.capability.screen_output"}]},"inputs":[{"rawinputs":[{"query":"tell bill gates","inputtype":"voice"}],"arguments":[{"rawtext":"tell bill gates","textvalue":"tell bill gates","name":"text"}],"intent":"actions.intent.text"}],"user":{"locale":"en-us","userid":"***"},"device":{},"conversation":{"conversationid":"1503063530856","type":"active","conversationtoken":"[\"quotes-start-followup\"]"}}},"id":"***","timestamp":"2017-08-18t13:39:27.966z","lang":"en","result":{"source":"agent","resolvedquery":"tell bill gates","speech":"","action":"quotes-start","actionincomplete":false,"parameters":{"person_all":"author86"},"contexts":[{"name":"actions_capability_screen_output","parameters":{"person_all.original":"bill gates","person_all":"author86"},"lifespan":0},{"name":"google_assistant_input_type_voice","parameters":{"person_all.original":"bill gates","person_all":"author86"},"lifespan":0},{"name":"actions_capability_audio_output","parameters":{"person_all.original":"bill gates","person_all":"author86"},"lifespan":0},{"name":"quotes-start-followup","parameters":{"person_all.original":"bill gates","person_all":"author86"},"lifespan":2}],"metadata":{"intentid":"***","webhookused":"true","webhookforslotfillingused":"false","nluresponsetime":877,"intentname":"quotes-start"},"fulfillment":{"speech":"","messages":[{"type":"simple_response","platform":"google","texttospeech":"ratan tata said \"i don't believe in taking right decisions. take decisions , make them right.\"","displaytext":"\"i don't believe in taking right decisions. take decisions , make them right.\" ratan tata"}]},"score":0.6399999856948853},"status":{"code":200,"errortype":"success"},"sessionid":"***"}
earlier using same structure different database working fine. unsure happening.
Comments
Post a Comment