Telegram broadcast: Message malformed

Hello, trying to create automation and broadcast telegram message, but getting error “Message malformed: expected dict for dictionary value…”. What should I do please?

image

It seems service data is not correct.

RTFM?

1 Like

While reading the fine manual should always be your first check, that particular page is a bit cryptic if you are just starting out and toying around with the developer tools.

Compare this correct use of the developer tools to the docs to see how it is presented in the docs:

Screenshot_2021-01-30 Developer Tools - Home Assistant

I have two Telegram bots set up, one for system messages and one for general alerts. I am using the system message bot in this case.

EDIT: actually that is the notify service (a lot easier) if you wan to use the Telegram send message service, press this button then edit the data it creates (you can delete whole lines you don’t need):

Hello, in the meanwhile I RTFM and put the message in correct format. The other problem was that I was using telegram bot instead of broadcast. However, I do not see in list of services the “notify.telegram_system”. How do I get it there? My configuration.yaml is this:

telegram_bot:
  - platform: broadcast
    api_key: 1607xxx147:AAHLayxxxxxxxxxxOmeGR0C72ZdzJaq9rbI
    allowed_chat_ids:
      - 41xxxxx74 # example id of a user
      #- -987654321  # example id of a group, starts with a -

How do I get to that service configuration page? In my Home Assistant settings is no service tab.

telegram_bot:
  - platform: webhooks
    api_key: !secret telegram_api_key
    allowed_chat_ids:
      - !secret telegram_general_chat_group_id
      - !secret telegram_system_chat_group_id
      - !secret telegram_tom_id
    trusted_networks:
      - 149.154.160.0/20
      - 91.108.4.0/22
notify:
- platform: telegram
  name: telegram_general
  chat_id: !secret telegram_general_chat_group_id

- platform: telegram
  name: telegram_system
  chat_id: !secret telegram_system_chat_group_id

Click the circle with your initials in the lower left of the side menu to get to your profile. Enable “advanced Mode”.

Sorry but still cannot get it to work. Configuration is like this:

# Example configuration.yaml entry
telegram_bot:
  - platform: broadcast
    api_key: 160xxxx47:xxxxxxxxgC5_OmeGR0C72ZdzJaq9rbI
    allowed_chat_ids:
      - 41xxx674 # example id of a user
      #- -987654321  # example id of a group, starts with a -
      
notify:
- platform: telegram
  name: telegram_general
  chat_id: 41xxx674

- platform: telegram
  name: telegram_system
  chat_id: 41xxx674

then in GUI I have this configuration but it still does not work:
image

The manual says:

This integration creates notification services to send, or edit previously sent, messages from a Telegram Bot account configured either with the polling platform or with the webhooks one, and trigger events when receiving messages.

So, only polling or webhooks, not broadcast (where did you see that setup?). I recommend using webhooks over polling for efficiency.

Thanks for your effort and help. I was trying to set up according to this page. Dont you have an example?

OK I got it working through set up of Telegram platform, not broadcast. The documenation about platform is more clear.

Hi.

I have an automation like this :

alias: Çolak - Merhaba (Duplicate) (Duplicate)
description: ''
trigger:
  - platform: event
    event_type: telegram_text
    event_data:
      text: Where are you from?
    id: '1'
    context: {}
condition: []
action:
  - service: notify.telegrambot
    data:
      message: I am from New York
mode: single

I wonder if I can use more than one text for this automation ? Or maybe is there a way to filter out some keywords from the text and action to be fired. Like instead of writing “Where are you from?” telegram bot should also understand "where from ? ". If text filtering is not possible how can I use multiple texts in one trigger ?

Any help will be appreciated.