Set up Telegram using Nabu Casa

I’m trying to set up Home Assistant using Nabu Casa to send and receive Telegram messages.

So far I’m trying to use a simple ping pong script.

Configuration.yaml:

telegram_bot:
  - platform: webhooks
    api_key: 111111111:AAAAAAAAAAAAAAAAAAAAAAAAAAAAA
    url: https://abcdefghijklmnop.ui.nabu.casa:8443
    allowed_chat_ids:
      - 11111111111

notify:
  - name: Telegram_Bot
    platform: telegram
    chat_id: 11111111111

Then I set up a automation using the automation wizard. I have translated the following YAML

- id: 'A'
  alias: PingPong
  trigger:
    platform: event
    event_type: telegram_command
    event_data:
      command: '/ping'
  action:
    - service: telegram_bot.send_message
      data:
        message: 'pong'

Unfortunately, this doesn’t work upon receiving the messages (in fact, I cannot even see the event). Sending the messages does work on the other hand (via a service or by triggering the automation).

How come I can send messages but I cannot receive them?

I’ve given up on Nabu Casa since I cannot do port forwarding. I am now trying to do the same with DuckDNS but I also cannot get it working. The reaction is the same. I can send messages, but not receive. I’ve tried multiple things:

  • Monitored the event stream by watching for telegram_message and telegram_text, but nothing happens when I send a text to the bot.
  • Monitored the full event stream with node-red debugging, but nothing happens when I send a text to the bot.
  • I checked the open ports and the one I specify for Telegram (8443) is open (from the internet). This means the port forwarding works correctly and something is happening on this port.
  • I have no active Telegram related errors. The platform is set up correctly.
  • Besides, I’m using duckdns for accessing my Home assistant instance and that is working correctly, so it also isn’t the connection.

Latest config:

http:
  base_url: https://xxxxxxx.duckdns.org:8123
  ssl_certificate: /ssl/fullchain.pem
  ssl_key: /ssl/privkey.pem
  server_port: 8123

telegram_bot:
  - platform: webhooks
    api_key: 111111111:AAAAAAAAAAAAAAAAAAAAAAAAAAAAA
    url: https://xxxxxxx.duckdns.org:8443
    allowed_chat_ids:
      - 11111111111

notify:
  - name: Telegram_Bot
    platform: telegram
    chat_id: 11111111111

I have also triple checked the chat_id and it is the same in both config parts. Therefore the chat id shouldn’t be the issue.

Where are you getting url from? Telegram doesn’t require a URL to work, so you don’t even need Nabu Casa.

Check out: https://www.home-assistant.io/components/polling/

Hmm, I’ve been trying the webhooks way since it was recommended as ‘the preferred way’. Switched to polling and now it works indeed without url (tried it also without url with webhooks, but without any effect).

Thanks a lot!