I am working on a ZAP to get information about a thread in LiveChat. I am calling a webhook and I get json similar to this:
{
"id": "CHATID",
"users": :],
"thread": {
"id": "XXXXXXX",
"tags": :
"CREATE FRESHDESK TICKET"
],
"events": :
{
"id": "1",
"type": "message",
"text": "Thanks for stopping by, how can we help? ",
},
{
"id": "2",
"type": "message",
"text": "hi",
},
{
"id": "3",
"type": "file",
"name": "test.png",
"url": "",
"content_type": "image/png",
"width": 100,
"height": 100,
"size": 12010
},
{
"id": "4",
"type": "message",
"text": "here is a file to test getting attachments",
},
{
"id": "5",
"type": "system_message",
"text": "archived the chat",
"system_message_type": "manual_archived_customer",
}
]
}
}
What I want to do now is look to see if there are any file attachments. The problem is that when I pass it to a Code step, it returns the items as a strings for the child objects. So, each child object property is grouped by properties, so I get events type, events text, etc.. The issue is that if the first element is blank it removes them. So, while file is element two (zero based indexes) when I look at events type, the corresponding events name element doesn’t exist, because it is element 0. It is a bit frustrating as when you see fields that are being passed to the Code step, it shows “,,test.png,” for events name, but when I split the string, it just has one element. How are others handling this? I really just want to grab the events with a type of file and then process them. Thanks.
Wade