LINE BOT on AWS Lambda + API Gateway using Chalice.
Command | Image |
---|---|
Greeting | |
Choice | |
Shuffle | |
Weather | |
News | |
Echo |
Chalice-Bot depends a Pillow - Python Imaging Library.
So If you want to create deploy package for AWS Lambda, you must prepare the Amazon Linux.
However, it is very inconvenient to create an instance of EC2 for that.
So please use Dockerfile.deploy
.
Create .chalice/config.json
:
$ cat .chalice/config.json
{
"app_name": "linebot",
"stage": "dev"
}
export AWS_ACCESS_KEY_ID=xxxxxxxxxxxxxxxxxxxx
export AWS_SECRET_ACCESS_KEY=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
export AWS_DEFAULT_REGION=ap-northeast-1
export S3_BUCKET_NAME=xxxxxxxxxxx
export LINE_BOT_CHANNEL_ACCESS_TOKEN=
export LINE_BOT_CHANNEL_ACCESS_SECRET=
Deploying by chalice cli:
$ make deploy
Set environment variables on your AWS console.
export LINE_BOT_CHANNEL_ACCESS_TOKEN=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
export LINE_BOT_CHANNEL_ACCESS_SECRET=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Open your line bot setting's page and Set WebHook url.
https://hoge.execute-api.ap-northeast-1.amazonaws.com/dev/callback
Success! 🎉
Other commands for developing are written in Makefile:
$ make help
Commands:
build Build docker container
deploy Deploy to AWS Lambda and API Gateway
lint Check coding styles
test Run tests
functions Show the list of AWS Lambda functions
help Show help text
MIT. See LICENSE