-
Notifications
You must be signed in to change notification settings - Fork 107
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0fcb529
commit 7c0c4ec
Showing
7 changed files
with
802 additions
and
95 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
const listener = require("./listener"); | ||
|
||
const dialogflow = require("@tiledesk/tiledesk-dialogflow-connector"); | ||
const dialogflowRoute = dialogflow.router; | ||
|
||
|
||
|
||
|
||
|
||
module.exports = { listener: listener, dialogflowRoute: dialogflowRoute }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
const botEvent = require('../../event/botEvent'); | ||
var Faq_kb = require("../../models/faq_kb"); | ||
var winston = require('../../config/winston'); | ||
const df = require("@tiledesk/tiledesk-dialogflow-connector"); | ||
var configGlobal = require('../../config/global'); | ||
|
||
var port = process.env.PORT || '3000'; | ||
|
||
const BOT_DIALOGFLOW_ENDPOINT = process.env.BOT_DIALOGFLOW_ENDPOINT || "http://localhost:" + port+ "/modules/dialogflow"; | ||
winston.debug("BOT_DIALOGFLOW_ENDPOINT: " + BOT_DIALOGFLOW_ENDPOINT); | ||
|
||
// if (BOT_DIALOGFLOW_ENDPOINT) { | ||
winston.info("Dialogflow endpoint: " + BOT_DIALOGFLOW_ENDPOINT); | ||
// } else { | ||
// winston.info("Dialogflow endpoint not configured"); | ||
// } | ||
|
||
|
||
const apiUrl = process.env.API_URL || configGlobal.apiUrl; | ||
winston.info('Dialogflow apiUrl: '+ apiUrl); | ||
|
||
class Listener { | ||
|
||
listen(config) { | ||
|
||
winston.debug('dialogflow Listener listen'); | ||
|
||
var that = this; | ||
|
||
|
||
df.startApp( | ||
{ | ||
MONGODB_URI: config.databaseUri, | ||
API_ENDPOINT: apiUrl, | ||
log: process.env.DIALOGFLOW_LOG | ||
}, () => { | ||
winston.info("Dialogflow route successfully started."); | ||
} | ||
); | ||
|
||
botEvent.on('faqbot.create', function(bot) { | ||
if (BOT_DIALOGFLOW_ENDPOINT) { | ||
|
||
if (bot.type==="dialogflow") { | ||
// bot.url = BOT_DIALOGFLOW_ENDPOINT; | ||
|
||
Faq_kb.findByIdAndUpdate(bot.id, {"url":BOT_DIALOGFLOW_ENDPOINT}, { new: true, upsert: true }, function (err, savedFaq_kb) { | ||
|
||
// bot.save(function (err, savedFaq_kb) { | ||
if (err) { | ||
return winston.error('error saving faqkb dialogflow ', err) | ||
} | ||
winston.verbose('Saved faqkb dialogflow', savedFaq_kb.toObject()) | ||
}); | ||
} | ||
} | ||
}); | ||
|
||
} | ||
|
||
} | ||
|
||
var listener = new Listener(); | ||
|
||
|
||
module.exports = listener; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters