How to use the node-red-viseo-helper.getByString function in node-red-viseo-helper

To help you get started, we’ve selected a few node-red-viseo-helper examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github NGRP / node-red-contrib-viseo / node-red-contrib-dialogflow / node-dialogflow.js View on Github external
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({
github NGRP / node-red-contrib-viseo / node-red-contrib-nosql / node-handover.js View on Github external
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);
    });

}
github NGRP / node-red-contrib-viseo / node-red-contrib-log / node-log-xiti.js View on Github external
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);
}
github NGRP / node-red-contrib-viseo / node-red-contrib-log / node-log-xiti.js View on Github external
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);
}
github NGRP / node-red-contrib-viseo / node-red-contrib-inbenta / node-inbenta-request.js View on Github external
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); }
    }
}
github NGRP / node-red-contrib-viseo / archives / api-ai / server-api-ai.js View on Github external
const getMessageContext = (message) => {
    if (message === undefined) return;

    let uuid    = helper.getByString(message, _CONTEXT_KEY);
    let context = _CONTEXTS.get(uuid);
    if (!context) {
        context = {};
        let convId = helper.getByString(message, 'address.conversation.id');
              uuid = convId + '-' + uuidv4();
              helper.setByString(message, _CONTEXT_KEY, uuid);
        _CONTEXTS.set(uuid, context);
    }
    return context;
}
github NGRP / node-red-contrib-viseo / node-red-contrib-amazon / server-alexa.js View on Github external
const getMessageContext = (message) => {
    if (message === undefined) return;

    let uuid    = helper.getByString(message, _CONTEXT_KEY);
    let context = _CONTEXTS.get(uuid);
    if (!context) {
        context = {};
        let convId = helper.getByString(message, 'address.conversation.id');
              uuid = convId + '-' + uuidv4();
              helper.setByString(message, _CONTEXT_KEY, uuid);
        _CONTEXTS.set(uuid, context);
    }
    return context;
}
github NGRP / node-red-contrib-viseo / node-red-contrib-dialogflow / server-dialogflow.js View on Github external
const getMessageContext = (message) => {
    if (message === undefined) return;

    let uuid    = helper.getByString(message, _CONTEXT_KEY);
    let context = _CONTEXTS.get(uuid);
    if (!context) {
        context = {};
        let convId = helper.getByString(message, 'address.conversation.id');
              uuid = convId + '-' + uuidv4();
              helper.setByString(message, _CONTEXT_KEY, uuid);
        _CONTEXTS.set(uuid, context);
    }
    return context;
}
github NGRP / node-red-contrib-viseo / node-red-contrib-iadvize / server-iadvize.js View on Github external
const getMessageContext = message => {
  if (message === undefined) return;

  let uuid = helper.getByString(message, _CONTEXT_KEY);
  let context = _CONTEXTS.get(uuid);
  if (!context) {
    context = {};
    let convId = helper.getByString(message, "address.conversation.id");
    uuid = convId + "-" + uuidv4();
    helper.setByString(message, _CONTEXT_KEY, uuid);
    _CONTEXTS.set(uuid, context);
  }
  return context;
};
github NGRP / node-red-contrib-viseo / archives / api-ai / server-api-ai.js View on Github external
const getMessageContext = (message) => {
    if (message === undefined) return;

    let uuid    = helper.getByString(message, _CONTEXT_KEY);
    let context = _CONTEXTS.get(uuid);
    if (!context) {
        context = {};
        let convId = helper.getByString(message, 'address.conversation.id');
              uuid = convId + '-' + uuidv4();
              helper.setByString(message, _CONTEXT_KEY, uuid);
        _CONTEXTS.set(uuid, context);
    }
    return context;
}

node-red-viseo-helper

Utility libarary for Node-RED

Apache-2.0
Latest version published 10 months ago

Package Health Score

62 / 100
Full package analysis