This repository hosts a bot written in Koa that makes a message block on LINE messenger with appointments on Google Calendar by calling Google Calendar API.
The above screenshot is a given date on Google Calendar. As shown, there are 2 appointments made during the day.
The app will invoke Google API to get appointments of a given day from the calendar and map it to message form in LINE. Furthermore, the "Ask" button can be used to reply to a certain event.
There are a few steps to take to get the app started:
Follow the docuentation here to finish the setup.
As for the webhook URL
, let's leave it for later once we setup a public https
connection and come back to it.
Meanwhile, fill in the keys in .env
file.
Go to Google Developers and create a project there.
Navidate to Google Calendar
and click on credentials
tab. Here you can create an OAuth 2.0 Client ID for the project.
Select Desktop
for Application Type and then you can download the credentials in json format.
Rename it to credentials.json
and place it in project root folder.
Clone the repo and install dependencies:
npm install
Launch the app:
docker compose up
Now the endpoint is revealed at http://localhost:3000
.
However, in order to use the endpoint as a webhook on LINE, it is mandatory to have an https
link.
Create a user and follow best practice in IAM.
Assign APIGateway
and EC2
full access policies to the group where you assign your IAM user.
The docker image can be deployed to AWS EC2.
Based on personal experiment, t2.small
tier with 12GB of storage is enough to host the project.
Binding it with API Gateway will then get you an https
link, which you can put in LINE developer console.
- See logging from CloudWatch
- Refactor service in serverless fashion, i.e. using Lambda
Any feedbacks are welcomed!