Skip to content

Commit 0d9b6e0

Browse files
Maestro updates (#99)
* Updating the web-form-config.json for the Web Forms example * updating workflow definition * Maestro changes * decoding final URL --------- Co-authored-by: inbargazit <[email protected]>
1 parent 480edb0 commit 0d9b6e0

File tree

5 files changed

+49
-220
lines changed

5 files changed

+49
-220
lines changed

examples/Maestro/eg001TriggerWorkflow.sh

Lines changed: 45 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,14 @@ if [[ $SHELL != *"bash"* ]]; then
77
echo "PROBLEM: Run these scripts from within the bash shell."
88
fi
99

10-
workflow_id=$(cat config/WORKFLOW_ID)
11-
if [ -z "$workflow_id" ]; then
10+
workflow_created=$(cat config/WORKFLOW_ID)
11+
if [ -z "$workflow_created" ]; then
1212
bash ./examples/Maestro/utils.sh
1313
fi
1414

1515
#check that create workflow script ran successfully
16-
workflow_id=$(cat config/WORKFLOW_ID)
17-
if [ -z "$workflow_id" ]; then
16+
workflow_created=$(cat config/WORKFLOW_ID)
17+
if [ -z "$workflow_created" ]; then
1818
echo "please create a worklow before running this example"
1919
exit 0
2020
fi
@@ -28,7 +28,7 @@ ACCESS_TOKEN=$(cat config/ds_access_token.txt)
2828
# Note: Substitute these values with your own
2929
account_id=$(cat config/API_ACCOUNT_ID)
3030

31-
base_path="https://demo.services.docusign.net/aow-manage/v1.0"
31+
base_path="https://api-d.docusign.com/v1"
3232

3333
# Construct your API headers
3434
#ds-snippet-start:Maestro1Step2
@@ -43,20 +43,46 @@ echo ""
4343
#ds-snippet-start:Maestro1Step3
4444
response=$(mktemp /tmp/response-wftmp.XXXXXX)
4545
Status=$(
46-
curl -w '%{http_code}' -i --request GET "${base_path}/management/accounts/${account_id}/workflowDefinitions/${workflow_id}" \
46+
curl -w '%{http_code}' --request GET "${base_path}/accounts/${account_id}/workflows" \
4747
"${Headers[@]}" \
4848
--output ${response}
4949
)
5050
# If the status code returned is greater than 201 (OK / Accepted), display an error message with the API response.
5151
if [[ "$Status" -gt "201" ]]; then
5252
echo ""
53-
echo "Unable to retrieve workflow definition with workflow ID: ${workflow_id}"
53+
echo "Unable to retrieve a workflow definition"
5454
echo ""
5555
cat $response
5656
exit 0
5757
fi
5858

59-
trigger_url=`cat $response | grep triggerUrl | sed 's/.*\"triggerUrl\":\"//' | sed 's/\",.*//'`
59+
echo "Response:"
60+
cat $response
61+
echo ""
62+
63+
workflow_id=$(grep -B 1 '"name": "Example workflow - send invite to signer"' $response | grep '"id":' | sed -n 's/.*"id": "\([^"]*\)".*/\1/p')
64+
65+
# Get the trigger URL
66+
response=$(mktemp /tmp/response-wftmp.XXXXXX)
67+
Status=$(curl -s -w "%{http_code}\n" -i --request GET "${base_path}/accounts/${account_id}/workflows/${workflow_id}/trigger-requirements" \
68+
"${Headers[@]}" \
69+
--output ${response})
70+
71+
# If the status code returned is greater than 201 (OK / Accepted), display an error message with the API response.
72+
if [[ "$Status" -gt "201" ]]; then
73+
echo ""
74+
echo "Unable to trigger a new instance of the specified workflow ${workflow_id}"
75+
echo ""
76+
cat $response
77+
exit 0
78+
fi
79+
80+
echo "Response:"
81+
cat $response
82+
echo ""
83+
84+
trigger_url=$(grep '"url":' $response | sed -n 's/.*"url": "\([^"]*\)".*/\1/p')
85+
decoded_trigger_url=$(echo $trigger_url | sed 's/\\u0026/\&/g')
6086
#ds-snippet-end:Maestro1Step3
6187

6288
echo "Please input a name for the workflow instance: "
@@ -78,36 +104,26 @@ read cc_email
78104
request_data=$(mktemp /tmp/request-wf-001.XXXXXX)
79105
printf \
80106
'{
81-
"instanceName": "'"$instance_name"'",
82-
"participants": {},
83-
"payload": {
107+
"instance_name": "'"$instance_name"'",
108+
"trigger_inputs": {
84109
"signerEmail": "'"${signer_email}"'",
85110
"signerName": "'"${signer_name}"'",
86111
"ccEmail": "'"${cc_email}"'",
87112
"ccName": "'"${cc_name}"'"
88-
},
89-
"metadata": {}
113+
}
90114
}' >$request_data
91115
#ds-snippet-end:Maestro1Step4
92116

93117
#ds-snippet-start:Maestro1Step5
94118
response=$(mktemp /tmp/response-wftmp.XXXXXX)
95-
Status=$(curl -s -w "%{http_code}\n" --request POST ${trigger_url} \
119+
Status=$(curl -s -w "%{http_code}\n" -i --request POST ${decoded_trigger_url} \
96120
"${Headers[@]}" \
97121
--data-binary @${request_data} \
98122
--output ${response})
99123
#ds-snippet-end:Maestro1Step5
100124

101-
# If the status code returned is greater than 201 (OK / Accepted), display an error message with the API response.
102-
if [[ "$Status" -gt "201" ]]; then
103-
echo ""
104-
echo "Unable to trigger a new instance of the specified workflow ${workflow_id}"
105-
echo ""
106-
cat $response
107-
exit 0
108-
fi
109125

110-
instance_id=`cat $response | grep instanceId | sed 's/.*\"instanceId\":\"//' | sed 's/\".*//'`
126+
instance_id=`cat $response | grep instance_id | sed 's/.*\"instance_id\":\"//' | sed 's/\".*//'`
111127
# Store the instance_id into the config file
112128
echo $instance_id >config/INSTANCE_ID
113129

@@ -116,6 +132,12 @@ echo "Response:"
116132
cat $response
117133
echo ""
118134

135+
instance_url=$(grep '"instance_url":' $response | sed -n 's/.*"instance_url": "\([^"]*\)".*/\1/p')
136+
decoded_instance_url=$(echo $instance_url | sed 's/\\u0026/\&/g')
137+
echo ""
138+
echo "Use this URL to complete the workflow steps:"
139+
echo $decoded_instance_url
140+
119141
# Remove the temporary files
120142
rm "$request_data"
121143
rm "$response"

examples/Maestro/eg002CancelWorkflow.sh

Lines changed: 0 additions & 72 deletions
This file was deleted.

examples/Maestro/eg003GetWorkflowStatus.sh

Lines changed: 0 additions & 73 deletions
This file was deleted.

examples/Maestro/utils.sh

Lines changed: 4 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,8 @@ printf \
101101
"propertyName": "dacId",
102102
"stepId": "'"${TRIGGER_ID}"'"
103103
}
104-
}
104+
},
105+
"type": "API"
105106
},
106107
"variables": {
107108
"dacId_'"${TRIGGER_ID}"'": {
@@ -154,46 +155,6 @@ printf \
154155
}
155156
},
156157
"steps": [
157-
{
158-
"id": "step1",
159-
"name": "Set Up Invite",
160-
"moduleName": "Notification-SendEmail",
161-
"configurationProgress": "Completed",
162-
"type": "DS-EmailNotification",
163-
"config": {
164-
"templateType": "WorkflowParticipantNotification",
165-
"templateVersion": 1,
166-
"language": "en",
167-
"sender_name": "DocuSign Orchestration",
168-
"sender_alias": "Orchestration",
169-
"participantId": "'"${SIGNER_ID}"'"
170-
},
171-
"input": {
172-
"recipients": [
173-
{
174-
"name": {
175-
"source": "step",
176-
"propertyName": "signerName",
177-
"stepId": "'"${TRIGGER_ID}"'"
178-
},
179-
"email": {
180-
"source": "step",
181-
"propertyName": "signerEmail",
182-
"stepId": "'"${TRIGGER_ID}"'"
183-
}
184-
}
185-
],
186-
"mergeValues": {
187-
"CustomMessage": "Follow this link to access and complete the workflow.",
188-
"ParticipantFullName": {
189-
"source": "step",
190-
"propertyName": "signerName",
191-
"stepId": "'"${TRIGGER_ID}"'"
192-
}
193-
}
194-
},
195-
"output": {}
196-
},
197158
{
198159
"id": "step2",
199160
"name": "Get Signatures",
@@ -580,7 +541,8 @@ printf \
580541
}
581542
}
582543
},
583-
"output": {}
544+
"output": {},
545+
"triggerType": "API"
584546
}
585547
]
586548
}

launcher.sh

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -951,8 +951,6 @@ function startMaestro() {
951951
PS3='Select the action : '
952952
select CHOICE in \
953953
"Trigger_Workflow" \
954-
"Stop_Workflow" \
955-
"Get_Workflow_Status"\
956954
"Home"; do
957955
case "$CHOICE" in
958956

@@ -963,14 +961,6 @@ function startMaestro() {
963961
bash examples/Maestro/eg001TriggerWorkflow.sh
964962
startMaestro
965963
;;
966-
Stop_Workflow)
967-
bash examples/Maestro/eg002CancelWorkflow.sh
968-
startMaestro
969-
;;
970-
Get_Workflow_Status)
971-
bash examples/Maestro/eg003GetWorkflowStatus.sh
972-
startMaestro
973-
;;
974964
*)
975965
echo "Default action..."
976966
startMaestro

0 commit comments

Comments
 (0)