Telegram configuration error

Hello. I decided to add notifications to Telegram. I paste a sample from the Telegram documentation into the configuration file and get an error

Setup of package ‘telegram.’ failed: Invalid package definition ‘telegram.’: invalid slug telegram. (try telegram). Package will not be initialized.

I spent two days and did not understand what my mistake was… I didn’t find anything like this either on the forum or on the Internet. Help please, what am I doing wrong?

# Telegram Bot
telegram_bot:
  - platform: polling
    api_key: !secret telegram_apikey
    allowed_chat_ids:
      - !secret telegram_chatid

# Notifier
notify:
  - platform: telegram
    name: "ha_bot"
    chat_id: !secret telegram_chatid

Does your secret include the leading dash in the chat id?

It should. e.g.

secrets.yaml

telegram_general_chat_group_id: -112233445566

Yes, there is a hyphen there.
I tried writing all the data into the code, but the error still does not go away.

# Telegram Bot
telegram_bot:
  - platform: polling
    api_key: "2343231423:ХХХХХХХХХХХХХХХХХХХХХХХХХХХ"
    parse_mode: html
    allowed_chat_ids:
      - 123456789

# Notifier
notify:
  - platform: telegram
    name: "ha_bot"
    chat_id: 123456789

I tried to do it with a space - 123456789 and without a space -123456789

Definitely no space.

Where are you putting this config?

Hmm, there is a space in the documentation

The code is placed in a separate configuration file. The path is specified in the main file

homeassistant: 
  packages: !include_dir_named packages

I found what was wrong. The configuration file was called telegram.yaml As soon as I renamed the file how to sendmessage.yaml the error disappeared. Мaybe it’s a function word. :thinking:

Now there is a problem with sending. The service is called without errors, but the message does not reach the telegram.

service: notify.ha_bot
data:
  message: test message

api_key and chatid are correct.

PS. Sorry if the questions are stupid, I used Domstick before, but now I decided to switch to HA.

it should look like this:

    allowed_chat_ids:
      - -123456789

One dash is a list in YAML the other dash is part of the group chat id.

Oh, I’m not writing to a group, I’m writing to a user

allowed_chat_ids:
      - CHAT_ID_1 # example: 123456789 for the chat_id of a user
      - CHAT_ID_2 # example: -987654321 for the chat_id of a group

I removed all links to the secret file and wrote everything in code.
This works correctly and the message has been sent.

# Telegram Bot
telegram_bot:
  - platform: polling
    api_key: "2343231423:ХХХХХХХХХХХХХХХХХХХХХХХХХХХ"
    parse_mode: html
    allowed_chat_ids:
      - 123456789

# Notifier
notify:
  - platform: telegram
    name: "ha_bot"
    chat_id: 123456789

Now I’ll try to insert data into the secret.yaml file
Thank you for the clarification

Oh my god,there are 10 lines of code here and I can’t ind the problem :joy: