question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Conflict: can\'t use getUpdates method while webhook is active

See original GitHub issue

I am using the telegraf example to test. I got this error “Conflict: can't use getUpdates method while webhook is active” whenever I try to run the code. I didn’t set up any webhook.

`const Telegraf = require(‘telegraf’) const Router = require(‘telegraf/router’) const Extra = require(‘telegraf/extra’) const session = require(‘telegraf/session’)

const markup = Extra .HTML() .markup((m) => m.inlineKeyboard([ m.callbackButton(‘Add 1’, ‘add:1’), m.callbackButton(‘Add 10’, ‘add:10’), m.callbackButton(‘Add 100’, ‘add:100’), m.callbackButton(‘Subtract 1’, ‘sub:1’), m.callbackButton(‘Subtract 10’, ‘sub:10’), m.callbackButton(‘Subtract 100’, ‘sub:100’), m.callbackButton(‘🐈’, Math.random().toString(36).slice(2)), m.callbackButton(‘Clear’, ‘clear’) ], {columns: 3}))

const calculator = new Router(({ callbackQuery }) => { if (!callbackQuery.data) { return } const parts = callbackQuery.data.split('😂 return { route: parts[0], state: { amount: parseInt(parts[1], 10) || 0 } } })

calculator.on(‘add’, (ctx) => { ctx.session.value = (ctx.session.value || 0) + ctx.state.amount return editText(ctx) })

calculator.on(‘sub’, (ctx) => { ctx.session.value = (ctx.session.value || 0) - ctx.state.amount return editText(ctx) })

calculator.on(‘clear’, (ctx) => { ctx.session.value = 0 return editText(ctx) })

calculator.otherwise((ctx) => ctx.reply(‘🌯’))

function editText (ctx) { if (ctx.session.value === 42) { return ctx.answerCbQuery(‘Answer to the Ultimate Question of Life, the Universe, and Everything’, true) .then(() => ctx.editMessageText(‘🎆’)) } return ctx.editMessageText(Value: <b>${ctx.session.value}</b>, markup).catch(() => undefined) }

const bot = new Telegraf(“xxxxx:xxxx”) bot.use(session({ ttl: 10 })) bot.start((ctx) => { ctx.session.value = 0 return ctx.reply(Value: <b>${ctx.session.value}</b>, markup) }) bot.on(‘callback_query’, calculator) bot.startPolling()`

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:5

github_iconTop GitHub Comments

40reactions
daspharioncommented, Aug 6, 2018

Try to delete the webhook: https://api.telegram.org/bot<token>/deleteWebhook

0reactions
antoniorbcommented, Sep 2, 2020

Dear Sir,

I’ve done a bot for telegram and it worked but some days ago it appears a problem.

“can’t use getUpdates method while webhook is active; use deleteWebhook to delete the webhook first”

I use the deleteWebhook but it doesn’t work (with the python-telegram-bot). I use the Python 3.6.12 version

data = {“url”: “”} bot = telegram.Bot(‘1126965009:AAFvWCs-Timzw3SDd4LcEIGXmY7cVQE_jOQ’)

if (normalize(update.message.text).upper() == 'HOLA'):
    #bot = telegram.Bot('1126965009:AAFvWCs-Timzw3SDd4LcEIGXmY7cVQE_jOQ')
    chat_id = update.message.chat_id
    bot.sendMessage(chat_id, 'HOLA')
  
    
    #pload = {'chat_id':chat_id,'message_id':'123'}
    #r = requests.get('https://api.telegram.org/bot1126965009:AAFvWCs-Timzw3SDd4LcEIGXmY7cVQE_jOQ/deleteWebhook')
    #r = requests.post('https://api.telegram.org/bot1126965009:AAFvWCs-Timzw3SDd4LcEIGXmY7cVQE_jOQ/deleteWebhook',data = pload)
    r = requests.post('https://api.telegram.org/bot1126965009:AAFvWCs-Timzw3SDd4LcEIGXmY7cVQE_jOQ/setWebhook',data = data)
    respuesta = bot.deleteWebhook()
    bot.sendMessage(chat_id, respuesta)
    respuesta = bot.deleteWebhook()

Could you tell me if there is a problem with that? How I can fix it?

Thank you

Read more comments on GitHub >

github_iconTop Results From Across the Web

can't use getUpdates method while webhook is active
I've done a bot for telegram and it worked but some days ago it appears a problem. "can't use getUpdates method while webhook...
Read more >
error: Conflict: can't use getUpdates method while webhook is ...
error: Conflict: can't use getUpdates method while webhook is active; use deleteWebhook to delete the webhook first #158.
Read more >
Webhook & Updates - Telegram Bot API SDK
There are two mutually exclusive ways of receiving updates for your bot — the getUpdates() method on one hand and Webhooks on the...
Read more >
removeWebhook - Telegram Bot API - PHP SDK
Use this method to remove a previously set outgoing webhook. This is a helper method from the SDK. The Official API doesn't support...
Read more >
deleteWebhook: Remove webhook integration in telegram.bot
Use this method to remove webhook integration if you decide to switch back to getUpdates . Requires no parameters.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found