Help trying to script Airmail 3

Hi folks
I’m trying to script Airmail 3, I know it is not very scriptable but my script is quite simple. If I select an email in airmail 3 and select my script from the scripts menu it performs as I expected. However, if I attach it to an Airmail 3 rule (another poor area) it does not work. I am assuming that the rule is not actually selecting the email. Does anyone know how I might achieve this? Thank you.

The script parses an email from IFTTT and creates an item in my shopping list in Omnifocus (it works fine with Apple Mail):

activate application "Airmail 3"
tell application "Airmail 3"
	set theSubject to subject of selected message
	set theContent to content of selected message
	set messageURL to get id of selected message
	set messageURL to "<message://%3C" & messageURL & "%3E>"
	set theProject to ">Shopping list"
	set theText to theSubject & theProject & return & messageURL & return & return & theContent
	tell application "OmniFocus"
		parse tasks into default document with transport text theText with as single task
	end tell
	move selected message to trash
end tell