7

I use setWebhook for my telegram-bot and now I need to use getUpdates. I have read the docs, and they say, that I can use only one method.

The problem is, that I have in console:

{"ok":false,"error_code":409,"description":"Error: Conflict: another webhook is active"}

So the question is, how to UNSET webhook and use getUpdates?

Leon
  • 6,316
  • 19
  • 62
  • 97

4 Answers4

13

In a browser send the following request:

https://api.telegram.org/bot655390656:bhFS50...ff3zO4/setwebhook
B.I.
  • 706
  • 3
  • 9
  • 19
11

as mentioned in Telegram bot api documentations you just need to pass empty string to url parameter.

> base_url = 'https://api.telegram.org/bot' + TOKEN + '/'
> data = {"url": ""}
> requests.post(base_url + 'setWebhook', data=data)
Aemir
  • 285
  • 5
  • 14
0

you can just call the method

deleteWebhook()

https://core.telegram.org/bots/api#deletewebhook

for example using telepot

import telepot
bot = telepot.Bot('YOUR_AUTHORIZATION_TOKEN')
bot.deleteWebhook()
pakira79
  • 111
  • 2
  • 5
0

I wrote a small rake task for this job

require 'net/https'

namespace :telegram_custom do
  desc "Deactives webhook - this is needed to enable polling in development"
  task deactivate_webhook: :environment do
    token = "YOUR_BOT_TOKEN"
    base_url = "https://api.telegram.org/bot#{token}/setwebhook"
    uri = URI.parse(base_url)

    res = Net::HTTP.get URI(base_url)
    puts res
  end
end

If you have the token stored in the credentials you can get them via: token = Rails.application.credentials.telegram[:bot]

Bergrebell
  • 4,263
  • 4
  • 40
  • 53