Combining certain and unknown items

Describe the problem/error/question

Trying to send an SMS message from separate items.

I want to combine all items that are above or equal to 3 (see attachment) because those are part of the contents of the message. The issue is that the number of items are not static. If we send a larger message the items (input) could range much further and I dont want to define that number but just want all equal to or above 3.
image

What is the error message (if any)?

no

Please share your workflow

{
“meta”: {
“instanceId”: “76ae82a9c315fdcf530f88eec26095c19e39b3068fa51bce346a852841153887”
},
“nodes”: [
{
“parameters”: {
“method”: “POST”,
“url”: “https://api.brevo.com/v3/transactionalSMS/sms”,
“sendHeaders”: true,
“headerParameters”: {
“parameters”: [
{
“name”: “accept”,
“value”: “application/json”
},
{
“name”: “api-key”
}
]
},
“sendBody”: true,
“bodyParameters”: {
“parameters”: [
{
“name”: “type”,
“value”: “transactional”
},
{
“name”: “unicodeEnabled”
},
{
“name”: “sender”,
“value”: “ProfitMedia”
},
{
“name”: “recipient”,
“value”: “=+{{ $json.TelefonnummerClean }}”
},
{
“name”: “content”,
“value”: “={{ $json.Content }}”
}
]
},
“options”: {}
},
“id”: “98af4916-d8d6-477b-bd19-142df4b1c8a6”,
“name”: “HTTP Request”,
“type”: “n8n-nodes-base.httpRequest”,
“typeVersion”: 4.1,
“position”: [
640,
1040
]
},
{
“parameters”: {
“values”: {
“string”: [
{
“name”: “input”,
“value”: “={{ $json.body["text"].split(’ ') }}”
}
]
},
“options”: {}
},
“id”: “8c560592-3ea5-4c9f-ba02-0583ef3cda11”,
“name”: “Split text”,
“type”: “n8n-nodes-base.set”,
“typeVersion”: 2,
“position”: [
40,
1040
]
},
{
“parameters”: {
“values”: {
“string”: [
{
“name”: “Content”,
“value”: “={{ $json.input[3] }}”
}
],
“number”: [
{
“name”: “TelefonnummerClean”,
“value”: “={{ $json.input[‘2’]? ‘+46’ + $json.input[‘2’].replace(/\D/g, ‘’).replace(/^46/, ‘’) : undefined }}”
}
]
},
“options”: {}
},
“id”: “9aa26085-9260-488c-aaff-589c9ca5b178”,
“name”: “Telefonnummer & Content”,
“type”: “n8n-nodes-base.set”,
“typeVersion”: 2,
“position”: [
440,
1040
]
},
{
“parameters”: {
“jsCode”: “for (const item of $input.all()) {\n if (item.json.input[‘2’].startsWith("0")) {\n item.json.input[‘2’] = item.json.input[‘2’].replace(/^0/, "");\n }\n}\nreturn $input.all();”
},
“id”: “0f702e94-677c-475e-b929-8a5d41d16ea8”,
“name”: “Remove 0 from phone”,
“type”: “n8n-nodes-base.code”,
“typeVersion”: 2,
“position”: [
240,
1040
]
}
],
“connections”: {
“Split text”: {
“main”: [
[
{
“node”: “Remove 0 from phone”,
“type”: “main”,
“index”: 0
}
]
]
},
“Telefonnummer & Content”: {
“main”: [
[
{
“node”: “HTTP Request”,
“type”: “main”,
“index”: 0
}
]
]
},
“Remove 0 from phone”: {
“main”: [
[
{
“node”: “Telefonnummer & Content”,
“type”: “main”,
“index”: 0
}
]
]
}
}
}

Thank you in advance!

Information on your n8n setup

  • n8n version:
    1.0.4

  • Database (default: SQLite):
    SQLite

  • n8n EXECUTIONS_PROCESS setting (default: own, main):
    default: own, main)

  • Running n8n via (Docker, npm, n8n cloud, desktop app):
    cloud n8n

  • Operating system:

Hi @Profit_Media, are you looking to build a new string of all items with index 3 from your input field after splitting that string in the first place?

If so, I think you might want to consider not splitting up the text from your existing body.text field which appears to be what Split text node is doing. Instead, perhaps you want to consider extracting only the phone number and keeping the original content? For example like so:

Let me know if this helps or if I have perhaps misunderstood something here :slight_smile:

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.