Skip to main content

Managing a product return request

This workflow processes a return request: it validates it according to the policy (30 days), generates the return label with the carrier and informs the internal teams in charge of customer relations.

Loading the diagram…

The need​

Each return request must be validated according to the return policy (30 days). If accepted, a return label must be generated with the carrier; otherwise, the refusal must be notified. In all cases, the internal teams in charge of customer relations (customer service, technical team) must be informed — the workflow never addresses the end customer directly.

What the workflow does​

  1. Return requested — the Trigger node captures the return.requested event. The order reference, the reason and the customer arrive in data.
  2. Return accepted? — the Condition node checks that the 30-day window (daysSinceDelivery) is respected.
  3. Create the return label — if accepted, the HTTP(S) Request node calls the carrier's API to generate the return label.
  4. Send the label to customer service — the Send an email node sends the label to customer service (internal team), retrieved from the API response via {{ context.lastResponse.data.labelUrl }}.
  5. Notify the refusal to customer service — if the window has passed, an email informs customer service, which relays the refusal to the customer.
  6. Handle carrier failure — if the HTTP(S) Request node errors, the On Error node takes over, then Alert the technical team sends an email to the internal teams.

What you need​

Construction​

Copy the workflow definition and paste it into the editor (the Trigger node is recreated automatically, it is not in the snippet):

[
{
"id": "cond-106",
"name": "Return accepted?",
"config": {
"type": "CONDITION",
"conditionCode": "return data.daysSinceDelivery <= 30;",
"conditions": [
{
"value": true,
"next": "http-106"
},
{
"value": false,
"next": "refus-106"
}
]
},
"parents": [
"trigger"
],
"position": {
"x": 0,
"y": 200
}
},
{
"id": "http-106",
"name": "Create the return label",
"config": {
"type": "HTTP_REQUEST",
"method": "POST",
"url": "https://api.transporteur.fr/v1/labels",
"bodyMode": "RAW",
"body": "{\"order\": \"{{ data.orderRef }}\", \"reason\": \"{{ data.reason }}\"}"
},
"parents": [
"cond-106"
],
"position": {
"x": 0,
"y": 400
},
"next": "label-106"
},
{
"id": "label-106",
"name": "Send the label to customer service",
"config": {
"type": "SEND_EMAIL",
"to": [
"service-clients@boutique-france.fr"
],
"subject": "Return label: {{ data.orderRef }}",
"content": "Label available for customer {{ data.customerEmail }}: {{ context.lastResponse.data.labelUrl }}",
"sendAsHtml": true
},
"parents": [
"http-106"
],
"position": {
"x": 0,
"y": 600
}
},
{
"id": "refus-106",
"name": "Notify the refusal to customer service",
"config": {
"type": "SEND_EMAIL",
"to": [
"service-clients@boutique-france.fr"
],
"subject": "Return refused: {{ data.orderRef }}",
"content": "The return of order {{ data.orderRef }} is refused (deadline exceeded), to be communicated to customer {{ data.customerEmail }}.",
"sendAsHtml": true
},
"parents": [
"cond-106"
],
"position": {
"x": 800,
"y": 400
}
},
{
"id": "error-106",
"name": "Handle carrier failure",
"config": {
"type": "ON_ERROR",
"enabledEnvironments": []
},
"parents": [],
"position": {
"x": -800,
"y": 0
},
"next": "error-email-106"
},
{
"id": "error-email-106",
"name": "Alert the technical team",
"config": {
"type": "SEND_EMAIL",
"to": [
"ops@boutique-france.fr"
],
"subject": "Carrier failure: {{ data.orderRef }}",
"content": "The creation of the return label {{ data.orderRef }} failed with the carrier.",
"sendAsHtml": true
},
"parents": [
"error-106"
],
"position": {
"x": -800,
"y": 200
}
}
]

Check that it works​

The label URL is retrieved from the HTTP node output via {{ context.lastResponse… }}; check the exact response path before referencing the field. Deploy the workflow, start an execution and check the traces to verify the return label generation with the carrier and the notifications to the internal teams.

Variations​

  • Return policy: the 30-day window is hardcoded in the condition; move it to a dictionary to be able to change it without touching the workflow.
  • Internal emails: the Send an email nodes target customer service and the technical team — the workflow never addresses the end customer; customer communication remains the responsibility of the team.

See the reference


See also: Examples and integrations