Used Automator to automatically insert file path; now "~a" is substituted with "ã"
Solution 1:
I found a way to fix this!
This automation doesn‘t work like copy and paste. It "mocks" the user and "presses" the exact keys as in the string. On my keyboard, when I press ⌥N and then A, I get "ã". However, when I press ⌥N and then Space and THEN "A", I get "~a". So the solution is to add a space after the ~:
on run {input, parameters}
tell application "System Events" to keystroke "/Users/johnappleseed/Library/Mobile Documents/com~ apple~CloudDocs/University"
return input
end run