services/natural_language_understanding/v1.js
function NLUNode (config) {
    RED.nodes.createNode(this, config);
    var node = this;

    this.on('input', function (msg) {
      var message = '',
        options = {};

      node.status({});

      username = sUsername || this.credentials.username;
      password = sPassword || this.credentials.password;
      apikey = sApikey || this.credentials.apikey;

      endpoint = sEndpoint;
      if ((!config['default-endpoint']) && config['service-endpoint']) {
        endpoint = config['service-endpoint'];
      }

      initialCheck(username, password, apikey)
        .then(function(){
          return payloadCheck(msg, options);
        })
        .then(function(){
          return checkAdditonalMsgOptions(msg, options);
        })
        .then(function(){
          return checkFeatureRequest(config, options);
        })
        .then(function(){
          return checkFeatureOptions(msg, config, options);
        })
        .then(function(){
          return checkNonFeatureOptions(config, options);
        })
        .then(function(){
          node.status({fill:'blue', shape:'dot', text:'requesting'});
          return invokeService(options);
        })
        .then(function(data){
          msg.features = data;
          node.send(msg);
          node.status({});
        })
        .catch(function(err){
          reportError(node,msg,err);
        });

    });
  }
function NLUNode (config) {
    RED.nodes.createNode(this, config);
    var node = this;

    this.on('input', function (msg) {
      var message = '',
        options = {};

      node.status({});

      username = sUsername || this.credentials.username;
      password = sPassword || this.credentials.password;
      apikey = sApikey || this.credentials.apikey;

      endpoint = sEndpoint;
      if ((!config['default-endpoint']) && config['service-endpoint']) {
        endpoint = config['service-endpoint'];
      }

      initialCheck(username, password, apikey)
        .then(function(){
          return payloadCheck(msg, options);
        })
        .then(function(){
          return checkAdditonalMsgOptions(msg, options);
        })
        .then(function(){
          return checkFeatureRequest(config, options);
        })
        .then(function(){
          return checkFeatureOptions(msg, config, options);
        })
        .then(function(){
          return checkNonFeatureOptions(config, options);
        })
        .then(function(){
          node.status({fill:'blue', shape:'dot', text:'requesting'});
          return invokeService(options);
        })
        .then(function(data){
          msg.features = data;
          node.send(msg);
          node.status({});
        })
        .catch(function(err){
          reportError(node,msg,err);
        });

    });
  }
function NLUNode ( config ) { RED . nodes . createNode ( this , config ) ; var node = this ; this . on ( 'input' , function ( msg ) { var message = '' , options = { } ; node . status ( { } ) ; username = sUsername || this . credentials . username ; password = sPassword || this . credentials . password ; apikey = sApikey || this . credentials . apikey ; endpoint = sEndpoint ; if ( ( ! config [ 'default-endpoint' ] ) && config [ 'service-endpoint' ] ) { endpoint = config [ 'service-endpoint' ] ; } initialCheck ( username , password , apikey ) . then ( function ( ) { return payloadCheck ( msg , options ) ; } ) . then ( function ( ) { return checkAdditonalMsgOptions ( msg , options ) ; } ) . then ( function ( ) { return checkFeatureRequest ( config , options ) ; } ) . then ( function ( ) { return checkFeatureOptions ( msg , config , options ) ; } ) . then ( function ( ) { return checkNonFeatureOptions ( config , options ) ; } ) . then ( function ( ) { node . status ( { fill : 'blue' , shape : 'dot' , text : 'requesting' } ) ; return invokeService ( options ) ; } ) . then ( function ( data ) { msg . features = data ; node . send ( msg ) ; node . status ( { } ) ; } ) . catch ( function ( err ) { reportError ( node , msg , err ) ; } ) ; } ) ; }
This is the Natural Language Understanding Node
This is the Natural Language Understanding Node