Skip to content
Nikhil Mashettiwar edited this page Jun 25, 2015 · 12 revisions

Welcome to the DocuSign Node Client wiki!

Getting Started

var docusign = require('docusign');
var async = require('async');


var integratorKey 		        = "***", //Integrator Key associated with your DocuSign Integration
		email 		        = "***", //Email for your DocuSign Account
		password	        = "***", //Password for your DocuSign Account
		docusignEnv		= "***", //DocuSign Environment generally demo for testing purposes
		fullName		= "***", //Recipient's Full Name
		recipientEmail		= "***", //Recipient's Email
		templateId		= "***", //ID of the Template you with to create the Envelope with
		templateRoleName	= "***"; //Role Name of the Template

var templateRoles = [{
	email: email,
	name: fullName,
	roleName: tempalteRoleName,
}]

async.waterfall([

	function init(next){
		docusign.init(integratorKey, docusignEnv, debug, function(response){
			if(response.message === 'succesfully initialized'){
				next(null);
			} else {
				return;
			}
		});
	},

	function createClient(next){
		docusign.client(email, password, function(response){
			if('error' in response){
				console.log('Error: ' + response.error);
				return;
			}
			next(null, response);
		});
	},

	function sendTemplate(client, next){
      client.envelopes.sendEnvelope('Sent from a Template', templateId, templateRoles, function(err, response){
        if(response.error){
      	  console.log('Error: ' + response.error);
      	  return;
        }
        console.log('The envelope information of the created envelope is: \n' + JSON.stringify(response));
        next(null, client);
      });
    },

    function logOut(client, next){
      client.logOut(function(err, response){
        if(!err){
      	  next(null);	
        } else {
      	  console.log(err);
        }
      });
    },

]);
Clone this wiki locally