/chalice-linebot

LINE BOT on AWS Lambda + API Gateway using Chalice

Primary LanguagePythonMIT LicenseMIT

title

LINE BOT on AWS Lambda + API Gateway using Chalice.

Functions

Command Image
Greeting greeting
Choice choice
Shuffle shuffle
Weather weather
News news
Echo echo

Development

Requirements

Because of AWS Lambda's restrictions, Supported python version is 2.7 only.

  • beautifulsoup4
  • chalice
  • line-bot-sdk
  • feedparser

Setup environment

$ virtualenv -p python2.7 venv
$ source venv/bin/activate
$ pip install -r requirements.txt -r requirements-dev.txt -c constraints.txt

Running tests

$ python -m unittest tests

How to run

Setup

Create .chalice/config.json :

$ cat .chalice/config.json
{
  "app_name": "linebot", 
  "stage": "dev"
}

Environment Variables

Set environment variables on your AWS console.

export LINE_BOT_CHANNEL_ACCESS_TOKEN=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
export LINE_BOT_CHANNEL_ACCESS_SECRET=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

Deploy to AWS Lambda and API Gateway

Deploying by chalice cli:

$ chalice deploy

Configuration on LINE DEVELOPERS

Open your line bot setting's page and Set WebHook url.

https://hoge.execute-api.ap-northeast-1.amazonaws.com/dev/callback

Success! 🎉

LICENSE

MIT. See LICENSE