Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
else {
// ----> QUERY : DETECT AN INTENT
let session = config.session || "user.id",
language = config.language || "en",
text = config.text || "payload";
if (config.languageType !== 'str') {
let loc = (config.languageType === 'global') ? node.context().global : data;
language = helper.getByString(loc, language); }
if (config.sessionType !== 'str') {
let loc = (config.sessionType === 'global') ? node.context().global : data;
session = helper.getByString(loc, session); }
if (config.textType !== 'str') {
let loc = (config.textType === 'global') ? node.context().global : data;
text = helper.getByString(loc, text); }
if (version === "v2") { // VERSION 2
try {
config.tokenv2.authenticate((client, token) => {
let key = token.value,
sessionPath = "projects/" + config.tokenv2.cred.project_id + "/agent/sessions/" + session;
let req = {
method: "POST",
uri: "https://dialogflow.googleapis.com/v2beta1/" + sessionPath + ":detectIntent",
headers: {
'Authorization': 'Bearer ' + key,
'Content-Type': 'application/json; charset=utf-8'
},
body: JSON.stringify({
const remove = (node, data, config) => {
let dbKey = (config.keyType === "str") ? config.key : helper.getByString(data, config.key, config.key);
node.server.databaseManager.remove({ id:dbKey}, data, config, function(err, data, result) {
if (err) node.error(err);
node.send(data);
});
}
const input = (node, data, config) => {
let now = new Date();
let pageId = (config.pageIdType === "msg") ? helper.getByString(data, config.pageId) : config.pageId;
let siteId = (config.siteIdType === "msg") ? helper.getByString(data, config.siteId) : config.siteId;
let url = 'http://logv2.xiti.com/hit.xiti' + '?s=' + siteId + '&p=' + pageId
+ '&hl='+now.getHours()+'x'+now.getMinutes()+'x'+now.getSeconds();
request({ 'url': url }, function (err, response, body) {
if (err) node.error(err);
});
node.send(data);
}
const input = (node, data, config) => {
let now = new Date();
let pageId = (config.pageIdType === "msg") ? helper.getByString(data, config.pageId) : config.pageId;
let siteId = (config.siteIdType === "msg") ? helper.getByString(data, config.siteId) : config.siteId;
let url = 'http://logv2.xiti.com/hit.xiti' + '?s=' + siteId + '&p=' + pageId
+ '&hl='+now.getHours()+'x'+now.getMinutes()+'x'+now.getSeconds();
request({ 'url': url }, function (err, response, body) {
if (err) node.error(err);
});
node.send(data);
}
let json = await searchRequest(ibConfig + "/?idata=" + objectId + "&action=click");
data.payload = JSON.parse(json);
return node.send(data);
}
catch(err) { return node.error(err); }
}
else if (action === "rate") {
let rating = config.objectRating,
comment = config.objectComment,
ratingType = config.objectRatingType,
commentType = config.objectCommentType;
if (ratingType !== 'str') {
let loc = (ratingType === 'global') ? node.context().global : data;
rating = helper.getByString(loc, rating);
}
if (commentType !== 'str') {
let loc = (commentType === 'global') ? node.context().global : data;
comment = helper.getByString(loc, comment);
}
if (comment === undefined || typeof comment !== 'string') comment = '';
try {
let json = await searchRequest(ibConfig + "/?action=rating-content&idata=" + rating + comment);
data.payload = JSON.parse(json);
return node.send(data);
}
catch(err) { return node.error(err); }
}
}
let cb = (err, result) => {
if (err) return node.warn(err);
helper.setByString(data, config.output || 'payload', result)
node.send(data);
}
request(req, (err, response, body) => {
if (err) return node.error(err);
helper.setByString(data, output, JSON.parse(body));
return node.send(data);
});
}
rekognition[action](params = parameters, function (err, res) {
if (err) {
helper.setByString(data, config.output || "payload" , { error: err });
node.warn("AWS Lex: Error - postText - " + err);
return node.send(data);
}
helper.setByString(data, config.output || "payload" , res);
return node.send(data);
});
}
function cb(err, response) {
if (err) {
node.warn(err);
return node.send(data);
}
helper.setByString(data, output, response.json);
return node.send(data);
}
request(req, (err, response, body) => {
if (err) return node.error(err);
helper.setByString(data, output, (typeof body === "object") ? body : JSON.parse(body));
return node.send(data);
});
}