Repository: connect-python-worker-aws
This is an example worker application for Connect webhook notification messages sent via the AWS SQS (Simple Queueing System).
This application receives DocuSign Connect messages from the queue and then processes them:
-
If the envelope is complete, the application uses a DocuSign JWT Grant token to retrieve the envelope's combined set of documents, and stores them in the
output
directory.For this example, the envelope must include an Envelope Custom Field named
Sales order.
The Sales order field is used to name the output file.
AWS has SQS SDK libraries for C#, Java, Node.js, Python, Ruby, C++, and Go.
First, install the Lambda listener on AWS and set up the SQS queue.
Then set up this code example to receive and process the messages received via the SQS queue.
Install the example
Connect listener for AWS
on AWS.
At the end of this step, you will have the
Queue URL
, Queue Region
and Enqueue url
that you need for the next step.
This example requires Python v3.6 or later. The SDK itself works with Python v2.7 or later.
-
Download or clone this repository. Then:
cd connect-python-worker-aws pip install docusign_esign # boto3 is the AWS Python SDK pip install boto3 # defusedxml is an XML parser with InfoSec fixes pip install defusedxml
-
Using AWS IAM, create an IAM
User
with access to your SQS queue. -
Configure the ds_config.ini file: ds_config.ini The application uses the OAuth JWT Grant flow.
If consent has not been granted to the application by the user, then the application provides a url that can be used to grant individual consent.
To enable individual consent: either add the URL https://www.docusign.com as a redirect URI for the Integration Key, or add a different URL and update the
oAuthConsentRedirectURI
setting in the ds_config.ini file. -
Creating the Integration Key Your DocuSign Integration Key must be configured for a JWT OAuth authentication flow:
- Create a public/private key pair for the key. Store the private key in a secure location. You can use a file or a key vault.
- The example requires the private key. Store the private key in the ds_config.ini file.
Note: the private key's second and subsequent lines need to have a space added at the beginning due to requirements from the Python configuration file parser. Example:
# private key string
# NOTE: the Python config file parser requires that you
# add a space at the beginning of the second and
# subsequent lines of the multiline key value:
DS_PRIVATE_KEY=-----BEGIN RSA PRIVATE KEY-----
N7b6a66DYU8/0BwXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
7lBHBbJcc76v+18XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
jCt15ZT4aux//2ZXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
....
PEHgznlGh/vUboCXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
-----END RSA PRIVATE KEY-----
python aws_worker.py
you can also right click on the file and choose the Run Python File in Terminal
option.
Configure a DocuSign Connect subscription to send notifications to the Cloud Function. Create / complete a DocuSign envelope. The envelope must include an Envelope Custom Field named "Sales order".
-
Check the Connect logs for feedback.
-
Check the console output of this app for log output.
-
Check the
output
directory to see if the envelope's combined documents and CoC were downloaded.For this code example, the envelope's documents will only be downloaded if the envelope is
complete
and includes aSales order
custom field.
Includes three types of testing:
-
SavingEnvelopeTest.cs allow you to send an envelope to your amazon sqs from the program. The envelope is saved at
output
directory although its status issent
. -
RunTest.cs divides into two types of tests, both submits tests for 8 hours and updates every hour about the amount of successes or failures that occurred in that hour, the differences between the two are:
few
- Submits 5 tests every hour.many
- Submits many tests every hour.
In order to run the tests you need to split the terminal in two inside Visual Studio Code, In the first terminal run the connect-csharp-worker-aws program. In the second terminal choose the wanted test. You can see above at Run the examples
part how the files can be run.
Submit support questions to StackOverflow. Use tag docusignapi
.
Contributions via Pull Requests are appreciated. All contributions must use the MIT License.
This repository uses the MIT license, see the LICENSE file.