DocuSign Connector 1.0 Examples - Mule 4
This example shows how to create a DocuSign envelope. The example contains two flows:
-
The first flow provides a template for a user interface.
-
The second flow creates the DocuSign envelope.
Create the First Flow
The first flow provides a template for the user interface. To change the template used in the flow, select the Parse Template component and go to the Location field to update the location with the path of the desired template.
In this flow, you configure:
-
An HTTP Listener component
-
A Parse Template component
Configure HTTP Listener
Configure HTTP Listener to initiate a Mule flow when a call is made to the /
account path on localhost
, port 8081
.
This example uses variables for some field values. You can either:
-
Replace the variables with their values in the code.
-
Provide the values for each variable in a properties file and then refer to that file from the connector configuration.
If you don’t know how to use a properties file, see Configuring Property Placeholders.
To configure HTTP Listener:
-
Create a new Mule project in Studio.
-
In the Mule Palette view, search for
http
and select the Listener operation: -
Drag the Listener operation onto the canvas.
-
In the Listener configuration, click the Add icon next to the Connector configuration field to add a global element.
-
Click OK to accept the defaults.
-
Set the Path field to
/
.
Add the Parse Template Component
The Parse Template component creates a template for an HTML form (form.html
),
which is located in the main resources folder. The example uses this form to
convey information for creating an envelope.
-
From the Mule Palette view, search for
parse
and drag Core> Parse Template onto the canvas, next to HTTP Listener. -
Configure the following fields in the Publish properties window:
Field Value Display Name
Name for the component, such as
Parse Template
.Location
Location of the file, such as
form.html
.
Create the Second Flow
The second flow creates the DocuSign envelope. The status
, emailSubject
,
documents
, and recipients
(combined URI and recipient URI) parameters must be provided.
In this flow, you configure:
-
An HTTP Listener component
-
Logger component
-
Envelopes Post Envelopes operation
-
Transform Message component
-
A second Logger component
Configure HTTP Listener
Configure HTTP Listener to initiate a Mule flow when a call is made to the /
account path on localhost
, port 8081
.
This example uses variables for some field values. You can either:
-
Replace the variables with their values in the code.
-
Provide the values for each variable in a properties file and then refer to that file from the connector configuration.
If you don’t know how to use a properties file, see Configuring Property Placeholders.
To configure HTTP Listener:
-
Create a new Mule project in Studio.
-
In the Mule Palette view, search for
http
and select the Listener operation: -
Drag the Listener operation onto the canvas.
-
In the Listener configuration, click the Add icon next to the Connector configuration field to add a global element.
-
Click OK to accept the defaults.
-
Set the Path field to
/create-envelope
.
Add a Logger Component
Configure a Logger component to perform logging on the payload.
-
In the Mule Palette view, search for
logger
. -
Drag the Logger component onto the canvas, next to HTTP Listener.
-
Configure the following fields:
Field Value Display Name
Name for the logger, such as
Payload Passed To The Operation Logger
.Message
Enter
#[payload]
.Level
INFO (Default).
Add the Envelopes Post Envelopes Operation
The Envelopes Post Envelopes operation creates an envelope from the template.
-
Drag the Envelopes Post Envelopes operation onto the canvas, next to Logger.
-
In the Envelopes Post Envelopes configuration, click the Connector configuration dropdown and select Docusign_Connector_Config.
-
Configure the following fields in the Envelopes Post Envelopes properties window:
Field Value Account Id
${account.id}
.Body
payload
.
Add the Transform Message Component
The Transform Message component converts the input data from the template.
-
In the Mule Palette view, search for
transform message
. -
Drag the Transform Message component onto the canvas, next to Envelopes Post Envelopes.
-
In the Transform Message configuration, overlay the brackets in the Output section with this XML:
%dw 2.0 output application/json --- payload
Add the Second Logger Component
Configure a second Logger component to perform logging on the output of the Transform Message component.
-
In the Mule Palette view, search for
logger
. -
Drag the Logger component onto the canvas, next to Transform Message.
-
Configure the following fields:
Field Value Display Name
Name for the logger, such as
Logger
.Message
Enter
#[payload]
.Level
INFO (Default).
XML for This Example
Paste this code into the Studio XML editor to quickly load the flow for this example into your Mule app:
<?xml version="1.0" encoding="UTF-8"?>
<mule xmlns:http="http://www.mulesoft.org/schema/mule/http"
xmlns:ee="http://www.mulesoft.org/schema/mule/ee/core" xmlns:docusign="http://www.mulesoft.org/schema/mule/docusign"
xmlns="http://www.mulesoft.org/schema/mule/core"
xmlns:doc="http://www.mulesoft.org/schema/mule/documentation" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="
http://www.mulesoft.org/schema/mule/http http://www.mulesoft.org/schema/mule/http/current/mule-http.xsd http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd
http://www.mulesoft.org/schema/mule/docusign http://www.mulesoft.org/schema/mule/docusign/current/mule-docusign.xsd
http://www.mulesoft.org/schema/mule/ee/core http://www.mulesoft.org/schema/mule/ee/core/current/mule-ee.xsd">
<http:listener-config name="HTTP_Listener_config" doc:name="HTTP Listener config" doc:id="13c7085f-6573-41dc-aafd-d138f8a3e810" >
<http:listener-connection host="0.0.0.0" port="8081" />
</http:listener-config>
<docusign:config name="Docusign_Connector_Config" doc:name="Docusign Connector Config" doc:id="753c4be0-d78e-49f0-9018-9fca64fb7a97" >
<docusign:authorization-connection authorization="${authorization.api.key}" baseUri="https://demo.docusign.net/restapi"/>
</docusign:config>
<configuration-properties doc:name="Configuration properties" doc:id="b7c89d0f-30d4-4bfc-883a-de464b792f30" file="application.properties" />
<flow name="mule-docusign-template-flow" doc:id="1f8e9187-ea3d-4ddc-9451-70882461fa63" >
<http:listener doc:name="Listener" doc:id="79babbba-a26a-42d6-b853-4806daa23def" config-ref="HTTP_Listener_config" path="/demo"/>
<parse-template doc:name="Parse Template" doc:id="e7ff6b4d-7cbc-4c20-9983-8fd7ac4e01f2" location="form.html"/>
</flow>
<flow name="create-envelope-flow" doc:id="68aaae35-5c5d-4f05-beb8-b06dd3500e19" >
<http:listener doc:name="Listener" doc:id="f5584ab0-a5fa-4246-a074-75a8bbfa45f6" config-ref="HTTP_Listener_config" path="/create-envelope"/>
<logger level="INFO" doc:name="Payload Passed To The Operation Logger" doc:id="dcb42d11-f8fa-4fe3-a1dc-10d7ae877c8b" message="#[payload]"/>
<docusign:create-v21-accounts-envelopes-by-account-id doc:name="Envelopes Post Envelopes" doc:id="a000887e-7276-4d43-a741-ecbed4b65e39" config-ref="Docusign_Connector_Config" accountId="${account.id}"/>
<ee:transform doc:name="Transform Message" doc:id="6778ad8b-200f-4873-b60c-4b0068b39e1f" >
<ee:message >
<ee:set-payload ><![CDATA[%dw 2.0
output application/json
---
payload]]></ee:set-payload>
</ee:message>
</ee:transform>
<logger level="INFO" doc:name="Logger" doc:id="16de0607-ee97-45fb-8b18-139a8698bab4" message=">>> #[payload]"/>
</flow>
</mule>