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
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
137 changes: 137 additions & 0 deletions BluePrismConnector.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,137 @@
var config = require("./config");
var botId = "st-007da037-67f9-55c3-bf93-6272ca639359"; //change this to link your bot
var botName = "BotName";
var soap = require('strong-soap').soap;
var sdk = require("./lib/sdk");

/*
* This is the function to invoke a BluePrism Process (using SOAP client service)
* In order to invoke the desired process successfully, that process must be exposed as a WebService from the BluePrism Studio.
*
* For more Information on "How to expose process luePrism Process as a WebService" visit the following link,
* https://usermanual.wiki/Pdf/Blue20Prism20User20Guide2020Web20Services.795353567/html
*
* Please Provide the credentials of the BluePrism Studio Account in Config.json
*/
function executeBlueprismRequest(requestId, blueprismRequest, callbacks) {

var url = blueprismRequest.url;
var endPoint = blueprismRequest.url;
if(!url.endsWith('?wsdl')){
url = url+"?wsdl";
}

if(endPoint.endsWith('?wsdl')){
endPoint = endPoint.split('?')[0];
}


return new Promise(function(resolve, reject) {
soap.createClient(url, function(err, client) {
if (err || !client) {
callbacks.on_failure(requestId, err);
}
else{
client.setEndpoint(endPoint);
client.setSecurity(new soap.BasicAuthSecurity(config.bluePrism.username, config.bluePrism.password));
client[blueprismRequest.operation](blueprismRequest.attributes || {}, function(err, result, rawResponse, soapHeader, rawRequest) {
if(err){
callbacks.on_failure(requestId, err);
}
callbacks.on_success(requestId, rawResponse);
})
}
});
});
}

/*
* Responds to the webhook asynchronously with the success flag.
*/
function onSuccess(requestId, result) {
sdk.getSavedData(requestId)
.then(function(data) {
console.log(result);
data.context.blueprismResponse = result;
data.context.successful = true;

sdk.respondToHook(data);
});
}

/*
* Responds to the webhook asynchronously with the Failure flag.
*/
function onFailure(requestId, err) {
sdk.getSavedData(requestId)
.then(function(data) {
data.context.successful = false;
data.context.blueprismResponse = err;
sdk.respondToHook(data);
});
}

//call executeBlueprismRequest with the requestId. This service is expected to respond asynchronously.
//'requestId' must be passed along all asynchronous flows, to allow the BotKit to respond
// back to the hook once the async process is completed.
function callBluePrism(requestId, blueprismRequest) {
executeBlueprismRequest(requestId, blueprismRequest, {
on_success : onSuccess,
on_failure : onFailure
});
}



module.exports = {
botId : botId,
botName : botName,

on_user_message : function(requestId, data, callback) {
if (data.message === "Hi") {
data.message = "Hello";
//Sends back 'Hello' to user.
return sdk.sendUserMessage(data, callback);
} else if(!data.agent_transfer){
//Forward the message to bot
return sdk.sendBotMessage(data, callback);
} else {
data.message = "Agent Message";
return sdk.sendUserMessage(data, callback);
}
},
on_bot_message : function(requestId, data, callback) {
if (data.message === 'hello') {
data.message = 'The Bot says hello!';
}
//Sends back the message to user

return sdk.sendUserMessage(data, callback);
},
on_agent_transfer : function(requestId, data, callback){
return callback(null, data);
},
on_event : function (requestId, data, callback) {
console.log("on_event --> Event : ", data.event);
return callback(null, data);
},
on_alert : function (requestId, data, callback) {
console.log("on_alert --> : ", data, data.message);
return sdk.sendAlertMessage(data, callback);
},
on_webhook : function(requestId, data, componentName, callback) {
/*The request to execute the BlluePrism Process from the Bot is received here.....
* the request data from the Bot is stored in "bluePrismRequest" which need to be sent
* through out the process of invoking Process.
*/
var context = data.context;
console.log(context.bluePrismRequest);
sdk.saveData(requestId, data)
.then(function() {
callBluePrism(requestId, context.bluePrismRequest);
callback(null, new sdk.AsyncResponse());
});

}

};
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,6 @@
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

Visit https://developer.kore.com/docs/bots/bot-builder/defining-bot-tasks/dialog-tasks/using-the-botkit-sdk/ for configuration instructions and API documentation.

BotKit SDK also includes Blue Prism Connector for integrating your Kore.ai bots with Blue Prism RPA Services. Visit
https://developer.kore.ai/docs/bots/sdks/botkit-sdk-tutorial-blue-prism/ for configuration instructions.
4 changes: 4 additions & 0 deletions config.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@
"appId": "test_app_id2"
}
},
"bluePrism":{
"username" : "username_of_BluePrism_Studio_Process_Developer_Account",
"password" : "xxxxxxxx"
},
"redis": {
"options": {
"host": "localhost",
Expand Down
18 changes: 18 additions & 0 deletions lib/app/routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,24 @@ function loadroutes(app) {

serviceHandler(req, res, sdk.runComponentHandler(botId, 'default', eventName, reqBody));
});

app.post(apiPrefix + '/sdk/blueprismConnector/:requestId', function(req, res) {
var reqBody = req.body;
var requestId = req.params.requestId;

sdk.getSavedData(requestId).then(function (data) {
console.log("Received hit to call back service : ", requestId);
if (data) {
data.context.ResponseFromBluePrism = reqBody;
sdk.respondToHook(data);
res.send({status:"OK"});
}
}).catch(function (err) {
console.error("no user id found: ", err.message);
res.send("No user id found " + err.message);
});

});
}

module.exports = {
Expand Down
1 change: 1 addition & 0 deletions node_modules/.bin/json2yaml

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

1 change: 1 addition & 0 deletions node_modules/.bin/mkdirp

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

1 change: 1 addition & 0 deletions node_modules/.bin/semver

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

1 change: 1 addition & 0 deletions node_modules/.bin/uuid

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

1 change: 1 addition & 0 deletions node_modules/.bin/which

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

1 change: 1 addition & 0 deletions node_modules/.bin/yaml2json

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

12 changes: 12 additions & 0 deletions node_modules/accept-language/.npmignore

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

24 changes: 24 additions & 0 deletions node_modules/accept-language/.vscode/launch.json

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

Loading