Hello again n8n community!
I’m trying to transform data output from an Airtable Node to build an array to send to the Telegram API and build a custom inline keyboard.
My Airtable Node is outputting data which looks like this:
[
{
"id": "rec1VJOChv1nkxfN4",
"createdTime": "2021-04-05T16:04:14.000Z",
"fields": {
"Asset ID": "RCE-99-0003",
"Item Name String": "Motorola - EVX-261-G7-5",
"Status": "Available"
}
},
{
"id": "recKrCqheDiw29HgL",
"createdTime": "2021-04-05T19:04:15.000Z",
"fields": {
"Asset ID": "RCE-99-0006",
"Item Name String": "Motorola - EVX-261-G7-5",
"Status": "Available"
}
},
{
"id": "recRZ730mzyVgl3k2",
"createdTime": "2021-04-05T19:04:14.000Z",
"fields": {
"Asset ID": "RCE-99-0005",
"Item Name String": "Motorola - EVX-261-G7-5",
"Status": "Available"
}
},
{
"id": "recdqVya9y7IEWnsJ",
"createdTime": "2021-04-05T19:04:13.000Z",
"fields": {
"Asset ID": "RCE-99-0004",
"Item Name String": "Motorola - EVX-261-G7-5",
"Status": "Available"
}
},
{
"id": "rece2k7GKAvQfRbiH",
"createdTime": "2021-04-05T16:04:14.000Z",
"fields": {
"Asset ID": "RCE-99-0002",
"Item Name String": "Motorola - EVX-261-G7-5",
"Status": "Available"
}
},
{
"id": "reclwjjZuGNCmCLsq",
"createdTime": "2021-04-05T16:04:14.000Z",
"fields": {
"Asset ID": "RCE-99-0001",
"Item Name String": "Motorola - EVX-261-G7-5",
"Status": "Available"
}
}
]
I need to transform this data to look like this:
{
"reply_markup": {
"inline_keyboard": [
[{
"text": "Motorola - EVX-261-G7-5 (Available)",
"callback_data": "rec1VJOChv1nkxfN4"
}
],
[{
"text": "Motorola - EVX-261-G7-5 (Available)",
"callback_data": "recKrCqheDiw29HgL"
}
],
[{
"text": "Motorola - EVX-261-G7-5 (Available)",
"callback_data": "recRZ730mzyVgl3k2"
}
],
[{
"text": "Motorola - EVX-261-G7-5 (Available)",
"callback_data": "recdqVya9y7IEWnsJ"
}
],
[{
"text": "Motorola - EVX-261-G7-5 (Available)",
"callback_data": "rece2k7GKAvQfRbiH"
}
],
[{
"text": "Motorola - EVX-261-G7-5 (Available)",
"callback_data": "reclwjjZuGNCmCLsq"
}
]
]
}
}
Values should be mapped to the new array like so:
{
"reply_markup": {
"inline_keyboard": [
[{
"text": "{fields.['Item Name String']}+' ('+{fields.Status}+')'",
"callback_data": "{id}"
}
]
]
}
}
I’ve spent hours trying to do this myself using some combination of the Item Lists node and jsmepath, but can’t for the life of me figure it out and I would so incredibly grateful if there is someone here that can point me in the right direction!