Skip to content

Commit

Permalink
testing sentiment analysis
Browse files Browse the repository at this point in the history
  • Loading branch information
sjr765 committed Nov 9, 2018
1 parent 413ebf1 commit 65b754f
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 21 deletions.
36 changes: 18 additions & 18 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use strict'

// import toneAnalyzer from './toneAnalyzer'
import toneAnalyzer from './toneAnalyzer'

const PAGE_ACCESS_TOKEN = process.env.PAGE_ACCESS_TOKEN

Expand Down Expand Up @@ -33,23 +33,23 @@ app.post('/webhook', (req, res) => {
// pass the event to the appropriate handler function
if (webhook_event.message) {
//WATSON ANALYSIS
// const text = webhook_event.message
// const toneParams = {
// tone_input: {text: text},
// content_type: 'application/json'
// }

// toneAnalyzer.tone(toneParams, function(error, toneAnalysis) {
// if (error) {
// console.log(error)
// } else {
// console.log('======== TONE ANALYSIS FROM WATSON ============')
// console.log(JSON.stringify(toneAnalysis, null, 2))
// console.log(
// '======== END OF TONE ANALYSIS FROM WATSON ============'
// )
// }
// })
const text = webhook_event.message
const toneParams = {
tone_input: {text: text},
content_type: 'application/json'
}

toneAnalyzer.tone(toneParams, function(error, toneAnalysis) {
if (error) {
console.log(error)
} else {
console.log('======== TONE ANALYSIS FROM WATSON ============')
console.log(JSON.stringify(toneAnalysis, null, 2))
console.log(
'======== END OF TONE ANALYSIS FROM WATSON ============'
)
}
})
//handle message
handleMessage(sender_psid, webhook_event.message)
} else if (webhook_event.postback) {
Expand Down
5 changes: 2 additions & 3 deletions toneAnalyzer.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ let toneAnalyzer = new ToneAnalyzerV3({
// }
// })


module.exports{
module.exports = {
toneAnalyzer
}
}

0 comments on commit 65b754f

Please sign in to comment.