Passing dynamic info to shell_command

it should works with double quoting “”{{ variable }}"" in the shell command
then add it to your service call

- service: shell_command.speak
  data_template:
    variable: '{{"this%20in%20only%20a%20test."}}'

as for url escaping you could try a cli tool, here’s a few ideas https://github.com/robbyrussell/oh-my-zsh/blob/master/plugins/urltools/urltools.plugin.zsh