iCal Integrations

There are several different ways you can integrate iCal with Indigo Pro, but the most obvious is to have Indigo Pro act on an iCal alarm somehow. Unfortunately, Apple doesn't publish an API for writing custom alarms, so doing this requires some round-about configuration. However, it's completely doable. If you're using Indigo Pro 5 or later, the iCal Alarm Processor plugin is the perfect solution for you. But if you are using an older version of Indigo Pro you can use the script described on this page.

The How-to level of difficulty is Moderate. Note that this requires your Indigo Server machine to be running all the time, and Apple Mail must also be running.

Here is what's required before you start:

  • Indigo Pro (Sorry Lite users, this one is Pro only)
  • Apple Mail (iCal uses Mail to send email alarms and we talk to Apple Mail to get the calendar event time)
  • A mail account (preferably a separate account from one you use every day)
  • An Address Book entry for yourself (iCal uses emails in the Address book as destination emails for Alarms - you should already have one that was created when you got your Mac)

Create the Mail account in Mail.app

  1. Set up Apple Mail to check mail for your account (note: this must be on the machine that you're running the Indigo Server on)
    • Follow the instructions in Mail for creating a new account, making a note of the Description of the account (we'll use that in the AppleScript later when we're checking for new mails).

Download the Script file from the File Library

Go to the File Library and download the “iCal Alarm Processor” script. Remember where you save it because you'll need to find it in the next step - I find it handy to just put it in the /Library/Application Support/Perceptive Automation/Indigo 4/Scripts/ folder: that way, it also shows up in the Scripts menu item in Indigo (if you're running the Client on the same machine as the server).

By default, this script will have your Mac speak the Name of the event and what time it starts through your Mac's built-in speakers (if you're using Airfoil, it will get redirected wherever you have Airfoil set as output). It can also execute an Action Group whenever an Alert Email is received.

There are four properties at the top of the script that you should pay attention to:

  • The first property tells the script the Description (name) you gave the account in the Mail settings. Change the value in between the quotes to match that name. This change must be made for the script to work.
  • The second property controls whether your mac will speak or not. It's set to true by default so you should hear your computer say the name of the event and the time it starts. Change true to false and it will stop speaking the event.
  • The third will enable the script to read specially formatted directives that you can insert into the Notes field of the event. Be careful if you turn on this feature, however, since this could be a security risk: if you have actions in an Action Group, Trigger, or Time/Date Action OR have triggers firing based on variable changes, any of these things could be triggered remotely by someone with enough knowledge of your system. An Indigo directive is a tag in the Notes field of an iCal event that is formatted in a special way:
[Set Variable]
varname1goeshere=variable 1 value here
varname2goeshere=variable 2 value here

[Execute Actions]
group=Action Group 1 Name here
tdaction=Time/Date Action Name here
trigger=Trigger Name here

Note the formatting: the directive name is enclosed in square braces on a separate line directly followed by name=value pairs. For the Set Variable directive, the name of the variable is first, the value of the variable is second. For the Execute Actions directive, the name is one of 3 options: “group” for an action group, tdaction for a Time/Date Action, or “trigger” for a Trigger. The value is the name of the item. I've broken Set Variable out from Execute Actions in terms of activation - the thinking is that setting a variable is (potentially) less of a security risk han executing an action. NOTE: After all of the directive name/value pairs, there must be a blank line.

  • The fourth is the name of an action group that will be executed each time we find an Alarm email. You can change the name “iCal Alarm Group” (leave the quotes) to the name of an action group that you already have defined in Indigo Pro or create an action group with that name. Anything in the action group will be executed when there's an Alarm email.
  • The last property tells the script how many times to loop while waiting for a new message to show up. Sometimes Mail lags behind Indigo when finding new messages, so the loop will allow it to catch up. This property will make sure that the script doesn't loop forever.

Create the Email Received Trigger in Indigo

OK, now that you know what you need, you have the script file ready, and the mail account has been created, here's the step-by-step instructions to perform in Indigo:

  1. Set Indigo up to scan your email account.
    1. Select Server Preferences… from the Indigo menu
    2. Select the Email tab
    3. Fill out the top of the form (all the fields under Email Scanning) with information for your mail account
    4. Make sure that you select the checkbox next to Check email every and specify how often you want to check for new iCal Alarms
    5. When you're done, click OK
  2. Create a Trigger Action that will trigger whenever an alarm email is scanned - it will then do some stuff
    1. Select TRIGGERS from the outline view on the left
    2. Click the New… button
    3. Name the trigger whatever you want
    4. Select Email Received from the Type: popup
    5. Check the Only if: radio button (so that it will only trigger when we get an Alarm email from iCal)
    6. Check the subject contains: checkbox
    7. Type “Alarm -” into the text box beside subject contains: (don't include the quotes). When iCal sends an email Alarm, the subject line always starts with “Alarm -” so that will be our trigger
    8. Click the Actions tab
    9. Select Execute AppleScript from the Type popup
    10. Make sure the File: radio button is checked
    11. Click on the Choose… button next to File:, and select the script you just saved.
    12. Once Finished with any changes to the AppleScript, click the OK button

Final Steps

  1. Open Address Book and make sure that your card (the one with the silouette of a person) has the email address that you're planning to use added to the card. iCal won't let you type in a destination email address for alarms; it will only allow you to chose one that's associated with your address book entry.
  2. Almost done. The last thing is to create an event in iCal and set the alarm to Email and set the address to the address book entry that you want to use (the same one that you configured at the top of this How-To in Mail)

That's it! Next time iCal sends out a reminder for an event, Indigo Pro will get it and perform whatever actions you want. Note: the AppleScript above could, in fact, get the entire iCal entry and all it's parts and do much more complex things. If you're interested in learning more about AppleScript, we'd suggest you get AppleScript: The Definitive Guide, 2nd Edition by Matt Neuburg. It's a very good overview and reference in one book.

ical.txt · Last modified: 2019/01/26 00:10 (external edit)

© Perceptive Automation, LLC. · Privacy