Telegram Channel Error: The webhook could not be saved by Telegram, seems to be an invalid URL

Infos:

  • Used Zammad version: 5.2.x
  • Used Zammad installation type: package
  • Operating system: Ubuntu 20.04
  • Browser + version: Brave 1.39.11

Expected behavior:

  • Telegram Bot to be added successfully

Actual behavior:

  • Error “The webhook could not be saved by Telegram, seems to be an invalid URL.” is shown and the bot is not added

  • am using https as the http_type and have a proper fqdn for the site
  • the site is also externally accessbile

Steps to reproduce the behavior:

  • Add telegram bot using the standard procedure

Thank you,.

I tried running this over Postman:

https://api.telegram.org/bot<Redacted BOT ID>/setWebhook?url=https://<Redacted URL>/api/v1/channels_telegram_webhook/<Redacted random 10 digit number>?bid=<Redacted BOT ID>

And it registered the webhook in Telegram but this obviously does not register the bot in Zammad so it doesn’t completely work. This gave me confidence that the instance URL / FQDN was good so am not sure where its going wrong.

I found out that the channels_telegram_webhook seems to be treated as some markup and it is translated to channels<u>telegram</u>webhook. Searching through the forum I found this Is the markup interpretation in overview names intentional?

But could not find how to avoid the markup. Does anyone know?

Hello,
I have the same issue.

1 Like

I got around this problem by changing the version to 5.1.1 . Zammad added bots .

I couldn’t find a way to escape the pair of underscores and resorted to a hack for now

I edited /opt/zammad/lib/telegram.rb

Replaced:
callback_url = "#{Setting.get('http_type')}://#{Setting.get('fqdn')}/api/v1/channels_telegram_webhook/#{callback_token}?bid=#{bot['id']}"

with

callback_url = "#{Setting.get('http_type')}://#{Setting.get('fqdn')}/api/v1/channels%5ftelegram%5fwebhook/#{callback_token}?bid=#{bot['id']}"

then edited /opt/zammad/vendor/bundle/ruby/3.0.0/bundler/gems/telegramAPI-fb62dd5b48b0/libvi telegramAPI.rb and replaced:

def setWebhook url
    self.query("setWebhook", {"url"=>URI::encode(url)})
end

with:

def setWebhook url
    self.query("setWebhook", {"url"=>url.gsub("%5f", "_")})
end

Restarted the Zammad service and I could successfully register the Telegram bot.

I’m sure there is a way to escape it but I cannot for the life of me find the place where it is marking up the strings. Hoping someone will point me to the place, more than happy to push a contribution once I get this info.

did everything, but the error remains

Hi.
The reason I think is that:

didn’t work either =(

didn’t work for me too :frowning:

Did you restart the zammad service after editing the 2 files?

Hi @javierwonghf ,

The file /opt/zammad/vendor/bundle/ruby/3.0.0/bundler/gems/telegramAPI-fb62dd5b48b0/libvi telegramAPI.rb was slightly different in my instance (5.2.1)

In the original file I had

self.query("setWebhook", {"url"=>URI::encode_www_form([url])})

and not

self.query("setWebhook", {"url"=>URI::encode(url)})

I did the replacement with

def setWebhook url
    self.query("setWebhook", {"url"=>url.gsub("%5f", "_")})
end

Then a zammad restart and now it works! thank you.