#How to create a script for Telegram?

1 messages ยท Page 1 of 1 (latest)

fallow oar
#

Hi! I've been using the telegram notification system for about (and maybe over) 10 years and use it to send messages to either a group, myself or some channels. Up until the recent update this was working fine but now... I'm actually kinda lost.

I did create a script with an empty message:

action: telegram_bot.send_message
metadata: {}
data:
  config_entry_id: XXXX
  target:
    - "410000000"
  parse_mode: markdownv2
  message: null

Thinking I could call this up within an automation with:

data:
  message: >-
    {% if states('counter.count_times_cv_turned_on') | int() > 0 %} CV went on
    {{ states('counter.count_times_cv_turned_on') }} times today, totalling {{
    states('sensor.cv_verwarmingstijd') }} hours of ON time. {% endif %}TV
    downstairs was turned on during {{ states('sensor.tv_aantijd') }} hours.
action: script.telegram_send_pm_to_myself

But when I execute that, I get an data.message not set: required key not provided @ data['message']. Got None. If I put any text, it doesn't get overwritten. Any ideas on how I can create a script so that I don't have to copy-paste the chat_id into tens of automations?

faint gulch
#

That's not how you use passed-in variables

fallow oar
#

uh thanks for the quick answer! ๐Ÿ˜„ that probably looks like the exact same thing I'm wanting to accomplish, will try it out ๐Ÿ™‚