Sending to Rabbit by one of the Airtable

Hi!
I get a list from Airtable, how do I send one object from that list to the Rabbit exchanger?
The example below, which doesn’t work.

Bad Example
  {
      "name": "",
      "nodes": [
    {
      "parameters": {},
      "name": "Start",
      "type": "n8n-nodes-base.start",
      "typeVersion": 1,
      "position": [
        250,
        300
      ]
    },
    {
      "parameters": {
        "operation": "list",
        "application": "id_base",
        "table": "table",
        "additionalOptions": {
          "filterByFormula": "=type = \"created\""
        }
      },
      "name": "GetWorkouts",
      "type": "n8n-nodes-base.airtable",
      "typeVersion": 1,
      "position": [
        493,
        536
      ],
      "credentials": {
        "airtableApi": "Airtable Alekseev"
      }
    },
    {
      "parameters": {
        "mode": "exchange",
        "exchange": "Exchange",
        "exchangeType": "topic",
        "routingKey": "rout_key",
        "sendInputData": false,
        "message": "={{JSON.stringify($node[\"GetWorkouts\"].json[\"fields\"])}}",
        "options": {}
      },
      "name": "SendingWorkouts",
      "type": "n8n-nodes-base.rabbitmq",
      "typeVersion": 1,
      "position": [
        720,
        540
      ],
      "credentials": {
        "rabbitmq": "n8n_rabbit"
      }
    }
      ],
      "connections": {
    "GetWorkouts": {
      "main": [
        [
          {
            "node": "SendingWorkouts",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
      },
      "active": false,
      "settings": {}
    }

It seems like you did not paste the workflow correctly. Can you check that out? Also, can you share how the data is coming from the rabbit queue. And, what is the structure of your data in Airtable? This way, I might be able to put a working example.

I get an array from Airtable and want to send one element of the array to RabbitMQ.

Example data from Airtable (List)
[
    {
        "id": "id_record_1",
        "fields": {
            "index": 5,
            "type": "created",
            "sending_date": "2021-04-04",
            "message": "Hello is Test 1!",
            "user": [
                "user_id_1"
            ],
            "status": [
                "active"
            ],
            "last_name": [
                "Last_Name_1"
            ],
            "first_name": [
                "First_Name_1"
            ],
            "tg_id": [
                "tg_id_1"
            ]
        },
        "createdTime": "2021-04-04T12:41:01.000Z"
    },
    {
        "id": "id_record_2",
        "fields": {
            "index": 4,
            "type": "created",
            "message": "Hello is test 2!",
            "sending_date": "2021-04-04",
            "user": [
                "user_id_2"
            ],
            "status": [
                "active"
            ],
            "last_name": [
                "Last_Name_2"
            ],
            "first_name": [
                "First_Name_2"
            ],
            "tg_id": [
                "tg_id_2"
            ]
        },
        "createdTime": "2021-04-04T12:26:52.000Z"
    }
]

Each element of the array must be sent separately. If there are 100 then there will be 100 messages to RabbitMQ.

Oh, gotcha. Sorry, I misunderstood the first message. The example below should do it.

{
  "nodes": [
    {
      "parameters": {},
      "name": "Start",
      "type": "n8n-nodes-base.start",
      "typeVersion": 1,
      "position": [
        250,
        300
      ]
    },
    {
      "parameters": {
        "functionCode": "return [\n  {\n    json: {\n        \"id\": \"id_record_1\",\n        \"fields\": {\n            \"index\": 5,\n            \"type\": \"created\",\n            \"sending_date\": \"2021-04-04\",\n            \"message\": \"Hello is Test 1!\",\n            \"user\": [\n                \"user_id_1\"\n            ],\n            \"status\": [\n                \"active\"\n            ],\n            \"last_name\": [\n                \"Last_Name_1\"\n            ],\n            \"first_name\": [\n                \"First_Name_1\"\n            ],\n            \"tg_id\": [\n                \"tg_id_1\"\n            ]\n        },\n        \"createdTime\": \"2021-04-04T12:41:01.000Z\"\n    },\n  },\n  {\n    json: {\n        \"id\": \"id_record_1\",\n        \"fields\": {\n            \"index\": 5,\n            \"type\": \"created\",\n            \"sending_date\": \"2021-04-04\",\n            \"message\": \"Hello is Test 1!\",\n            \"user\": [\n                \"user_id_1\"\n            ],\n            \"status\": [\n                \"active\"\n            ],\n            \"last_name\": [\n                \"Last_Name_1\"\n            ],\n            \"first_name\": [\n                \"First_Name_1\"\n            ],\n            \"tg_id\": [\n                \"tg_id_1\"\n            ]\n        },\n        \"createdTime\": \"2021-04-04T12:41:01.000Z\"\n    },\n\n  }\n]"
      },
      "name": "Function",
      "type": "n8n-nodes-base.function",
      "typeVersion": 1,
      "position": [
        520,
        300
      ]
    },
    {
      "parameters": {
        "queue": "yourquue",
        "options": {}
      },
      "name": "RabbitMQ",
      "type": "n8n-nodes-base.rabbitmq",
      "typeVersion": 1,
      "position": [
        720,
        300
      ],
      "credentials": {
        "rabbitmq": "asasasasasas"
      }
    }
  ],
  "connections": {
    "Start": {
      "main": [
        [
          {
            "node": "Function",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Function": {
      "main": [
        [
          {
            "node": "RabbitMQ",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}

Thanks sending works, I see different messages in rebbit messages.
The problem is that when messages are received from the queue, they all 3 read as one that went last.
Leaves 3 messages, comes 3 but all as one that was sent last, although in the rebbit logs, if you get the messages, they are all different…

I guess you can read more than one message from the queue. That would be a RabbitMQ question.

Yes, he reads.
Only all 3 unique messages are sent I get as 3 identical messages.
Workflow is executed 3 times with the same message, although I sent to RabbitMQ different messages in the log it is visible.

hm, that is strange. I actually tested the RabbitMQ node this morning and when I did send 3 different messages I did also receive 3 different messages.

Do you have an example workflow that shows the problem you have?

Yes everything is correct, the messages from RabbitMQ come as they were sent, but then when I connect a few more Node, something strange happens, all recorded as one message sent.

As I understand each call, with RabbitMQ should initiate the entire Workflow process from the beginning?

Consumer Workflow
{
  "name": "CusDev_Workouts_Sending",
  "nodes": [
{
  "parameters": {},
  "name": "Start",
  "type": "n8n-nodes-base.start",
  "typeVersion": 1,
  "position": [
    250,
    300
  ]
},
{
  "parameters": {
    "operation": "update",
    "application": "app55LWjwlTcLazSI",
    "table": "workout",
    "id": "={{$node[\"RabbitTrigger\"].json[\"id\"]}}",
    "updateAllFields": false,
    "fields": [
      "type"
    ],
    "options": {}
  },
  "name": "SetDelivered",
  "type": "n8n-nodes-base.airtable",
  "typeVersion": 1,
  "position": [
    1030,
    550
  ],
  "credentials": {
    "airtableApi": "Airtable"
  }
},
{
  "parameters": {
    "chatId": "={{$node[\"RabbitTrigger\"].json[\"fields\"][\"tg_id\"][0]}}",
    "text": "={{$node[\"RabbitTrigger\"].json[\"fields\"][\"message\"]}}",
    "additionalFields": {}
  },
  "name": "SendWorkoutToUser",
  "type": "n8n-nodes-base.telegram",
  "typeVersion": 1,
  "position": [
    700,
    810
  ],
  "credentials": {
    "telegramApi": "Telegram CusDev Bot"
  },
  "disabled": true
},
{
  "parameters": {
    "keepOnlySet": true,
    "values": {
      "string": [
        {
          "name": "type",
          "value": "delivered"
        }
      ]
    },
    "options": {}
  },
  "name": "SetType",
  "type": "n8n-nodes-base.set",
  "typeVersion": 1,
  "position": [
    850,
    550
  ]
},
{
  "parameters": {
    "conditions": {
      "boolean": [
        {
          "value1": true,
          "value2": "={{$node[\"RabbitTrigger\"].json[\"fields\"][\"tg_id\"] !== undefined}}"
        }
      ]
    }
  },
  "name": "TgIdExist?",
  "type": "n8n-nodes-base.if",
  "typeVersion": 1,
  "position": [
    450,
    650
  ]
},
{
  "parameters": {
    "queue": "cusdev_workouts",
    "options": {
      "durable": true,
      "jsonParseBody": true,
      "onlyContent": true
    }
  },
  "name": "RabbitTrigger",
  "type": "n8n-nodes-base.rabbitmqTrigger",
  "typeVersion": 1,
  "position": [
    270,
    550
  ],
  "credentials": {
    "rabbitmq": "n8n_rabbit"
  }
}
  ],
  "connections": {
"SetType": {
  "main": [
    [
      {
        "node": "SetDelivered",
        "type": "main",
        "index": 0
      }
    ]
  ]
},
"TgIdExist?": {
  "main": [
    [
      {
        "node": "SetType",
        "type": "main",
        "index": 0
      }
    ]
  ]
},
"RabbitTrigger": {
  "main": [
    [
      {
        "node": "TgIdExist?",
        "type": "main",
        "index": 0
      }
    ]
  ]
}
  },
  "active": false,
  "settings": {
"executionTimeout": 300,
"saveExecutionProgress": "DEFAULT",
"errorWorkflow": "23"
  },
  "id": "25"
}

Sorry, do not totally understand what you mean.

Not sure right now if it is possible that multiple messages arrive at the same time. In this case you can try to change the expression on the Airtable-Node “SetDelivered” from
{{$node["RabbitTrigger"].json["id"]}}
to
{{json["id"]}}

You get an empty field when you update Airtable, which causes an error.

Video with problem - https://drive.google.com/file/d/1Wn1Ps0QDDCbtTINgu5H3mASKNAWIzCOK/view?usp=sharing

My understanding is that one message = one thread = one processing context.
Isn’t it supposed to be like that?

Correct, it should normally start one workflow execution for each message. Exactly that also seems to happen in the video. You did send 3 messages, the workflow started 3x, 1x for each message.

Sorry, maybe it is too late at night but I sadly do not understand what is supposed to be wrong in that video. Are you saying all three workflows have exactly the same data? Then the video does not show that as you open just one execution and not any of the other two.

I’ve updated the video, watch it again.
The quality was terrible in the last post, sorry…

https://drive.google.com/file/d/1s2GLCHEyhacvOlEL-jqXWFrdhwhGsPyJ/view?usp=sharing

Sorry, actually is the quality now very bad (360p) that I can literally not see anything.

Maybe you should switch to 1080p?
Perhaps there was video processing…

Ah yes, now also other options are available. Yesterday there was only 360p underneath options. Maybe they really just become available after a while. Will check when I find time.

Okay, I’ll wait, but I want to understand is it a bug? Or my error?

Thanks a lot. The video was very helpful. Now I was able to reproduce the problem. It looks definitely like a bug. We will have a look and try to fix.

Just fixed the issue. Will be released with the next version. Gonna update here once it is available.

2 Likes