(1) I am trying to write an embedded script in a Smart Rule which lets me send an iMessage. I get the error shown on the bottom - “Access not allowed.” There is an existing thread to this phone number so I thought access would be permitted. Ideas on how to fix this?
(2) Assuming I can get this working, is there a way that I can include in the iMessage the Item Link to open the record in DT3?
Hi @rkaplan, do you use Keyboard Maestro by any chance? Then this would be very easy to do without AppleScript.
That looks like a permissions issue. Perhaps a dialog asking you for permission to allow DEVONthink to control Messages was missed along the way – these easily can fall behind other windows.
In System Preferences > Security & Privacy > Automation scroll down the right pane to see if there is a combination for DEVONthink 3.app to control Messages where the checkbox is not checked. If so, click the lock in the lower left corner of the preference pane, log in, and then check the unchecked checkbox.
Messages does not have an entry.
Under the Devonthink 3 entry, there is option for Messages.
Good to eliminate that possibility.
Does this change work?
set targetBuddy to buddy "+17248802948" of targetService
or it might be
buddy "+1 (724) 880-2948"
When I examine Messages content in Script Debugger 7 I notice that all the buddies have the contact name from my Contact list. E.g,
buddy "Nelson Algren" rather than
buddy "+1 (888) 555-1212
Yes I do - I love KM.
In fact, I have my Stream Deck set up with a couple buttons to send prefab messages i.e. my 5-year-old knows she can press the button with the picture of mommy and she gets an I love you message.
I see I could easily (as you say) create a smart rule which has the action “Launch URL” and then runs a Keyboard Maestro macro to execute the command “Send iMessage.”
The hard part though is - is there some way to pass a variable from a DT3 smart rule to Keyboard Maestro? In particular I would like the Smart Rule to pass the relevant Item Link to Keyboard Maestro so I can include that as a clickable hyperlink in the iMessage.
That works! Thanks. As a bonus, the first time I ran it I got a prompt to add Messages under Automation/Devonthink.
Now is there some way to include the item link in the iMessage?
tell application id "DNtp"
repeat with theRecord in theRecords
set myLink to (the reference URL of theRecord) as text
---insert the script to tell "Messages" here
---tell application "Messages"
---blah blah blah
Of course, that item link will have no use for your recipient unless they also have that database on their machine or synced in DEVONthink to Go.
I suspect if you do too many of these at once you might run into an iCloud throttle preventing excess messaging (to prevent bots sending spam).
Please excuse @rkaplan my English is not so good.
Here is my example how I send an iMessage to a certain person with a link:
Since I use a german macOS, I will be happy to help you with further questions about the individual actions. Here is the macro for it.
You can start any KM macro using a DT Smart Rule. Simply run the KM macro as AppleScript.
You can find the KM AppleScript with every macro here:
Many thanks - this works great. (I will use it in relatively small volume for myself and a few staff members - I do not think throttling will be a problem.)
For final implementation I combined it with the Reminders Smart Rule - now in addition to whatever other reminder actions I take all reminders will be texted to me along with the Name of the document and its Item Link. Among other things this means I can receive reminders on my iPhone as well as all of my synced computers and can access the document directly with DTTG. Also it is a lot less likely that notifications for an important document will get lost in the noise of all my other MacOS notifications.
For those interested - this is the working Smart Rule
Thanks - I got this working with pure Applescript but it KM may be helpful for future projects. Can I simply pass “name” or “the URL” as parameters to KM?
For myself I would tweak one small thing:
send (myName & return & myLink) to targetBuddy
since Messages accepts carriage returns, and this way you get all the data into one message. Should still be clickable.
For really extra credit, you could probably write a Shortcut on your phone that monitors these messages and auto-adds to Reminders — or just have your smart rule add to reminders on the desktop.
… can’t stop myself from tweaking … but as-is, this is a really interesting rule you created @rkaplan – thank you for the inspiration