studio3104 / line-bot-chalice

LINE Bot on AWS serverless services powered by AWS Chalice

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

LINE Bot example on AWS serverless services Build Status

This is a sample implementation of LINE Bot that detects labels on sent images by Amazon Rekognition.

image

Workflow Overview

image

  1. User sends a picture to the Bot
  2. LINE server make a callback request to the associated endpoint
  3. Amazon API Gateway invokes the associated AWS Lambda function
  4. AWS Lambda validates the request, and then enqueues the payload into Amazon SQS
  5. Responsing 200 OK
  6. Ditto
  7. Invoking the function triggered by SQS events
  8. Download the image that user sent from LINE server
  9. Calling the detect label API of Amazon Rekognition
  10. Replying the labels of the sent image

Dependencies

Prerequisite

LINE Messaging API

https://developers.line.biz/en/services/messaging-api/

You need to sign up and register your API via the site above.
And take a copy of channel secret and channel access token.

AWS Services

AWS CLI

Install and configure AWS CLI referring the following guides.
AWS Chalice depends on the credential settings configured by the procedre.

Amazon SQS

Create Amazon SQS queue, and take a copy of its queue name.
Note that the visivility timeout of the queue have to be more than 60, otherwise the queue cannot integrate with AWS Lambda function.

Deployment

Configuration

This sample project has an example configuration file.
You need to copy (or rename) the file and configure appropriately.

$ cp .chalice/config.json.exapmle .chalice/config.json
$ cat .chalice/config.json
{
  "version": "2.0",
  "app_name": "LINEBotWorkshop",
  "autogen_policy": false,
  "iam_policy_file": "policy.json",
  "stages": {
    "dev": {
      "api_gateway_stage": "api",
      "environment_variables": {
        "SQS_QUEUE_NAME": "",
        "LINE_CHANNEL_SECRET": "",
        "LINE_CHANNEL_ACCESS_TOKEN": ""
      }
    }
  }
}

Installing dependencies

Activate the virtual environment as needed before performing this procedure

$ pip install requirements.txt

Deploy

Once dependencies are successfully installed, you can run chalice deploy command

$ chalice deploy

License

This library is licensed under the MIT-0 License. See the LICENSE file.

About

LINE Bot on AWS serverless services powered by AWS Chalice

License:MIT No Attribution


Languages

Language:Python 100.0%