I’m trying to parse the content of an incoming email to extract a start and end date for use in creating a Google calendar entry.
As I’ve not done anything like this before, I’ve tried doing it in small steps and now think I have all the small steps working but don’t know how to bring them together in the action of an automation, First off, I’ve got an automation that’s triggered by the incoming email and extracts the strings representing the dates. This works successfully:
I just don’t know how to combine this all into a single action i.e. the logic to extract and translate the date strings plus creating the Google calendar event. Can someone point me in the right direction?
You just need to set your Jinja variables up as Script/YAML variables. Also, if the first regex “works successfully” to extract the desired string from the text, there’s no reason to repeat variations of it multiple times. Just extract the date range string and process it with more efficient string methods.
You haven’t shared how the IMAP is set up, but for something like this you need to have some filtering so you don’t end up with a bunch of false calendar events. If you did that during the setup of the IMAP integration, great. Otherwise, make sure to include it in the trigger and/or conditions blocks.
Thank you, I think your variables insight pushed me over the finishing line!
I knew I didn’t need to repeat the regex, I was just doing separate proof of concepts as best I could to satisfy myself the different elements worked before I joined them up and tidied them.
Yes, I’ve added some extra filtering now the core functionality is working. It’s also on a separate IMAP mailbox which only has very specific messages forwarded to it.