title: Telegram bot webhook and amazon lambda
body: <p>I've tried to create my first telegram bot hosting the code as an amazon lambda instance, i suppose i should return something to the webhook 'cause it keep saying &quot;Wrong response from the webhook: 502 Bad Gateway&quot;.</p>
  <p>Here is part of my code:</p>
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>def msgSend(text, chat_id):
      url = URL + "sendMessage?text={}&amp;chat_id={}".format(text, chat_id)
      response = requests.get(url)
      content = response.content.decode("utf8")
      return content
  
  
  def handle(msg):
      sender = msg['from']['username']
      id_gruppo = msg['chat']['id']
      if sender == NAME:
          testo = msg['text']
          usernames = [x.replace('@','') for x in rx.findall(text)]
          map(foo, usernames)
          msgSend(confirm_mess, id_group)
          return
  
  
  def main(event, context): 
      response = ast.literal_eval(event['body'])
      handle(response['message'])
      return {
          'something': 'something'
      }</code></pre>
  </div>
  </div>
  </p>
  <p>Actually the process works fine enough, the messages are received by my lambda and everything works like a charm, except for one thing, the confirmation message is sent over and over endlessly and the webhooks never marks the messages as read.</p>
  <p>here is the response of getWebHookInfo:
  {&quot;ok&quot;:true,&quot;result&quot;:{&quot;url&quot;:&quot;https://t2rt9guj3h.execute-api.us-west-2.amazonaws.com/prod/instabot&quot;,&quot;has_custom_certificate&quot;:false,&quot;pending_update_count&quot;:19,&quot;last_error_date&quot;:1489331750,&quot;last_error_message&quot;:&quot;Wrong response from the webhook: 502 Bad Gateway&quot;,&quot;max_connections&quot;:40}}</p>
  <p>According to the bot helper the wh requires a 2XX code response...</p>
  <p>Any idea about that?</p>