Telegram notification script not working. required key not provided @ data[‘message’]

I’m getting an error “Failed to call service script.keymaster_manual_notify_2. required key not provided @ data[‘message’]. Got None” using the Telegram bot integration. The exact script works with SMTP & Mobile notification but not Telegram. If I use the telegram script with test texts it works. I tried the solution in this thread but I get “Message malformed: extra keys not allowed @ data[‘sequence’][0][‘Service_data’]”

This is the script:

alias: Keymaster manual notify 2
sequence:
  - service: notify.ha_telebot
    data:
      message: "{{ message }}"
      title: "{{ title }}"
mode: parallel

Is there a different syntax for data for telegram bots in scripts? In cards it is service_data, what is it in scripts? From the link you sent it seems the error is receiving the data from “message”. Also in the developer testing section the script without in data provided works for mobile and smtp but only give an error for Telegram. I’m assuming telegram is looking for something else.

Cards are different, scripts and automations follow what’s shown in the docs:

action:
  service: notify.NOTIFIER_NAME
  data:
    title: "*Send a message*"
    message: "That's an example that _sends_ a *formatted* message."

Check the trace for your script to ensure you have an actual message - you need a message

Here a trace:
xecuted: November 2, 2023 at 1:07:08 PM
Result:

params:
domain: notify
service: ha_telebot
service_data:
message: RF unlock operation
title: 4781b_door
target: {}
running_script: false

The message never gets to Telegram, but if I use text instead of data, the message gets to telegram. When testing I get the above error with telegram but not any other notifiers.

Ok, found the issue, it was the “" in “4781b_door”. I removed the "” and the script worked with 4781bdoor.

1 Like