Send a VCard from a Database with Integromat

A few days ago, I wrote a post about sending iCal (.ics) files from a database with Integromat, using Airtable as the database. Shortly after that, a reader asked me a question - whether a similar process could be built to send VCard files (for address book entries).


It turns out that the structure of a VCard file is not that dis-similar to an iCal file so I decided to write a new article about this. On this occasion, I am going to use Knack as the database (although using Airtable would be very similar - see the iCal article) - in particular my Test database currently has objects for Contacts and Companies (Objects are what Knack call tables). And once again, Integromat will be used to create the file and send it.


The Database


I'm not going to spend much time discussing the database except to say that Contacts contain personal information about a contact and the Company record holds their business address. We're therefore going to have to retrieve both of these records to complete the VCard information.


To trigger the Integromat Scenario, I am going to use an Action Link in Knack (a kind of 'button' you can put in an app to update, send emails etc) to update a field in the Contact Object called SendV Card which is simply a Yes/No field. The Action Link is placed on the Table of contacts as follows:



The Integromat Scenario


With Knack, Integromat has the ability to 'listen' for updates to records and trigger a Scenario immediately. So we need to start our Scenario with a Knack New Event trigger:


Within the module you will need to configure a link to your Contacts object looking for record updates:


Note that you may need to create a connection to your particular database as part of the process of setting this up.


Once this is configured, Integromat will be triggered each time a Contact record is updated - and the next step is to retrieve the actual record that was updated (the trigger step just returns the ID of this record):



Note: the process so far will be triggered by ALL updates to Contact records in the database - and we only want to send VCards for those where Send VCard is set to True (ticked). For this we can simply use a filter following the above step:



Note that the condition uses the Send VCard (raw) field - this contains the boolean values true of false.


I mentioned earlier in the post that the addresses in this database are held in the Companies object - so we also need to retrieve the company record connected to the contact, again using a Get a Record module:



VCard Files


We now have all the data available within the Scenario to create our VCard file - so let's look at the required format. The following basic format should suffice for our purposes:


BEGIN:VCARD

VERSION:3.0

FN;CHARSET=UTF-8:Julian Kirkness

N;CHARSET=UTF-8:Kirkness;Julian;;;

EMAIL;CHARSET=UTF-8;type=WORK,INTERNET:julian@kirkness.com

TEL;TYPE=WORK,VOICE:01228 124124

ADR;CHARSET=UTF-8;TYPE=WORK:;;Stone Stile, Selling;Faversham;Kent;ME13 9SD;UK

TITLE;CHARSET=UTF-8:Director

ORG;CHARSET=UTF-8:KA Software

REV:2019-08-19T14:55:44.197Z

END:VCARD


I worked out this format using an online tool called VCard Maker at https://vcardmaker.com - so if you need to send different or additional content you can generate a template using this. Note that the items in Green will be inserted from the database.


During the process of preparing this post, I discovered that I had one more address line in my database than in the VCard format (I had 2 lines for Street Address). The next module in the Scenario is therefore going to calculate Street Address depending on whether the second line is used - and if so, concatenate the two with a comma between (as in the example above):



It uses an if function in a Set Variable module to either return just Street or, if Street 2 exists, Street 1, Street 2.


Finally, before sending the email, we can now calculate the content of the VCard in a Compose a String module:



If you look carefully, you'll see that this is just the text from above with fields available in Integromat replacing the green text.


Sending the Email


So we can now send an email - and the recipient of the email could be any email address available in your app - but in this case, for simplicity, I am going to simply send it to my own email address:



Note that I have used advanced options (so that I can use HTML in the email) and that the attachment is simply created by giving the file a name (the contact's record id with a .vcf extension) and the data is the text we just created.


Here is a copy of the email this sends:



and here's Oliver Timms added as a contact:



Finishing Up


There's one last step to add to the Integromat Scenario to make this work properly - and that's to reset the Send VCard field to No so that it this record is edited again, but for a different reason, the process won't send the message again. This uses a Knack Update Record module:



and the only field to update is Send VCard:

Conclusion


Integromat is a really powerful tool - especially in conjunction with a powerful database platform like Knack. With these database tools, we are essentially adding a data language to the platform - combined with the ability to integrate with almost anything!


If you's like to find out more about Integromat click here


or Knack click here


And don't forget VCard Maker which is available here





0 views

© 2019 by Kirkness Associate Ltd