Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 13 additions & 9 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,19 @@ function Witbot (witToken) {
// only consider the 1st outcome
if (res.outcomes && res.outcomes.length > 0) {
var outcome = res.outcomes[0]
var intent = outcome.intent
args.push(outcome)
if (intents._intents[intent]) {
intents._intents[intent].forEach(function (registration) {
if (!matched && outcome.confidence >= registration.confidence) {
matched = true
registration.fn.apply(undefined, args)
}
})
if(typeof outcome.entities.intent !== 'undefined'){
var intent = outcome.entities.intent[0].value
var confidence = outcome.entities.intent[0].confidence
args.push(outcome)
if (intents._intents[intent]) {
console.log('"' + intent + '" - intent found')
intents._intents[intent].forEach(function (registration) {
if (!matched && confidence >= registration.confidence) {
matched = true
registration.fn.apply(undefined, args)
}
})
}
} else if (intents._any) {
matched = true
intents._any.apply(undefined, args)
Expand Down