bottender-chatbase
Advanced tools
Comparing version 0.2.0 to 0.2.1
@@ -1,7 +0,12 @@ | ||
# 0.2.0 / 2017-12-07 | ||
0.2.1 / 2017-12-08 | ||
================== | ||
* [fix] Fix koa return next | ||
* [fix] Fix crash on some event types | ||
0.2.0 / 2017-12-07 | ||
================== | ||
* [new] Support koa middleware | ||
# 0.1.0 / 2017-12-05 | ||
0.1.0 / 2017-12-05 | ||
================== | ||
* [new] Support express middleware |
@@ -25,5 +25,25 @@ 'use strict'; | ||
req.body.entry.forEach(entry => { | ||
const { sender: { id }, message: { text } } = entry.messaging[0]; | ||
let messaging; | ||
if (entry.messaging) { | ||
messaging = entry.messaging[0]; | ||
} else if (entry.standby) { | ||
messaging = entry.standby[0]; | ||
} else { | ||
return; | ||
} | ||
chatbase.newMessage().setAsTypeUser().setUserId(id).setTimestamp(Date.now().toString()).setMessage(text).send().catch(console.error); | ||
const { id } = messaging.sender; | ||
let logMessage; | ||
if (messaging.message && messaging.message.text) { | ||
logMessage = `Text: ${messaging.message.text}`; | ||
} else if (messaging.message && messaging.message.quick_reply) { | ||
logMessage = `Quick Reply Payload: ${messaging.message.quick_reply.payload}`; | ||
} else if (messaging.postback) { | ||
logMessage = `Postback Payload: ${messaging.postback.payload}`; | ||
} else { | ||
return; | ||
} | ||
chatbase.newMessage().setAsTypeUser().setUserId(id).setTimestamp(Date.now().toString()).setMessage(logMessage).send().catch(console.error); | ||
}); | ||
@@ -30,0 +50,0 @@ |
@@ -25,9 +25,29 @@ 'use strict'; | ||
request.body.entry.forEach(entry => { | ||
const { sender: { id }, message: { text } } = entry.messaging[0]; | ||
let messaging; | ||
if (entry.messaging) { | ||
messaging = entry.messaging[0]; | ||
} else if (entry.standby) { | ||
messaging = entry.standby[0]; | ||
} else { | ||
return; | ||
} | ||
chatbase.newMessage().setAsTypeUser().setUserId(id).setTimestamp(Date.now().toString()).setMessage(text).send().catch(console.error); | ||
const { id } = messaging.sender; | ||
let logMessage; | ||
if (messaging.message && messaging.message.text) { | ||
logMessage = `Text: ${messaging.message.text}`; | ||
} else if (messaging.message && messaging.message.quick_reply) { | ||
logMessage = `Quick Reply Payload: ${messaging.message.quick_reply.payload}`; | ||
} else if (messaging.postback) { | ||
logMessage = `Postback Payload: ${messaging.postback.payload}`; | ||
} else { | ||
return; | ||
} | ||
chatbase.newMessage().setAsTypeUser().setUserId(id).setTimestamp(Date.now().toString()).setMessage(logMessage).send().catch(console.error); | ||
}); | ||
next(); | ||
return next(); | ||
}; | ||
} |
@@ -15,5 +15,14 @@ "use strict"; | ||
if (/graph\.facebook\.com.*\/me\/messages/.test(config.url)) { | ||
const { recipient: { id }, message: { text } } = JSON.parse(config.data); | ||
const messaging = JSON.parse(config.data); | ||
const { id } = messaging.recipient; | ||
let logMessage; | ||
chatbase.newMessage().setAsTypeAgent().setUserId(id).setTimestamp(Date.now().toString()).setMessage(text).send().catch(e => console.error(e)); | ||
// TODO: handle more message type? | ||
if (messaging.message && messaging.message.text) { | ||
logMessage = `Text: ${messaging.message.text}`; | ||
} else { | ||
return response; | ||
} | ||
chatbase.newMessage().setAsTypeAgent().setUserId(id).setTimestamp(Date.now().toString()).setMessage(logMessage).send().catch(e => console.error(e)); | ||
} | ||
@@ -20,0 +29,0 @@ |
@@ -9,3 +9,3 @@ { | ||
}, | ||
"version": "0.2.0", | ||
"version": "0.2.1", | ||
"main": "lib/index.js", | ||
@@ -12,0 +12,0 @@ "files": [ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
9660
103
0