A few days ago, a client asked me whether it was possible to send a calendar entry from their bookings table to create calendar entries for the members booking onto an event. At first, I couldn't see how this could be done but I did some research about .ICS files (files used to email calendar entries) and, realising that they're just text files, decided to have a go. This turned out to be quite simple and so I've put together this post to help other people do the same using Airtable and Integromat.
The Airtable Base
I've added an Events and a Bookings table to my Test database for the purposes of this post:
If you're intending to follow this article, then you should set up tables with these or similar fields - including the Created field which is a Created Time field type which is used to control which records trigger Integromat.
iCalendar (.ics) Files
As I've already mentioned, .ics files are just text files with an .ics extension - and the contents are fairly simple. There is a great deal of information available on the web about the format but none is terribly clear for the non-techie and it isn't easy to find out what the minimum content would be. I decided to experiment a little and have come up with the following content for this scenario:
BEGIN:VCALENDAR
VERSION:2.0
CALSCALE:GREGORIAN
BEGIN:VEVENT
UID:recaDDT3MYHWHLfqt.ics
SUMMARY:Integromat Training
DTSTART;TZID=Europe/London:20190810T120000
DTEND;TZID=Europe/London:20190810T173000
LOCATION:Faversham
DESCRIPTION:This is a course to introduce you to Integromat
STATUS:CONFIRMED
END:VEVENT
END:VCALENDAR
The values marked in green are where variable information is included from the database. Note in particular the required format for the Date/Time values.
The UID value is a unique identifier for the calendar entry (which is calculated in this case as the ID of the booking record and .ics on the end) and is the same as the file name of the file we are going to create/send. Including a UID (which is optional) means that if you send an update to the calendar entry it will edit the existing entry rather than creating a new one (as long as you use the same UID).
When you come to build your own Integromat Scenario you can copy the above and replace these items with fields from the database.
Creating the Integromat Scenario
At the start of building any Integromat Scenario (the name given to a process built in Integromat), you need to decide what you are going to use to trigger the process. In this case we're looking for new records added to the Bookings table and so use the Watch Records option which is configured as follows:
Note the Trigger field set to the Airtable field {Created}. Integromat needs this to determine which is the next new record to process.
Now, the booking record doesn't actually include all the information we need to create the calendar entry - for example the Start and End date/time values aren't there. We could include them in the Bookings table as Lookup fields but this would make the table busier and less user friendly. For this reason, we'll use another Integromat 'module' to get the associated Event record from the database. To do this we use a Retrieve a Record module with the following configuration:
The Record ID field is what is needed to find the linked Event - and the ID can be selected from the previous module by clicking the value shown.
So, we have the two records we need to build our iCalendar file and send it by email to the person booking. The next step is where we create the .ics file content and I've found that a Compose a String module is the one to use:
Having selected Compose a string, this is how it needs to be configured:
You can see how the values are included from the database - and note how the dates are configured using Integromat's formatDate function - this is where you find this:
Now that we have the text for our .ics file, all we have to do is use an email module (I'm using Office 365 email here but Gmail will also work). If you're new to Integromat you'll probably need to connect Integromat to your mail account first (use Add under the Connection field).
And, further down the settings, the clever part is attaching the text we created as a file - which is as simple as this:
In other words, set the file content to the value we created in the Compose a string module and then use the booking id with a .ics extension as the filename.
So, we're now finished - and it really is that simple (using Integromat) - here's a copy of the email this sends:
You can find out more information about Integromat here
and Airtable here.
And the following articles about .ics files may be useful:
Commentaires