Telegram Notification not working

Hi, trying to have notification on Telegram.
Took template of official documentation and just modified relevant data.

type: http
name: http_default

log_level: debug


format: |
  {
   "chat_id": "-XXXXXXX",
   "text": "
     {{range . -}}  
     {{$alert := . -}}  
     {{range .Decisions -}}
     {{.Value}} will get {{.Type}} for next {{.Duration}} for  triggering {{.Scenario}}.\r\n https://www.shodan.io/host/{{.Value}}
     {{end -}}
     {{end -}}
   "
  }

url: https://api.telegram.org/bot71765765:AAH2vhgfhgfdhgfhfghgfhfhhfghfhgsad/sendMessage

method: POST
headers:
  Content-Type: "application/json"

But is not working. Form debug log i clearly see that POST is sent without text.

time="28-04-2022 14:28:26" level=info msg="received signal for http_default config" @module=http-plugin

time="28-04-2022 14:28:26" level=debug msg="adding header Content-Type: application/json" @module=http-plugin

time="28-04-2022 14:28:26" level=debug msg="making HTTP POST call to https://api.telegram.org/bot71765765:AAH2vhgfhgfdhgfhfghgfhfhhfghfhgsad/sendMessage with body {\n \"chat_id\": \"-XXXXXXX\", \n \"text\": \"\n   192.168.1.238 will get ban for next 4h for  triggering crowdsecurity/ssh-bf.\\r\\n https://www.shodan.io/host/192.168.1.238\n   \"\n}\n" @module=http-plugin

time="28-04-2022 14:28:26" level=debug msg="got response {\"ok\":false,\"error_code\":400,\"description\":\"Bad Request: message text is empty\"}" @module=http-plugin

time="28-04-2022 14:28:26" level=warning msg="HTTP server returned non 200 status code: 400" @module=http-plugin```

Any idea?

Regards
1 Like

Hi, just want to share solution found by myself.
In code example there is typo:

change from this:

format: |
  {
   "chat_id": "-XXXXXXXX",

to this:

format: |
  {
   "chat_id": XXXXXXX,

so without “-” (minus) and double quotas
Regards

1 Like

Thanks for sharing that with us!

This does not work for me, i keep getting the following response:
level=warning msg=“HTTP server returned non 200 status code: 400” @module=http-plugin

I have double checked the API and Chat id (by thge way, my chat ID starts indeed with the minus symbol -).
Any suggestions?
Thank you all

Hi, tried without “-” ?

Yes tried without - also without “”.
No luck so far

Can you post yuor configuration? Also entire logs.