git clone https://github.com/kianhean/telegrambotawslambda.git
pipenv --three
pipenv install
pipenv install awscli
pipenv install zappa
Open zappa_settings.json and replace with the name of your project
(please refer to reference)
If you dont have one please go to @botfather to get one
Open app.py and replace with your key from botfather
Assuming you have sufficient permissions run the following commands in the shell
pipenv shell
zappa deploy
Take note of the endpoint of your bot. Will look similar to the following
https://xxxxxxx.execute-api.ap-southeast-1.amazonaws.com/dev
Send the following curl to Telegram to inform them of your endpoint. Replace the variables below with your own
curl --data "url=<YOUR URL ABOVE>" "https://api.telegram.org/bot<TELEGRAMAPIKEY>/setWebhook"
(I prefer to use a python script to do so instead. Please refer to set_webhook.py)
The reply returned should be True.
Speak to your bot!
Updates to your bot can be done and then sent to production using
zappa update
- ngrok (https://ngrok.com/) is a very good way to test your code before deploying to AWS lambda. Please refer to item 1 of the reference for details.