diff --git a/niceday-broker/index.js b/niceday-broker/index.js index e31a3d4..aec68bd 100644 --- a/niceday-broker/index.js +++ b/niceday-broker/index.js @@ -26,7 +26,11 @@ function requestRasa(text, userId, attachmentIds, callback) { xhr.open('POST', RASA_AGENT_URL, true); xhr.setRequestHeader('Content-Type', 'application/json'); xhr.onreadystatechange = callback; - const data = JSON.stringify({ sender: userId, message: text, metadata: {'attachmentIds': attachmentIds} }); + const data = JSON.stringify({ + sender: userId, + message: text, + metadata: { attachmentIds }, + }); xhr.send(data); } @@ -54,14 +58,14 @@ function onRasaResponse() { if (ENVIRONMENT === 'prod') { await sleep(i * MESSAGE_DELAY); } - var attachment = { + const attachment = { replyOfId: null, - attachmentIds: [] - } - if(message.hasOwnProperty('metadata')){ - attachment.attachmentIds = message.metadata + attachmentIds: [], + }; + if (message.hasOwn('metadata')) { + attachment.attachmentIds = message.metadata; } - sendMessage(message.text, parseInt(message.recipient_id, 10),attachment); + sendMessage(message.text, parseInt(message.recipient_id, 10), attachment); }); } else if (this.readyState === 4) { console.log('Something went wrong, status:', this.status, this.responseText); @@ -85,7 +89,6 @@ class MessageHandler { } } - function setup(therapistId, token) { // Setup connection chatSdk.init(SenseServerEnvironment.Alpha);