Skip to content
Open
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# BotKit

Kore Bot Server SDK is set of libraries which gives you more control over the bots you build on Kore Bots platform. Once you build the Dialog task using Dialog Editor, you can subscribe to all the message and webhook events. You can easily add event handlers in the SDK and get the handle over the messages and webhook events. The SDK requires node.js (version 10 or above) to communicate between your server and the Kore.ai Bots Platform.
Kore Bot Server SDK is set of libraries which gives you more control over the bots you build on Kore Bots platform. Once you build the Dialog task using Dialog Editor, you can subscribe to all the message and webhook events. You can easily add event handlers in the SDK and get the handle over the messages and webhook events. The SDK requires node.js (version 12 or above) to communicate between your server and the Kore.ai Bots Platform.

Visit https://developer.kore.ai/docs/bots/sdks/using-the-botkit-sdk/ for configuration instructions and API documentation.
5 changes: 2 additions & 3 deletions app.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
require('./util').checkNodeVersion();
var sdk = require("./lib/sdk");
var Application = require("./lib/app");
var Server = require("./lib/server");
var sdk = require("./lib/sdk");
var config = require("./config");

var app = new Application(null, config);
var server = new Server(config, app);

sdk.checkNodeVersion();

server.start();

sdk.registerBot(require('./FindAFlight.js'));
Expand Down
11 changes: 6 additions & 5 deletions config.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@
},
"app": {
"apiPrefix" : "",
"url": "https://0ddf-122-174-183-138.ngrok-free.app"
"url": "http://localhost"
},
"validations": {
"leastNodeVersion": 10
"leastNodeVersion": 12
},
"credentials": {
"apikey": "tz4fhIiIPg6c1JHnP7tiZBtGfeCtCydlv6rbc6k4acw=",
"appId": "cs-9a909c58-c5a9-569d-aa7c-1f36f94b23ad",
"apikey": "test_api_key",
"appId": "test_app_id",
"st-67890":{
"apikey": "test_api_key2",
"appId": "test_app_id2"
Expand All @@ -28,7 +28,8 @@
"redis": {
"options": {
"host": "localhost",
"port": 6379
"port": 6379,
"legacyMode": true
},
"available": false
},
Expand Down
27 changes: 26 additions & 1 deletion lib/RedisClient.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,40 @@ function createClient (opts, cache_key) {

//use version of redis library passed by caller if provided
opts.redis = opts.redis || redis;

/*
var client = opts.redis.createClient(
opts.options.port,
opts.options.host,
opts.options);

//if errors like connection reset should not cause crash,
client.on('error', errorlistener);
*/
function getRedisConnectionString(redisCong) {
let connectionString = "redis://";
if (redisCong?.user && redisCong?.password) {
connectionString += redisCong?.user + ":" + redisCong?.password + "@";
}
connectionString += (redisCong?.host || "localhost") + ":";
connectionString += redisCong?.port || "6379";
return connectionString;
}
let url = getRedisConnectionString(opts.options);
const client = opts.redis.createClient({
url,
legacyMode: opts.options.legacyMode ?? true
});


client.connect((err) => {
if (err) {
errorlistener(err)
console.error('Error connecting to Redis:', err);
} else {
// Now you can execute Redis commands
}
});

if (typeof cache_key === 'string' && (redis_client_cache[cache_key] === undefined)) {
debug('caching redis client %s', cache_key);
redis_client_cache[cache_key] = client;
Expand Down
8 changes: 0 additions & 8 deletions lib/sdk/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -247,14 +247,6 @@ module.exports = {
return clearConversationSession(request)
.nodeify(callback);
},
checkNodeVersion : function(){
var clientNodeVersion = process.version.match(/^v(\d+\.\d+)/)[1];
if(clientNodeVersion < _.get(config, "validations.leastNodeVersion", 10)){
console.error("The BotKit SDK cannot be initiated. Please use the Node.js version 10.x or above.")
process.exit(78);
}
return;
},
closeConversationSession : function(request, callback) {
if (!request.clearConversationSessionUrl) {
throw new errors.InvalidArguments('close conversation session url is missing');
Expand Down
6 changes: 3 additions & 3 deletions node_modules/.package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading