Parameter not recieving any value in script

I’ve got a problem trying to get parameters to work in a script.

It’s fairly basic in that it expects a parameter called “message” which I then use to post to slack.

My script:

data:
  message: '{{ message }}'
  target: '#general'
service: notify.slack_notify

When I test it using the call services in the developer tools, it fails with the message:

There was a Slack API error while sending to general: The request to the Slack API failed. The server responded with: {‘ok’: False, ‘error’: ‘no_text’}

which I’m taking as the message parameter had no value.

The service data i’m using from the developer tools is:

data_template:
  message: "test"

Other things I’ve tried include:

data_template:
  message: {{ "test" }}

and combinations there of with the brackets.

In the script, I replaced {{ message }} with a hard coded value and it works.

Please help.

  • Danny

shameless bump for help.

Can we see the whole thing?

This is from my scripts.yaml file:

post_to_slack_home_log:
  alias: Post To Slack Home Log
  icon: mdi:slack
  max: 10
  mode: queued
  sequence:
  - data:
      message: '{{ message }}'
      target: '#general'
    service: notify.slack_notify

And the automation that is firing the script please?

I was calling it from Developer Tools > Services selecting “script.post_to_slack_home_log” as the service and the service data:

data_template:
  message: "test"

That should be fine if you’re on 115, anything earlier you need data_template instead of data in the script.

I’m on 115.1. Any ideas why it isn’t passing the message parameter into the script?

No, any errors in the log?

Other than:

There was a Slack API error while sending to general: The request to the Slack API failed. The server responded with: {‘ok’: False, ‘error’: ‘no_text’}

I couldn’t see anything else.

Configuration file validation also shows no errors.

No idea, sorry :man_shrugging:

Oh, hang on, you’re just doing this from the developer tools? You need to remove the data_template line and just put

message: "This is a test"