skip to Main Content

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?

4

Answers


  1. 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)
    
    Login or Signup to reply.
  2. In a browser send the following request:

    https://api.telegram.org/bot655390656:bhFS50...ff3zO4/setwebhook
    
    Login or Signup to reply.
  3. 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()
    
    Login or Signup to reply.
  4. 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]

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search