Get My ID Bot - AWS Lambda
--Resource
--
1. Create a bot
# Open this bot in telegram
https://telegram.me/botfather
# give the commands
/start
/newbot
# give a name to your bot
# you will get a token . SAVE IT!
2. Prepare zip file
# Open a linux terminal and give this commans to create a lambda function
mkdir /tmp/bot
cd /tmp/bot
pip3 install requests -t .
wget https://raw.githubusercontent.com/techworldthink/Get-My-ID-BOT---Telegram/main/get_myID.py -O lambda_function.py
replace BOT token
zip -r /tmp/bot.zip *
# save this zip file
3. Create Lambda function
# open aws account
# search lambda
# click on create function
# choose Author from scratch , give function name , select runtime Python 3.8
# click on create function
4. Upload code
# open asw account
# search lambda
# select the function you were created
# Code entry type: Upload a .zip file
# Upload bot.zip
5. Time OUT
# open asw account
# search lambda
# select the function you were created
# select configuration
# select General configuration
# set Timeout 35sec
6. Trigger
# open aws account
# search lambda
# select the function you were created
# select configuration
# select Triggers
# set API Gateway
API type: HTTP
Authorization: NONE
Method: ANY
# set CloudWatch Events
Rule name –> get_my_id_bot
Schedule expression –> rate(1 hour)
8. Register webhook at telegram
# open a linux terminal and type it
# AWS_API_GATEWAY (HOw get?)
open aws account
search lambda
select the function you were created
select configuration
select Triggers
select API Gateway
API endpoint = AWS_API_GATEWAY
# Telegram token from https://telegram.me/botfather when you create a bot
AWS_API_GATEWAY=XXX
TELEGRAM_TOKEN=XXX
curl -XPOST https://api.telegram.org/bot$TELEGRAM_TOKEN/setWebhook --data "url=$AWS_API_GATEWAY" --data "allowed_updates=['message','callback_query']"
OR use this method to set up hook instead of use commands in terminal
https://api.telegram.org/bot{my_bot_token}/setWebhook?url={url_to_send_updates_to}
https://api.telegram.org/bot{my_bot_token}/getWebhookInfo
10. How to use
# open telegram bot created by you
get telegram ID
/start