Building a Telegram Bot with AWS API Gateway and AWS Lambda

Поделиться
HTML-код
  • Опубликовано: 20 авг 2024
  • This video demonstrate making a simple serverless Telegram bot that can shorten a Long URL, using AWS API Gateway and AWS Lambda.
    Prerequisite:
    -----------------------
    In-depth intuition on Webhooks-Push-Styled API with Hands-On Demo
    • In-depth intuition on ...
    Build a Github Webhook handler with API Gateway & AWS Lambda
    • Build a Github Webhook...
    Documentation for cleanuri API:
    --------------------------------------------------------
    cleanuri.com/docs
    To Steup Webhook for Telegram Bot:
    -------------------------------------------------------------------
    api.telegram.o...{HTTP Token}/setWebhook
    Code:
    -----------------
    import json
    import requests
    def lambda_handler(event, context):
    print(event)
    try:
    body=json.loads(event['body'])
    print(body)

    message_part=body['message'].get('text')
    print("Message part : {}".format(message_part))
    data = {'url': message_part}
    payload=requests.post('cleanuri.com/a...)
    short_url=payload.json()['result_url']
    print("The short url is : {}".format(short_url))
    chat_id=body['message']['chat']['id']
    url = f'api.telegram.o...{HTTP Token}/sendMessage'
    payload = {
    'chat_id': chat_id,
    'text': short_url
    }
    r = requests.post(url,json=payload)
    return {
    "statusCode": 200
    }
    except:
    return {
    "statusCode": 200
    }
    Check this playlist for more Data Engineering related videos:
    • Demystifying Data Engi...
    Snowflake Complete Course from scratch with End-to-End Project with in-depth explanation--
    doc.clickup.co...
    🙏🙏🙏🙏🙏🙏🙏🙏
    YOU JUST NEED TO DO
    3 THINGS to support my channel
    LIKE
    SHARE
    &
    SUBSCRIBE
    TO MY RUclips CHANNEL

Комментарии • 19

  • @yilmazdaskafa
    @yilmazdaskafa 11 месяцев назад +3

    This was very helpful, thank you.

  • @saisreedhar954
    @saisreedhar954 Год назад +1

    thanks for the video
    if we try to get image from telegram bot, what changes we need to change ....

  • @jagermeister5
    @jagermeister5 Год назад +1

    Thank you very good tutorial!

    • @KnowledgeAmplifier1
      @KnowledgeAmplifier1  Год назад

      You are Welcome Amit! Happy Learning & wish you a very Happy New Year

  • @cristiancornacchiola4362
    @cristiancornacchiola4362 Год назад +1

    Thanks for the video, it is possible to use docker to package everything even the modules. Do you have information on how to do it? Thank you

  • @tcsanimesh
    @tcsanimesh Год назад +1

    Thanks for the video!

    • @KnowledgeAmplifier1
      @KnowledgeAmplifier1  Год назад

      You are Welcome Animesh Sen! Happy Learning

    • @tcsanimesh
      @tcsanimesh Год назад

      @@KnowledgeAmplifier1 Can you please make one video on CORS and how to handle it using AWS services

  • @xavier2586
    @xavier2586 10 месяцев назад

    Pure gold

  • @lupobrando2827
    @lupobrando2827 Год назад

    Sometimes if i click the cleanuri url it gives.....unwanted results (xxx material) instead of the wanted url. Why?

  • @KetanRathod-dm9ep
    @KetanRathod-dm9ep Год назад +1

    It shows me error that enable to load request in lambda how to deal with it ??

    • @KnowledgeAmplifier1
      @KnowledgeAmplifier1  Год назад

      Hello Ketan Rathod, if you are facing issue with request module import part , then that means the module is not available as part of lambda default execution env. Might be you are using Python 3.9 or some python version where request module is not available , to resolve the issue there are 2 options --
      1)Use lambda deployment zip or Lambda Layer
      For Lambda deployment zip , you can refer this --
      ruclips.net/video/9hsdnLrx4iE/видео.html
      For Lambda Layer , you can refer this --
      ruclips.net/video/0Q4yV7Hb7Vs/видео.html
      2)Use Python 3.7 as execution env as done in this video.
      Hope this will help in resolving issue .. Happy Learning

  • @cunny1307
    @cunny1307 Год назад +1

    Do one with node pls

    • @KnowledgeAmplifier1
      @KnowledgeAmplifier1  Год назад +1

      cunny , if you are referring with node js , then sorry , I don't have experience with node js .. in future if I learn this , then will update ..

  • @yuriiserebriakov6085
    @yuriiserebriakov6085 Год назад +1

    How are you using requests library in Lambda?

    • @KnowledgeAmplifier1
      @KnowledgeAmplifier1  Год назад +1

      Hello Yurii Serebriakov, requests library is available in default Lambda Execution environment for Python 3.7 , for hight version , you might need to create Lambda Layer or deployment zip ...

  • @charankumar2304
    @charankumar2304 Год назад

    send the json event please