Telegram notifications not sent

gonza_cid5 years ago

Hi, I have installed new 4.4 with telegram notifications.

Configuration are:

<entry key='notificator.types'>web,mail,telegram</entry>
<entry key='notificator.Telegram.apikey'>BotApiKey</entry>
<entry key='notificator.Telegram.chatid'>ChatId</entry>

Both keys (bot and chat) are valid and tested. I have test it on HA notificator and works.

Once I have set an alarm in the UI and assig a telegram notification, web and mail I trigger a SOS alarm since device:

  • Mail arrives
  • Web event is register
  • Telegram not sent anything and I can see a waning in the log:
WARN: Telegram API error - javax.ws.rs.NotFoundException: HTTP 404 Not Found - ResponseProcessingException (...)

What can I test?

Anton Tananaev5 years ago

Your configuration is incorrect.

gonza_cid5 years ago

Please, can you indicate me whats the correct?

I was looking in github for the code here and put:

<entry key='notificator.types'>web,mail,telegram</entry>
<entry key='notificator.telegram.key'>BotApiKey</entry>
<entry key='notificator.Telegram.chatid'>ChatId</entry>

with the same result.

Thanks

Anton Tananaev5 years ago

Looks correct. We would need to rename the keys though. The case is all mixed up.

gonza_cid5 years ago

OK, and there is anything I can do to trace it and see the cause of it isn't working?

Anton Tananaev5 years ago

I would recommend to debug the code and see what happens with the request.

Han Wer5 years ago

@GoNzCiD you should first of all make sure the below request works. Keep in mind, that the chat_id is negative (with a "-" in front) for groups in telegram.

$ curl -s -X POST https://api.telegram.org/bot<TOKEN>/sendMessage -d chat_id=<CHAT_ID> -d text="Hello World" 

If this works, there is no reason why it shouldn't work with traccar. Most people are facing problems finding the proper chat_id.

engpro5 years ago

Hello, I was able to run the telegram notifications but I only get the notifications !! How can I add the user to receive notifications of his vehicle via Telegram ??

Rodrigo5 years ago

Hello!!
Can you recommend any bot to use (under win7)??? Simple and beautiful jaja
Greetings and thanks in advance!!

gonza_cid5 years ago

@Han Wer, thanks a lot.

I have tested it and it doesn't work :(, I have tryed with another bot I wich it's key has less special characters in traccar and it works... I'm going to recreate the bot api key!

@Anton Tananaev, maybe traccar log error message should contain the error description additional to request status code, and it helps to identify the problem.

Jose B5 years ago

@GoNzCiD, how did you recreate the bot with less special characters? Maybe it be my traccar server problem.
works for me: curl -s -X POST https://api.telegram.org/bot<TOKEN>/sendMessage -d chat_id=<API_CHAT_ID> -d text="Hello World"
works for me: https://api.telegram.org/bot<MY_TOKEN>/sendMessage?chat_id=<API_CHAT_ID>&text="Hello World"

Regards

JB

gonza_cid5 years ago

I don't know if it was the real reason, but I only request botfather to regenerate the api key.
Try to start a chat from your chat to the bot and then send the message again via api

Jose B5 years ago

@GoNzCiD, maybe it is not the problem. I recreated the bot api key (same standard format - ex: 123456:AAG-Nh2FrLJ6gktlOPPQ5VJ3MmSTuDC6x_8) and did not work on traccar. return WARN: Telegram API error - HTTP 400 Bad Request - BadRequestException (...). any clue ?

JB

shyy5 years ago

Is the phone nomber on the user setting contining the cuntry code?

Jose B5 years ago

@shyy, I already tried using with (+55) and without. Same error on traccar. using "http://...". or "curl -s -X ...." works fine.
JB