DocuSign Connect with AWS S3 -Part Two

Thiwanka Wickramage
5 min readJan 29, 2019

Before Starting

In the part one of this tutorial we have created API Gateway, Lambda Function and also tested it successfully. If you have not read part one, please read part one and come back to this tutorial. In this article, we going to create and configure S3 bucket, write Lambda function to upload documents into the bucket and integrate with DocuSign. Okay, let’s start.

Create AWS S3 Bucket

Before creating S3 bucket…

What is S3 Bucket
Amazon S3 is cloud storage for the internet. To upload your data (photos, videos, documents etc.), you first create a bucket in one of the AWS Regions. You can then upload any number of objects to the bucket.

Okay then, To create S3 bucket go to the S3 Bucket Homepage and create a new bucket. There are a few steps need to follow but we are going to give a name and create a bucket. We will change other settings in the latter.

Give a bucket name as you wish, but here I gave the name as docusign-bucket.

Keep other things same as default.

As I mentioned earlier we don’t go through the other steps, for now, we will come back for them latter.

So just click the Create button in the left side bottom. Now we created a new S3 bucket.

For this tutorial, we are going to make our bucket accessible for the public. So we can skip the configuration part. To do that go to your bucket which we ware created.

Edit Bucket permission

Go to the permission tab and under the public access setting uncheck ACLs for this bucket. Then click save and it will prompt confirmation box, so type confirm and click confirm button.

Next thing is got the Access Control List and click Everyone on the left side, and check List Objects, and Write Objects from the right side. Click Save.

Okay, that’s it. Now our bucket is accessible for public. Now let’s jump into the DocuSign side.

Configuring DocuSign Connection

So in this section, we going to integrate our API Gateway and DocuSign application.

To do that go the DocuSign admin panel and under the Integration category, click on the connect link.

In that page, we are going to create a custom connection. To do that select the Custom option in the Add Configuration drop-down list.

Now we need to fill out Custom Configuration Settings details. First, you can give a name for the connection as you wish. Here I named it as S3 connection.
And the main thing is we need to give connection URL. From the DocuSign this URL going invoke when the configured event happened.

This URL should be our AWS API Gateway endpoint which we ware created in this tutorial. They have provided so many options we can configure, but for this example, I used minimal option. Please refer the image below what I have configured here.

So other settings I kept as default. That’s all for configuration.

Finally, DocuSign will call this connection endpoint with the details xml file that include data we have configured above under the include category and also when this event happened as we configured above under the event category.

Example XML notification files: envelope creation, envelope completion.

Okay great. We have configured DocuSign and S3 bucket. Next thing is we need to modify our Lambda function that we ware created in our part one tutorial.

Update Lambda Function

To update Lambda, go to AWS Lambda Homepage and click on the function that we ware created ( docusign-lambda-v1 ).

In this code snippet we going to extract data coming from the DocuSign web-hook. I just extract the data, you can write your own business logic full fill your requirement.

myWebhookActionFunction: async event => {
console.log('event .....', JSON.stringify(event));
try {
//parse xml data to json
const data = await xmlParseString(event);

// get sign document byte stream
const pdfBytes = data.DocuSignEnvelopeInformation.DocumentPDFs[0].DocumentPDF[0].PDFBytes[0];

// get the recipient statuses
const { RecipientStatuses, EnvelopeID } = data.DocuSignEnvelopeInformation.EnvelopeStatus[0];
// get all document sign users
const signerList = RecipientStatuses[0].RecipientStatus;
........ your own business logic and you can extract whatever the data you need form the web-hook payload ....

I don’t think code is much complex, so I’m not going to explain about the code.

That’s all. Now we can test the integration process, I’m going to use Postman to make Create and Send Envelope API request. I assume you have already setup DocuSign API development environment and familiar with these APIs.

If you are not, please go through this article — Setup DocuSign API Development Environment with Postman

Create and Send Envelope API POST Request

We got response status 201 Created. That’s mean request successfully completed. Now you can go to the S3 bucket and see documents are uploaded.

Uploaded documents in the S3 bucket

We are done. 🎉 👐

If you liked this post, don’t forget to share and follow.

In my next article I will explain How to secure your DocuSign webhook listener

🤝 Please Read My Other Articles

👉🏻 DocuSign Connect with AWS S3 -Part One
👉🏻
How to Secure Your DocuSign Webhook Listener
👉🏻
My Serverless deployment process Experience
👉🏻 Configure AWS Route 53, CloudFront and SSL Certificate

--

--