Hi Support - I’m getting this error too. Can you please assist, as this appears to be a bug? I’m getting the error when executing the “Get Shopify Order by Name” node in the workflow below. I’m on the latest version.
{
“nodes”: [
{
“parameters”: {
“postProcessAction”: “nothing”,
“downloadAttachments”: true,
“options”: {}
},
“id”: “1”,
“name”: “Email Trigger (IMAP)”,
“type”: “n8n-nodes-base.emailReadImap”,
“position”: [
256,
288
],
“typeVersion”: 2.1,
“credentials”: {
“imap”: {
“id”: “oDhGRB6YM6nzvIud”,
“name”: “[email protected] IMAP connection”
}
}
},
{
“parameters”: {
“modelId”: {
“__rl”: true,
“value”: “claude-sonnet-4-20250514”,
“mode”: “list”,
“cachedResultName”: “claude-sonnet-4-20250514”
},
“messages”: {
“values”: [
{
“content”: “=Analyze this email subject and body to determine if it’s a payment notification. Note that the paymemt details will be contained in an attachment, NOT in the email, so you’re just looking for a reference to the fact that the email is a payment notification.\n\nEmail Subject: {{ $json.subject }}\n\nEmail Body: {{ $json.textPlain }}\n\nRespond with a valid JSON object only, like this:\n{\n “isPaymentNotification”: true/false,\n “confidence”: 0-100,\n “reason”: “brief explanation”\n}”
}
]
},
“options”: {
“maxTokens”: 200,
“temperature”: 0.3
}
},
“id”: “2”,
“name”: “Check if Payment Notification”,
“type”: “@n8n/n8n-nodes-langchain.anthropic”,
“position”: [
480,
288
],
“typeVersion”: 1,
“credentials”: {
“anthropicApi”: {
“id”: “CGC61nZHUJJSA8rj”,
“name”: “Anthropic account”
}
}
},
{
“parameters”: {
“jsCode”: “// Process ALL input items and parse Claude’s response about payment notification\nconst results = ;\n\n// Get ALL email data from the Email Trigger (IMAP) node\nconst emailTriggerItems = $(‘Email Trigger (IMAP)’).all();\n\n// Loop through all input items from Claude’s payment notification check\nfor (let i = 0; i < $input.all().length; i++) {\n const currentItem = $input.all()[i];\n \n // Get corresponding email data (same index)\n const emailData = emailTriggerItems[i] ? emailTriggerItems[i].json : emailTriggerItems[0].json;\n // Get corresponding binary data (same index) - THIS IS THE KEY FIX\n const emailBinary = emailTriggerItems[i] ? emailTriggerItems[i].binary : emailTriggerItems[0].binary;\n \n let claudeResponse;\n \n try {\n const content = currentItem.json.content;\n let textContent = ‘’;\n \n // Extract text from Claude’s response structure\n if (Array.isArray(content) && content.length > 0) {\n // Find the text item in the content array\n const textItem = content.find(item => item.type === ‘text’);\n if (textItem && textItem.text) {\n textContent = textItem.text;\n }\n } else if (typeof content === ‘string’) {\n textContent = content;\n } else {\n throw new Error(‘Unexpected content format’);\n }\n \n if (!textContent) {\n throw new Error(‘No text content found’);\n }\n \n // Clean up the text: remove markdown, normalize whitespace\n textContent = textContent\n .replace(/json\\s*|\s*/g, ‘’) // Remove code blocks\n .replace(/\\n/g, ‘’) // Remove escaped newlines\n .replace(/\n/g, ‘’) // Remove actual newlines\n .trim();\n \n // Parse the JSON directly\n claudeResponse = JSON.parse(textContent);\n \n } catch (e) {\n // If parsing fails, create a default response\n claudeResponse = {\n isPaymentNotification: false,\n confidence: 0,\n reason: ‘Failed to parse Claude response: ’ + e.message,\n parseError: true\n };\n }\n \n // Extract sender information from corresponding email data\n let from = emailData.from || ‘’;\n let domain = ‘’;\n \n // Extract domain from email address (simple string format)\n if (from && from.includes(’@‘)) {\n domain = from.split(’@')[1].toLowerCase();\n }\n \n // Check if from valid bank domain\n const validBankDomains = [‘fnb.co.za’, ‘absa.co.za’, ‘nedbank.co.za’, ‘yahoo.com’];\n const isValidBank = validBankDomains.includes(domain);\n \n // Add the processed item to results\n results.push({\n json: {\n // Include original email data from corresponding email\n …emailData,\n // Add parsed Claude response\n isPaymentNotification: claudeResponse.isPaymentNotification || false,\n confidence: claudeResponse.confidence || 0,\n reason: claudeResponse.reason || ‘No reason provided’,\n // Add sender analysis\n senderDomain: domain,\n isValidBank: isValidBank,\n fromEmail: from,\n // Add item index for debugging\n itemIndex: i\n },\n // CRITICAL FIX: Pass through the original email binary data (attachments)\n binary: emailBinary || {}\n });\n}\n\nreturn results;”
},
“id”: “3”,
“name”: “Parse Payment Check”,
“type”: “n8n-nodes-base.code”,
“position”: [
832,
288
],
“typeVersion”: 2
},
{
“parameters”: {
“conditions”: {
“options”: {
“caseSensitive”: true,
“leftValue”: “”,
“typeValidation”: “strict”,
“version”: 1
},
“conditions”: [
{
“operator”: {
“type”: “boolean”,
“operation”: “equals”
},
“leftValue”: “={{ $json.isPaymentNotification }}”,
“rightValue”: true,
“id”: “66ab3f1b-0958-49a4-82a1-36bfc51ea6d8”
}
],
“combinator”: “and”
},
“options”: {}
},
“id”: “4”,
“name”: “Is Payment Notification?”,
“type”: “n8n-nodes-base.if”,
“position”: [
1056,
288
],
“typeVersion”: 2
},
{
“parameters”: {
“conditions”: {
“options”: {
“caseSensitive”: true,
“leftValue”: “”,
“typeValidation”: “strict”,
“version”: 1
},
“conditions”: [
{
“operator”: {
“type”: “boolean”,
“operation”: “equals”
},
“leftValue”: “={{ $json.isValidBank }}”,
“rightValue”: true,
“id”: “60a9ddfb-6362-4a7a-b5e7-dc04f1a267c5”
}
],
“combinator”: “and”
},
“options”: {}
},
“id”: “5”,
“name”: “Is Valid Bank Domain?”,
“type”: “n8n-nodes-base.if”,
“position”: [
1280,
272
],
“typeVersion”: 2
},
{
“parameters”: {
“fromEmail”: “[email protected]”,
“toEmail”: “={{ $json.customerEmail }}”,
“subject”: “SIWSA Order {{ $json.orderNumber }} - Payment Notification Received”,
“html”: “Dear Customer\n\nWe have received a payment notification for order number {{ $json.orderNumber }}. We’ll now process your order, which will be released on receipt of funds. Thank you for your business!\n\nKind regards,\nSIWSA”,
“options”: {}
},
“id”: “6”,
“name”: “Send Email Acknowledgement”,
“type”: “n8n-nodes-base.emailSend”,
“position”: [
2400,
0
],
“typeVersion”: 2.1,
“webhookId”: “44e54eb8-f969-4808-989a-1609ea84323a”,
“credentials”: {
“smtp”: {
“id”: “msEtua9eM3qlx9w3”,
“name”: “[email protected] SMTP account (send)”
}
}
},
{
“parameters”: {
“resource”: “document”,
“modelId”: {
“__rl”: true,
“mode”: “list”,
“value”: “claude-sonnet-4-20250514”,
“cachedResultName”: “claude-sonnet-4-20250514”
},
“text”: “Analyse the bank payment notification PDF to extract the payment reference. Follow these steps:\n1. Primary Target: Look for a 7-character code starting with “WB” followed by exactly 5 digits (pattern: WB12345)\n2. Secondary Targets (if WB code not found): Extract whatever appears to be the payment reference.\nRespond ONLY with the JSON structure below and no other text or commentary:\n{\n “WB_code_found”: true/false,\n “reference”: “extracted_value_or_null”,\n “confidence”: 0-100,\n “extraction_notes”: “brief_explanation_of_what_was_found”\n}\nIf no reference is found at all, set the reference to null and the confidence to 0.”,
“inputType”: “binary”,
“binaryPropertyName”: “attachment_0”,
“options”: {
“maxTokens”: 200
}
},
“id”: “7”,
“name”: “Extract Reference from PDF”,
“type”: “@n8n/n8n-nodes-langchain.anthropic”,
“position”: [
1504,
192
],
“typeVersion”: 1,
“credentials”: {
“anthropicApi”: {
“id”: “CGC61nZHUJJSA8rj”,
“name”: “Anthropic account”
}
}
},
{
“parameters”: {
“url”: “=https://inverter-warehouse.myshopify.com/admin/api/2024-04/orders.json?name=WB12023&limit=1”,
“authentication”: “predefinedCredentialType”,
“nodeCredentialType”: “shopifyAccessTokenApi”,
“sendHeaders”: true,
“headerParameters”: {
“parameters”: [
{
“name”: “Content-Type”,
“value”: “application/json”
}
]
},
“options”: {}
},
“id”: “9”,
“name”: “Get Shopify Order by Name”,
“type”: “n8n-nodes-base.httpRequest”,
“position”: [
1920,
192
],
“typeVersion”: 4.2,
“credentials”: {
“shopifyAccessTokenApi”: {
“id”: “Dme3BZkWd713LzDX”,
“name”: “Shopify Access Token account”
}
},
“onError”: “continueErrorOutput”
},
{
“parameters”: {
“operation”: “send”,
“phoneNumberId”: “={{ $credentials.phoneNumberId }}”,
“recipientPhoneNumber”: “={{ $json.customerPhone }}”,
“textBody”: “Thank you for your payment for order {{ $json.orderNumber }}.\n\nWe have received your payment confirmation and will ship your order as soon as the funds clear.\n\n{{ $json.wbCodeFound ? ‘Reference: ’ + $json.orderReference : ‘Order processed successfully’ }}\n\nKind regards,\nSIWSA”,
“additionalFields”: {}
},
“id”: “11”,
“name”: “Send WhatsApp Message”,
“type”: “n8n-nodes-base.whatsApp”,
“position”: [
2400,
192
],
“typeVersion”: 1,
“webhookId”: “469c5144-d371-443c-b1c4-1d63b4f1c0b8”,
“onError”: “continueRegularOutput”
},
{
“parameters”: {
“fromEmail”: “[email protected]”,
“toEmail”: “[email protected]”,
“subject”: “=Alert: Payment Notification from Unverified Source”,
“emailFormat”: “text”,
“options”: {}
},
“id”: “12”,
“name”: “Notify Admin - Invalid Domain”,
“type”: “n8n-nodes-base.emailSend”,
“position”: [
1504,
384
],
“typeVersion”: 2.1,
“webhookId”: “37dc0631-d956-4d4c-af10-22495eebdb46”,
“credentials”: {
“smtp”: {
“id”: “msEtua9eM3qlx9w3”,
“name”: “[email protected] SMTP account (send)”
}
}
},
{
“parameters”: {
“options”: {}
},
“id”: “13”,
“name”: “Handle Shopify Error”,
“type”: “n8n-nodes-base.emailSend”,
“position”: [
2176,
288
],
“typeVersion”: 2.1,
“webhookId”: “56ee6138-51c7-4f91-85c4-774f2481c819”,
“credentials”: {
“smtp”: {
“id”: “msEtua9eM3qlx9w3”,
“name”: “[email protected] SMTP account (send)”
}
}
},
{
“parameters”: {
“jsCode”: “// Extract phone number and email from Shopify HTTP response\nconst response = $input.item.json;\n\n// Handle HTTP Request response structure - orders are in an array\nlet order;\nif (response.orders && Array.isArray(response.orders) && response.orders.length > 0) {\n order = response.orders[0]; // Get first (and should be only) order\n} else {\n throw new Error(Order with name '${$input.item.json.orderReference || 'unknown'}' not found);\n}\n\nlet phoneNumber = ‘’;\nlet customerEmail = ‘’;\n\n// === PHONE NUMBER EXTRACTION ===\n// Try to get phone from different possible locations with priority fallback\nphoneNumber = order.phone || \n order.billing_address?.phone || \n order.shipping_address?.phone || \n order.customer?.phone || \n ‘’;\n\n// Clean and format phone number\nif (phoneNumber) {\n // Remove all non-numeric characters except +\n phoneNumber = phoneNumber.replace(/[^0-9+]/g, ‘’);\n \n // Ensure it starts with country code\n if (phoneNumber && !phoneNumber.startsWith(‘+’)) {\n // Assume South Africa if no country code\n if (!phoneNumber.startsWith(‘27’)) {\n phoneNumber = ‘27’ + phoneNumber.replace(/^0/, ‘’);\n }\n phoneNumber = ‘+’ + phoneNumber;\n }\n}\n\n// === EMAIL ADDRESS EXTRACTION ===\n// Try to get email from different possible locations with priority fallback\ncustomerEmail = order.email || \n order.customer?.email || \n order.billing_address?.email ||\n order.shipping_address?.email ||\n ‘’;\n\n// Basic email validation and cleaning\nif (customerEmail) {\n // Trim whitespace and convert to lowercase\n customerEmail = customerEmail.trim().toLowerCase();\n \n // Basic email format validation\n const emailRegex = /+@[^\s@]+\.[^\s@]+$/;\n if (!emailRegex.test(customerEmail)) {\n console.log(Warning: Invalid email format detected: ${customerEmail});\n // Don’t clear it completely - let downstream processes handle it\n }\n}\n\n// === ERROR HANDLING ===\n// Check if we have at least one contact method\nif (!phoneNumber && !customerEmail) {\n throw new Error(‘No phone number or email address found in order’);\n}\n\n// === RETURN DATA ===\nreturn [{\n json: {\n …$input.item.json,\n // Include the full order data\n order: order,\n customerPhone: phoneNumber,\n customerEmail: customerEmail,\n orderNumber: order.name || order.order_number || $input.item.json.orderReference,\n orderId: order.id, // Include the actual order ID for reference\n // Add some debug info for troubleshooting\n contactSources: {\n phoneSource: order.phone ? ‘order.phone’ : \n order.billing_address?.phone ? ‘billing_address.phone’ :\n order.shipping_address?.phone ? ‘shipping_address.phone’ :\n order.customer?.phone ? ‘customer.phone’ : ‘none’,\n emailSource: order.email ? ‘order.email’ :\n order.customer?.email ? ‘customer.email’ :\n order.billing_address?.email ? ‘billing_address.email’ :\n order.shipping_address?.email ? ‘shipping_address.email’ : ‘none’\n }\n }\n}];}”
},
“id”: “10”,
“name”: “Extract Phone No and Email”,
“type”: “n8n-nodes-base.code”,
“position”: [
2176,
96
],
“typeVersion”: 2
},
{
“parameters”: {
“mode”: “runOnceForEachItem”,
“jsCode”: “// Simplified parsing logic for the updated JSON structure\nlet reference = null;\nlet confidence = 0;\nlet extractionNotes = ‘’;\nlet wbCodeFound = false;\n\ntry {\n const response = $input.item.json;\n let content = ‘’;\n \n // Extract content from various possible response formats\n if (response.content) {\n if (Array.isArray(response.content)) {\n const textItem = response.content.find(item => item.type === ‘text’);\n content = textItem?.text || ‘’;\n } else if (typeof response.content === ‘string’) {\n content = response.content;\n }\n } else if (response.message) {\n content = response.message;\n }\n \n if (!content) {\n throw new Error(‘No content found in response’);\n }\n \n // Clean and parse JSON\n content = content\n .replace(/json\\s*|\s*/g, ‘’) // Remove code blocks\n .replace(/\\n/g, ‘’) // Remove escaped newlines\n .replace(/\n/g, ‘’) // Remove actual newlines\n .trim();\n \n const parsed = JSON.parse(content);\n \n // Extract data from the simplified structure\n if (parsed.reference && parsed.reference !== ‘null’ && parsed.reference !== null) {\n reference = parsed.reference;\n confidence = parsed.confidence || 0;\n extractionNotes = parsed.extraction_notes || ‘’;\n wbCodeFound = parsed.WB_code_found || false;\n \n // Validate WB code format if claimed\n if (wbCodeFound && reference) {\n const wbPattern = /^WB\d{5}$/i;\n if (!wbPattern.test(reference)) {\n extractionNotes += ’ (WB format validation failed)’;\n confidence = Math.max(0, confidence - 20);\n wbCodeFound = false;\n }\n }\n } else {\n throw new Error(‘No valid reference found in document’);\n }\n \n} catch (e) {\n // Enhanced error handling with fallback\n reference = null;\n confidence = 0;\n extractionNotes = ‘Parsing failed: ’ + e.message;\n \n // Try to extract any alphanumeric string as fallback from original content\n if (content) {\n const fallbackMatch = content.match(/[A-Z0-9]{5,10}/i);\n if (fallbackMatch) {\n reference = fallbackMatch[0];\n confidence = 30;\n extractionNotes += ’ (fallback extraction)’;\n }\n }\n}\n\nif (!reference) {\n throw new Error(‘Could not extract any reference from PDF’);\n}\n\nreturn {\n json: {\n …$input.item.json,\n orderReference: reference,\n extractionConfidence: confidence,\n extractionNotes: extractionNotes,\n wbCodeFound: wbCodeFound\n }\n};”
},
“type”: “n8n-nodes-base.code”,
“typeVersion”: 2,
“position”: [
1712,
176
],
“id”: “46abf29d-6531-4727-a767-8ec3a20acc3a”,
“name”: “Parse Reference”
}
],
“connections”: {
“Email Trigger (IMAP)”: {
“main”: [
[
{
“node”: “Check if Payment Notification”,
“type”: “main”,
“index”: 0
}
]
]
},
“Check if Payment Notification”: {
“main”: [
[
{
“node”: “Parse Payment Check”,
“type”: “main”,
“index”: 0
}
]
]
},
“Parse Payment Check”: {
“main”: [
[
{
“node”: “Is Payment Notification?”,
“type”: “main”,
“index”: 0
}
]
]
},
“Is Payment Notification?”: {
“main”: [
[
{
“node”: “Is Valid Bank Domain?”,
“type”: “main”,
“index”: 0
}
],
]
},
“Is Valid Bank Domain?”: {
“main”: [
[
{
“node”: “Extract Reference from PDF”,
“type”: “main”,
“index”: 0
}
],
[
{
“node”: “Notify Admin - Invalid Domain”,
“type”: “main”,
“index”: 0
}
]
]
},
“Extract Reference from PDF”: {
“main”: [
[
{
“node”: “Parse Reference”,
“type”: “main”,
“index”: 0
}
]
]
},
“Get Shopify Order by Name”: {
“main”: [
[
{
“node”: “Extract Phone No and Email”,
“type”: “main”,
“index”: 0
}
],
[
{
“node”: “Handle Shopify Error”,
“type”: “main”,
“index”: 0
}
]
]
},
“Extract Phone No and Email”: {
“main”: [
[
{
“node”: “Send WhatsApp Message”,
“type”: “main”,
“index”: 0
},
{
“node”: “Send Email Acknowledgement”,
“type”: “main”,
“index”: 0
}
]
]
},
“Parse Reference”: {
“main”: [
]
}
},
“pinData”: {
“Check if Payment Notification”: [
{
“content”: [
{
“type”: “text”,
“text”: “{\n “isPaymentNotification”: true,\n “confidence”: 95,\n “reason”: “The email subject clearly states ‘Payment Notification’ and this phrase appears consistently across multiple forwarded messages in the chain, indicating this is indeed a payment notification email.”\n}”
}
]
}
],
“Extract Reference from PDF”: [
{
“content”: [
{
“type”: “text”,
“text”: “{\n “WB_code_found”: true,\n “reference”: “WB12023”,\n “confidence”: 100,\n “extraction_notes”: “Found WB12023 in the Reference field under Payee Details section”\n}”
}
]
}
],
“Parse Reference”: [
{
“content”: [
{
“type”: “text”,
“text”: “{\n “WB_code_found”: true,\n “reference”: “WB12023”,\n “confidence”: 100,\n “extraction_notes”: “Found WB12023 in the Reference field under Payee Details section”\n}”
}
],
“orderReference”: “WB12023”,
“extractionConfidence”: 100,
“extractionNotes”: “Found WB12023 in the Reference field under Payee Details section”,
“wbCodeFound”: true
}
]
},
“meta”: {
“instanceId”: “356540b8f4cfb00b0cf5fcc36feebff370092bf048688bf0c737a3c0d3d75ea6”
}
}