This repo creates a LINE Bot. Enter the date and text you want to be reminded of. When the time arrives this Bot will remind you. Similar to Slack reminder.
I've created a front page for this Bot.
You need to have Docker engine running on your local.
cd hello-world
npm install
cd ..
sam build
sam local start-lambda
After Lambda is started, start ngrok and point ngrok to the Lambda:
./ngrok http -subdomain=ezyraise -region ap 3001
Now your local LINE Bot is connected to the internet.
POST https://ezyraise.ap.ngrok.io/2015-03-31/functions/LineBotFunction/invocations
Point the LINE Webhook URL to the ngrok.
Now you can add the LINE Bot to your phone, start interacting with it. All the messages will be sent to your local LINE Bot.
export AWS_PROFILE=
sam build
sam deploy --no-confirm-changeset
The deployment will create a DynamoDB table to store users and messages. When user wants to see all reminders, the Bot will query the DynamoDB.
When you enter a text and date in the LINE Bot, a message will be sent to QStash with the text and the date. Date is converted to epoch time in seconds. QStash is a messaging queue. You can set an attribute notBefore
. notBefore
is the time the message pops off the queue and be sent back to you.
QStash Free Plan only supports 7 days of queuing. I worked around the limit by sending the messsage back to the queue every 7 days, until the desired time has reached.
if (scheduledTimeInSeconds === nextTimeInSeconds) {
// remind user
} else {
// send message back to the queue
}
Model | pk | sk | gsi1pk | gsi1sk | |||
---|---|---|---|---|---|---|---|
User | USER#user_id | USER#user_id | scheduled_reminders_count | created_at | |||
Reminder | UR#user_ud | REMINDER#reminder_id | UR#user_id | status | message | scheduled_at | created_at |
Access Patterns
- get total count of scheduled reminders by user
- get scheduled reminders by user and ordered by scheduled_at
- insert reminder
- update reminder status
- insert user
- get user
- update user's reminder count