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
This was very helpful, thank you.
Glad it was helpful!
thanks for the video
if we try to get image from telegram bot, what changes we need to change ....
Thank you very good tutorial!
You are Welcome Amit! Happy Learning & wish you a very Happy New Year
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
Thanks for the video!
You are Welcome Animesh Sen! Happy Learning
@@KnowledgeAmplifier1 Can you please make one video on CORS and how to handle it using AWS services
Pure gold
Thank you! Happy Learning
Sometimes if i click the cleanuri url it gives.....unwanted results (xxx material) instead of the wanted url. Why?
It shows me error that enable to load request in lambda how to deal with it ??
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
Do one with node pls
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 ..
How are you using requests library in Lambda?
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 ...
send the json event please