Telegram Bot Lambda Boilerplate using Zappa + Hug + Telepot
Switch branches/tags
Nothing to show
Clone or download
kianhean Merge pull request #1 from dfpoon/master
Some hands-on refinements on your boilerplate
Latest commit 82530de Mar 10, 2018
Permalink
Failed to load latest commit information.
.gitignore
Pipfile
Pipfile.lock add pipfile.lock Jan 8, 2018
app.py
readme.md Update readme.md Mar 11, 2018
set_webhook.py
zappa_settings.json initial commit Jan 6, 2018

readme.md

Telegram Bot Lambda Boilerplate using Zappa + Hug + Telepot

Git Clone this repo

git clone https://github.com/kianhean/telegrambotawslambda.git

Initial setup

pipenv --three
pipenv install

Make sure you have installed Zappa and awscli in your project directory

pipenv install awscli
pipenv install zappa

Setup Your Project Variables

Open zappa_settings.json and replace with the name of your project

create a AWS IAM role for zappa

(please refer to reference)

Setup Your Telegram Bot's Key

If you dont have one please go to @botfather to get one

Open app.py and replace with your key from botfather

Deploy on AWS Lambda

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

Telling Telegram your Bot is alive

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!

Updating your bot

Updates to your bot can be done and then sent to production using

zappa update

Tips

  1. 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.

Some useful reference

  1. https://medium.freecodecamp.org/how-to-build-a-server-less-telegram-bot-227f842f4706
  2. https://taiosolve.xyz/first-steps-with-aws-lambda-zappa-flask-and-python-3/
  3. https://www.viget.com/articles/building-a-simple-api-with-amazon-lambda-and-zappa/