-
Notifications
You must be signed in to change notification settings - Fork 0
/
chatstate.js
35 lines (30 loc) · 1.33 KB
/
chatstate.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
const chat = require('./chat')
const Student = require('./models/student')
const dataformat = require('./dataformat')
const desiree = chat.desiree
function handleResponse(response,session) {
const message = response.result.fulfillment.speech
if(message === 'start-second-collect') {
console.log("start second");
session.rawData = response.result.parameters
chat.sendToAPI('start-second-collection',session,function(data) {
session.socket.emit('message',chat.newMessage(data.result.fulfillment.speech))
})
return true
}
else if(message === 'finish-collect') {
session.rawData = Object.assign(session.rawData,response.result.parameters)
dataformat.formatDataForMLAndSave(session)
console.log(session.rawData)
session.socket.emit('message',chat.newMessage('Thanks you for helping us help you help us all! That\'s all the questions I have today.'));
setTimeout(function() {
session.socket.emit('message',chat.newMessage('Your info has been sent to the NSA (Node Server Application) and will be used by your advisor to help you improve your grades.'))
},1000)
setTimeout(function() {
session.socket.emit('message',chat.newMessage('Now that we are done, feel free to make small talk with me!'))
},2000)
return true
}
return false
}
module.exports.handleResponse = handleResponse