Do print(msg.url()) in the script that you want to send a message to, and you’ll see the correct URL.
print(msg.url())