Dial2Do and OmniFocus

The comments in this post at Lifehacker led me to look into Dial2Do, a service similar to Jott that transcribes your voice messages and emails them to you. Unlike Jott, Dial2Do still sends emails for free, so I decided to give it a try and rework my Jott2OmniFocus AppleScript to handle emails from Dial2Do.

The setup at Dial2Do is basically the same as that at Jott: I created a contact with the name “focus” and an email address of the form “johndoe+omnifocus@gmail.com.” I modified the Mail Rule that handles addresses sent to the “+omnifocus” address. The rule, which used to run the Jott2OmniFocus script, now runs a similar script called Dial2Do2OmniFocus. Both scripts are slightly reworked versions of the script supplied with OmniFocus to handle emailed tasks.

Here’s Dial2Do2OmniFocus:

 1:  -- Copyright 2007 The Omni Group.  All rights reserved.
 2:  --
 3:  -- $Header: svn+ssh://source.omnigroup.com/Source/svn/Omni/branches/OmniFocus/1.x/OmniGroup/Applications/Focus/App/Preferences/MailAction.applescript 100519 2008-05-15 21:12:32Z bungi $
 4:  
 5:  using terms from application "Mail"
 6:    -- Trims "foo <foo@bar.com>" down to "foo@bar.com"
 7:    on trim_address(theAddress)
 8:      try
 9:        set AppleScript's text item delimiters to "<"
10:        set WithoutPrefix to item 2 of theAddress's text items
11:        set AppleScript's text item delimiters to ">"
12:        set MyResult to item 1 of WithoutPrefix's text items
13:      on error
14:        set MyResult to theAddress
15:      end try
16:      set AppleScript's text item delimiters to {""} --> restore delimiters to default value
17:      return MyResult
18:    end trim_address
19:    
20:    
21:    on process_message(theMessage)
22:      tell application "OmniFocus"
23:        log "OmniFocus calling process_message in Dial2Do2OmniFocus script"
24:      end tell
25:      -- Allow the user to type in the full sender address in case our trimming logic doesn't handle the address they are using.
26:      set theSender to sender of theMessage
27:      set trimmedSender to my trim_address(theSender)
28:      tell application "OmniFocus"
29:        set AllowedSender to allowed mail senders
30:        if AllowedSender does not contain trimmedSender and AllowedSender does not contain theSender then
31:          beep
32:          return
33:        end if
34:      end tell
35:      
36:      set messageText to the content of theMessage as text
37:      set theTask to paragraph 1 of messageText
38:      tell application "OmniFocus"
39:        tell default document
40:          parse tasks with transport text theTask without as single task
41:        end tell
42:      end tell
43:    end process_message
44:    
45:    on perform mail action with messages theMessages
46:      try
47:        set theMessageCount to count of theMessages
48:        repeat with theMessageIndex from 1 to theMessageCount
49:          my process_message(item theMessageIndex of theMessages)
50:        end repeat
51:      on error m number n
52:        tell application "OmniFocus"
53:          log "Exception in Mail action: (" & n & ") " & m
54:        end tell
55:      end try
56:    end perform mail action with messages
57:  end using terms from

There are only two differences between this script and the Jott version:

  1. The log command in Line 23 now indicates that the OmniFocus task is coming from Dial2Do2OmniFocus.
  2. The task text is taken from the first paragraph of the email body (Line 37) instead of the third. Dial2Do puts the meat at the top of the message instead of in the middle the way Jott does.

That’s it! With those two small changes, Dial2Do messages sent to “focus” will show up in my OmniFocus Inbox for further processing.

If this post seems short on details, it’s because the steps for setting up Dial2Do for OmniFocus are almost exactly the same as those for setting up Jott for OmniFocus. See my Jott and OmniFocus post to fill in the gaps.

Tags: