Apple script to add tagged items to todoist

First of all Thank you for the help!
this did the trick:

final script number one:

on performSmartRule(theRecords)
	repeat with theRecord in theRecords
		tell application id "DNtp"
			set this_subject to (name of theRecord) as Unicode text
			set the_reference to (the reference URL of theRecord) as string
			set link_text to "[" & (this_subject) & "](" & (the_reference) & ")"
		end tell
		
		set encoded_task to do shell script "/usr/bin/python -c 'import sys, urllib; print urllib.quote(sys.argv[1])' " & quoted form of link_text
		set theURL to "todoist://addtask?content=" & (encoded_task)
		tell application "System Events" to open location theURL
		
		tell application "System Events"
			delay 0.3
			keystroke return
			delay 0.3
		end tell
	end repeat
end performSmartRule

@BillW this should work with Omnifocus, too. you would just need to replace the todoist link with “omnifocus:///add?name=” - please note: the link might not be formatted correctly in Omnifocus, but as I’m not a user, I can’t test this. maybe you need to add the “note” parameter to the called link and paste “the_reference” there…

as I mentioned here I already installed the CLI tool for todoist.
A few trial and errors and I got it working now and the addtask window won’t appear, it just happens in the background.
my script looks like this:

on performSmartRule(theRecords)
	repeat with theRecord in theRecords
		tell application id "DNtp"
			set this_subject to (name of theRecord) as Unicode text
			set the_reference to (the reference URL of theRecord) as string
		end tell
		
		do shell script "$HOME/path/to/the/script/scripts/addSubjectWithLink.sh " & "\"" & this_subject & "\" \"" & the_reference & "\""
		
	end repeat
end performSmartRule

and the shell script I run:

#!/bin/bash
/usr/local/bin/todoist add "[$1]($2)"

I’d be happy to help if someone else needs this.