Create an array with some items

Hello.

I need to create a workflow that send a list of some paramets to MicrosoftTeams.
I made this workflow and it’s working, in the end of workflow, I have five rows and it was send to Teams, but, as a five differents messages… I would like that the message was send like a list, in other words, just one message with five rows.

Can I create some array and put the values like “array.push[]” ?

I’m not development, Can anybody helps me?

Thanks


You need to use a function node before the Microsoft Teams node to group all the names into a single name.

The function node should be something like:

return [
  {
    json: {
      Name: items.map(item => item.json.NAME).join('')
    }
  }
]
Example workflow
{
  "nodes": [
    {
      "parameters": {},
      "name": "Start",
      "type": "n8n-nodes-base.start",
      "typeVersion": 1,
      "position": [
        250,
        300
      ]
    },
    {
      "parameters": {
        "functionCode": "return [\n  {\n    json: {\n      NAME: 'A'\n    }\n  },\n   {\n    json: {\n      NAME: 'B'\n    }\n  },\n     {\n    json: {\n      NAME: 'C'\n    }\n  }\n]"
      },
      "name": "Function",
      "type": "n8n-nodes-base.function",
      "typeVersion": 1,
      "position": [
        490,
        300
      ],
      "notesInFlow": true,
      "notes": "Mockup data"
    },
    {
      "parameters": {
        "functionCode": "return [\n  {\n    json: {\n      Name: items.map(item => item.json.NAME).join('')\n    }\n  }\n]\n\n"
      },
      "name": "Function1",
      "type": "n8n-nodes-base.function",
      "typeVersion": 1,
      "position": [
        720,
        300
      ],
      "notesInFlow": true,
      "notes": "Group data"
    },
    {
      "parameters": {
        "resource": "channelMessage",
        "teamId": "d6b83b00-085d-472c-a6d9-8c2c32c1424e",
        "channelId": "19:[email protected]",
        "messageType": "text",
        "message": "={{$node[\"Function1\"].json[\"Name\"]}}\n",
        "options": {}
      },
      "name": "Microsoft Teams",
      "type": "n8n-nodes-base.microsoftTeams",
      "typeVersion": 1,
      "position": [
        940,
        300
      ],
      "credentials": {
        "microsoftTeamsOAuth2Api": "asasasasasas"
      }
    }
  ],
  "connections": {
    "Start": {
      "main": [
        [
          {
            "node": "Function",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Function": {
      "main": [
        [
          {
            "node": "Function1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Function1": {
      "main": [
        [
          {
            "node": "Microsoft Teams",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}

Hi @RicardoE105, thank you very much, it worked on my workflow.

One question, Is there a way to group all the names with line break?

Glad that it worked. Have fun. The example below uses line breaks.

   return [
      {
        json: {
          Name: items.map(item => item.json.NAME).join('\n')
        }
      }
    ]

Hi @RicardoE105, didn’t work… but no problem, your first soluction helps me.
Thanks.