Last active
February 18, 2018 11:47
-
-
Save shyampurk/e890d727bfb035c159dac35fe9e02696 to your computer and use it in GitHub Desktop.
Watson-NLC-EventFeedback
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
db.get(request.message.userMessage).then((database_value)=>{ | |
console.log("FETCHED DATABASE VALUE",database_value); | |
var feedback = request.message.userMessage; // Extract the feedback from the incoming Message. | |
fetchUserFeedback(feedback); | |
console.log(request.message); | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
xhr.fetch(url).then((url_fetched_data) =>{ | |
var fetched_message_body = JSON.parse(url_fetched_data.body); | |
var top_class = fetched_message_body.top_class; | |
console.log("FETCHED CLASS FOR RECEIVED FEEDBACK --> ",top_class); | |
console.log(fetched_message_body); | |
// Preparing Object with the Classified Class | |
message = {"feedbackClass":top_class}; | |
// Calling the broadcast function to send to message(Classified Class) back to the client | |
broadcastMessage(pubchannel,message); | |
// Storing the Prepared Object with to the Database with feedback as key. | |
db.set(feedback,message); | |
}) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function broadcastMessage(pubchannel,message){ | |
// Broadcasting the Message back to the page with Classified class. | |
pubnub.publish({ | |
channel : pubchannel, | |
message : message, | |
callback : function(e) { | |
console.log( "SUCCESS!", e ); | |
}, | |
error : function(e) { | |
console.log( "FAILED! RETRY PUBLISH!", e ); | |
} | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment