I have users contact info saved as a vCard within a JSON object. I’d like to access this and extract the elements (Name, Tel, Email etc) into JSON elements to that I can access/reference them individually within n8n.
I’ve found a few resources online to support with this - like this npm library (https://www.npmjs.com/package/vcard) and whilst I read that it is possible to use external libraries with n8n - I’m not sure if it is whilst hosting my instance on n8n Cloud.
Would love to hear from other n8n user who either know how to do this, or have accomplished something similar via any means that could sit in n8n.
Hi @Felix_is_stuck, this sounds like quite a challenge to build yourself without a designated node. Luckily, this problem has already been solved, for example here:
You could for example use such parser code in a Function node. Here is an example using the above parser and then reading the full name (which just takes the first value from the FN field) as well as the home address (which performs a bit of filtering for demo purposes):
Ah, I didn’t add any checks as to whether the respective element exists in my example code. So when trying to extract a non-existing field, you’d indeed get an error (probably something like Cannot read property '0' of undefined).
I don’t know much about vcards and all the different formats they could have, but have added some checks using the ternary operator in the below example: