title: Prevent getting old updates from Telegram Bot API using a web hook
body: <p>I'm writing a Telegram bot and I'm using the <a href="https://core.telegram.org/bots/api" rel="noreferrer">official bot API</a>. I've got a webhook server that handles requests and sends a <code>200 OK</code> response for every request.</p>
  
  <p>Before the server stops, the webhook is detached so Telegram does not send updates anymore. However, whenever I turn the bot on and set the webhook URL again, Telegram starts flooding the webhook server with old updates.</p>
  
  <p>Is there any way I can prevent this without requesting <code>/getUpdates</code> repeatedly until I reach the last update?</p>
  
  <p>Here's a heavily simplified version of how my code looks like:</p>
  
  
  
  <pre class="lang-js prettyprint-override"><code>var http = require('http'),
      unirest = require('unirest'),
      token = '***';
  
  // Attach the webhook
  unirest.post('https://api.telegram.org/bot' + token + '/setWebhook')
      .field('url', 'https://example.com/api/update')
      .end();
  
  process.on('exit', function() {
      // Detach the webhook
      unirest.post('https://api.telegram.org/bot' + token + '/setWebhook')
          .field('url', '')
          .end();
  });
  
  // Handle requests
  var server = http.createServer(function(req, res) {
      res.writeHead(200, { 'Content-Type': 'text/plain' })
      res.end('Thanks!');
  });
  
  server.listen(80);
  </code></pre>
  
  <p>Thanks in advance.</p>