Skip to content

jesusgn90/url-shortener-telegram-bot-aws-lambda

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

URL shortener Telegram bot using AWS Lambda

Based on tutorial seen here: https://iamondemand.com/blog/building-your-first-serverless-telegram-bot/.

Install dependencies

yarn global add serverless
yarn install

Obtain a Telegram bot token

Chat with @BotFather to create a new bot, then copy the generated token.

Setup serverless.yml

cp serverless.yml.example serverless.yml

Now, edit serverless.yml and change the service name and the TELEGRAM_TOKEN value.

Deploy the application

yarn deploy

Copy the endpoint URL, you should see something like this:

endpoints:
  POST - https://XXXXXXX.execute-api.us-west-2.amazonaws.com/dev/short-bot

Set the webhook URL for the Telegram bot:

TELEGRAM_TOKEN="YOUR_TOKEN_HERE"
SERVERLESS_URI="https://XXXXXXX.execute-api.us-west-2.amazonaws.com/dev/short-bot"
curl --request POST \
  --url "https://api.telegram.org/bot$TELEGRAM_TOKEN/setWebhook" \
  --header "content-type: application/json" \
  --data "{\"url\": \"$SERVERLESS_URI\"}"

About

URL shortener Telegram bot using AWS Lambda

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published