services/dialog/v1.js
function performDeleteAll(node,dialog,msg) {

    node.status({fill:'blue', shape:'dot', text:'requesting Delete All dialogs'});   
    dialog.getDialogs({}, function(err, dialogs){
      node.status({});
      if (err) {
          node.status({fill:'red', shape:'ring', text:'Delete All : call to getDialogs service failed'});
          node.error(err, msg);   
        } else {
          // Array to hold async tasks
          var asyncTasks = [];
          var nb_todelete = dialogs.dialogs.length;
          var nbdeleted = 0;
          dialogs.dialogs.forEach(function (aDialog) {

              asyncTasks.push(function (cb) {
                var parms = {};
                parms.dialog_id=aDialog.dialog_id;;
                dialog.deleteDialog(parms, function(err, dialog_data){
                node.status({});
                if (err) {
                    node.error(err, msg);
                    console.log('Error with the removal of Dialog ID '+parms.dialog_id +' : ' +  err);
                  } else {
                    console.log('Dialog ID '+ aDialog.dialog_id + ' deleted successfully.');
                    nbdeleted++;
                  }
                  cb();
                });  
              });
          });

        } // else

        async.parallel(asyncTasks, function(){
          // All tasks are done now
          console.log('Deleted ' + nbdeleted + ' dialog objects on ' + nb_todelete );
          if (nbdeleted==nb_todelete)
            msg.payload = 'All Dialogs have been deleted';
          else
            msg.payload = 'Some Dialogs could have not been deleted; See node-RED log for errors.';
          console.log(msg.payload);
          node.send(msg);            
        });

      });
  
    }
function performDeleteAll(node,dialog,msg) {

    node.status({fill:'blue', shape:'dot', text:'requesting Delete All dialogs'});   
    dialog.getDialogs({}, function(err, dialogs){
      node.status({});
      if (err) {
          node.status({fill:'red', shape:'ring', text:'Delete All : call to getDialogs service failed'});
          node.error(err, msg);   
        } else {
          // Array to hold async tasks
          var asyncTasks = [];
          var nb_todelete = dialogs.dialogs.length;
          var nbdeleted = 0;
          dialogs.dialogs.forEach(function (aDialog) {

              asyncTasks.push(function (cb) {
                var parms = {};
                parms.dialog_id=aDialog.dialog_id;;
                dialog.deleteDialog(parms, function(err, dialog_data){
                node.status({});
                if (err) {
                    node.error(err, msg);
                    console.log('Error with the removal of Dialog ID '+parms.dialog_id +' : ' +  err);
                  } else {
                    console.log('Dialog ID '+ aDialog.dialog_id + ' deleted successfully.');
                    nbdeleted++;
                  }
                  cb();
                });  
              });
          });

        } // else

        async.parallel(asyncTasks, function(){
          // All tasks are done now
          console.log('Deleted ' + nbdeleted + ' dialog objects on ' + nb_todelete );
          if (nbdeleted==nb_todelete)
            msg.payload = 'All Dialogs have been deleted';
          else
            msg.payload = 'Some Dialogs could have not been deleted; See node-RED log for errors.';
          console.log(msg.payload);
          node.send(msg);            
        });

      });
  
    }
function performDeleteAll ( node , dialog , msg ) { node . status ( { fill : 'blue' , shape : 'dot' , text : 'requesting Delete All dialogs' } ) ; dialog . getDialogs ( { } , function ( err , dialogs ) { node . status ( { } ) ; if ( err ) { node . status ( { fill : 'red' , shape : 'ring' , text : 'Delete All : call to getDialogs service failed' } ) ; node . error ( err , msg ) ; } else { // Array to hold async tasks var asyncTasks = [ ] ; var nb_todelete = dialogs . dialogs . length ; var nbdeleted = 0 ; dialogs . dialogs . forEach ( function ( aDialog ) { asyncTasks . push ( function ( cb ) { var parms = { } ; parms . dialog_id = aDialog . dialog_id ; ; dialog . deleteDialog ( parms , function ( err , dialog_data ) { node . status ( { } ) ; if ( err ) { node . error ( err , msg ) ; console . log ( 'Error with the removal of Dialog ID ' + parms . dialog_id + ' : ' + err ) ; } else { console . log ( 'Dialog ID ' + aDialog . dialog_id + ' deleted successfully.' ) ; nbdeleted ++ ; } cb ( ) ; } ) ; } ) ; } ) ; } // else async . parallel ( asyncTasks , function ( ) { // All tasks are done now console . log ( 'Deleted ' + nbdeleted + ' dialog objects on ' + nb_todelete ) ; if ( nbdeleted == nb_todelete ) msg . payload = 'All Dialogs have been deleted' ; else msg . payload = 'Some Dialogs could have not been deleted; See node-RED log for errors.' ; console . log ( msg . payload ) ; node . send ( msg ) ; } ) ; } ) ; }
This function performs the operation to Delete ALL Dialogs
This function performs the operation to Delete ALL Dialogs