An experimental n8n workflow example intended to email tracking details for a Shopify fulfillment through Gmail. The tracking link is included only when supplied in the fulfillment data. Code logic was tested with synthetic inputs; the complete workflow has not been verified with connected services. The workflow export below is free to copy. You need your own n8n environment and service accounts, which may have their own charges. Use a test environment with made-up data first. Copy the JSON onto an empty n8n canvas (Ctrl+V) and follow the setup steps.
For a Shopify store using Gmail. A fulfilled-order event is checked for a tracking number and customer email before a tracking message is sent.
Requirements: your own n8n instance, Shopify credentials permitted to receive order fulfillment events, and Gmail credentials permitted to send email. Configure these in Shopify Trigger and Send tracking email. No community nodes or sub-workflows are required.
Setup:
- Connect a test Shopify store and a test Gmail sender. Configure Shopify Trigger for orders/fulfilled and ensure the webhook can reach your n8n instance.
- In Settings, replace storeName.
- Test with made-up orders and a recipient address you control. Check the delivered email, items, carrier, tracking number and link.
- Test missing tracking, missing customer email, multiple fulfillments and repeated events. Inspect both workflow output and the destination inbox. Test service errors and inspect the execution before retrying.
- Use active-workflow test events when checking static-data persistence. Manual executions alone do not establish persistent duplicate handling.
- Check Shopify's existing shipping notifications. Avoid sending two shipping notices for one event. Activate for customers only after the exact export has passed complete testing.
Limits: deduplication uses workflow static data, which depends on active executions and persistence. It is not a guarantee against concurrent events, resets or delivery failures. Inspect an order and execution history before retrying a failed send. When several fulfillments have tracking, the code selects the last fulfillment with tracking in the supplied fulfillments array; the workflow does not sort by time.
Made with AI tools. Code logic was tested on made-up inputs; this is not evidence of a complete run with connected services. A complete run of the exact export is required before submission to n8n Creator Hub. Verify the complete workflow in your own test environment before activating it for real use.
Workflow JSON
{
"name": "Shopify shipped order to tracking email",
"nodes": [
{
"parameters": {
"content": "## Fulfilled Shopify order to a tracking email\n\nFor a Shopify store using Gmail. A fulfilled-order event is checked for a tracking number and customer email before a tracking message is sent.\n\nRequirements: your own n8n instance, Shopify credentials permitted to receive order fulfillment events, and Gmail credentials permitted to send email. Configure these in Shopify Trigger and Send tracking email. No community nodes or sub-workflows are required.\n\nSetup:\n1. Connect a test Shopify store and a test Gmail sender. Configure Shopify Trigger for orders/fulfilled and ensure the webhook can reach your n8n instance.\n2. In Settings, replace storeName.\n3. Test with made-up orders and a recipient address you control. Check the delivered email, items, carrier, tracking number and link.\n4. Test missing tracking, missing customer email, multiple fulfillments and repeated events. Inspect both workflow output and the destination inbox. Test service errors and inspect the execution before retrying.\n5. Use active-workflow test events when checking static-data persistence. Manual executions alone do not establish persistent duplicate handling.\n6. Check Shopify's existing shipping notifications. Avoid sending two shipping notices for one event. Activate for customers only after the exact export has passed complete testing.\n\nLimits: deduplication uses workflow static data, which depends on active executions and persistence. It is not a guarantee against concurrent events, resets or delivery failures. Inspect an order and execution history before retrying a failed send. When several fulfillments have tracking, the code selects the last fulfillment with tracking in the supplied fulfillments array; the workflow does not sort by time.\n\nMade with AI tools. Code logic was tested on made-up inputs; this is not evidence of a complete run with connected services. A complete run of the exact export is required before submission to n8n Creator Hub. Verify the complete workflow in your own test environment before activating it for real use.",
"width": 650,
"height": 1200
},
"id": "00000000-0000-4000-8000-000000000016",
"name": "Setup notes",
"type": "n8n-nodes-base.stickyNote",
"typeVersion": 1,
"position": [
-80,
-260
]
},
{
"parameters": {
"topic": "orders/fulfilled",
"authentication": "accessToken"
},
"id": "00000000-0000-4000-8000-000000000017",
"name": "Shopify Trigger",
"type": "n8n-nodes-base.shopifyTrigger",
"typeVersion": 1,
"position": [
0,
0
]
},
{
"parameters": {
"assignments": {
"assignments": [
{
"id": "00000000-0000-4000-8000-000000000018",
"name": "storeName",
"value": "Your Store",
"type": "string"
}
]
},
"includeOtherFields": true,
"options": {}
},
"id": "00000000-0000-4000-8000-000000000019",
"name": "Settings",
"type": "n8n-nodes-base.set",
"typeVersion": 3.4,
"position": [
220,
0
]
},
{
"parameters": {
"jsCode": "// Code node \"Write tracking message\": one email per fulfilled Shopify order.\r\n// Skips orders without a tracking number and orders already messaged (workflow static data).\r\nconst cfg = $('Settings').first().json;\r\nconst seen = $getWorkflowStaticData('global');\r\nseen.sent = seen.sent || {};\r\n\r\nconst out = [];\r\nfor (const item of $input.all()) {\r\n const o = item.json;\r\n const email = String(o.email ?? o.contact_email ?? o.customer?.email ?? '').trim();\r\n const fulfillments = Array.isArray(o.fulfillments) ? o.fulfillments : [];\r\n const f = [...fulfillments].reverse().find((x) => x && (x.tracking_number || (x.tracking_numbers || []).length));\r\n const tracking = f ? String(f.tracking_number ?? f.tracking_numbers[0]) : '';\r\n const url = f ? String(f.tracking_url ?? (f.tracking_urls || [])[0] ?? '') : '';\r\n const company = f ? String(f.tracking_company ?? '') : '';\r\n const key = String(o.id ?? o.name) + ':' + tracking;\r\n\r\n let skip = '';\r\n if (!email) skip = 'no customer email';\r\n else if (!tracking) skip = 'no tracking number yet';\r\n else if (seen.sent[key]) skip = 'already messaged';\r\n\r\n const first = String(o.customer?.first_name ?? o.shipping_address?.first_name ?? '').trim() || 'there';\r\n const items = (o.line_items || []).map((li) => '- ' + li.quantity + ' x ' + li.title).join('\\n');\r\n const lines = [\r\n 'Hi ' + first + ',',\r\n '',\r\n 'Your order ' + o.name + ' has shipped.',\r\n '',\r\n items,\r\n '',\r\n 'Carrier: ' + (company || 'see tracking link'),\r\n 'Tracking number: ' + tracking,\r\n url ? 'Track it here: ' + url : '',\r\n '',\r\n 'If something looks wrong when it arrives, reply to this email and we will sort it out.',\r\n '',\r\n cfg.storeName,\r\n ];\r\n const body = lines.filter((l, i) => !(l === '' && lines[i - 1] === '') ).join('\\n').replace(/\\n{3,}/g, '\\n\\n');\r\n\r\n if (!skip) seen.sent[key] = true;\r\n out.push({ json: { orderName: o.name, to: email, skip, subject: 'Your order ' + o.name + ' has shipped', body, tracking } });\r\n}\r\nreturn out;\r\n"
},
"id": "00000000-0000-4000-8000-000000000020",
"name": "Write tracking message",
"type": "n8n-nodes-base.code",
"typeVersion": 2,
"position": [
440,
0
]
},
{
"parameters": {
"conditions": {
"options": {
"caseSensitive": true,
"leftValue": "",
"typeValidation": "strict",
"version": 2
},
"conditions": [
{
"id": "00000000-0000-4000-8000-000000000021",
"leftValue": "={{ $json.skip }}",
"rightValue": "",
"operator": {
"type": "string",
"operation": "empty",
"singleValue": true
}
}
],
"combinator": "and"
},
"options": {}
},
"id": "00000000-0000-4000-8000-000000000022",
"name": "Skip reason empty?",
"type": "n8n-nodes-base.if",
"typeVersion": 2.2,
"position": [
660,
0
]
},
{
"parameters": {
"resource": "message",
"operation": "send",
"sendTo": "={{ $json.to }}",
"subject": "={{ $json.subject }}",
"emailType": "text",
"message": "={{ $json.body }}",
"options": {}
},
"id": "00000000-0000-4000-8000-000000000023",
"name": "Send tracking email",
"type": "n8n-nodes-base.gmail",
"typeVersion": 2.1,
"position": [
880,
-100
]
}
],
"connections": {
"Shopify Trigger": {
"main": [
[
{
"node": "Settings",
"type": "main",
"index": 0
}
]
]
},
"Settings": {
"main": [
[
{
"node": "Write tracking message",
"type": "main",
"index": 0
}
]
]
},
"Write tracking message": {
"main": [
[
{
"node": "Skip reason empty?",
"type": "main",
"index": 0
}
]
]
},
"Skip reason empty?": {
"main": [
[
{
"node": "Send tracking email",
"type": "main",
"index": 0
}
]
]
}
},
"active": false,
"settings": {
"executionOrder": "v1"
},
"pinData": {},
"tags": []
}
Top comments (0)