This project provides a webhook endpoint for receiving and processing event notifications from a LINE Messaging API. The endpoint receives messages from a LINE bot, processes the messages and replies accordingly. It features the use of a key-value database - Vercel kv (a simple Redis-like interface using the Vercel SDK) to store incoming messages.
-
Receiving Events: Upon successfully setting up of webhook URL and enabling the usage of webhooks on the LINE Developers console, the endpoint will start receiving webhook events from a LINE bot.
-
Event Processing: Each webhook event represents a single user action in LINE app. The endpoint is able to handle text message event types and replies to them.
-
Storing Messages: Incoming messages, including message ID, user ID, and message timestamp, are stored in Vercel kv.
-
Replying to Messages: The endpoint is capable of replying to the message events. The reply is made through LINE Messaging API's reply message functionality.
-
Message View Page: This page displays messages saved in the database by user ID. You can view all messages exchanged for each LINE user.
-
Event Log Page: This page shows a log of all incoming webhook events. It's useful for debugging and understanding the behavior of your LINE bot.
To configure the LINE Bot, set these environment variables in your .env file:
CHANNEL_SECRET=your_channel_secret
CHANNEL_ACCESS_TOKEN=your_channel_access_token
- Clone the repository.
- Install dependencies using
npm install
. - Run the server using
npm run dev
. - Set your webhook URL on LINE Developers console to point to your local or production server.
In addition to the above, you will need to set up Vercel KV storage:
-
Link Your Project: Run
vercel link
in your CLI to connect to your existing project. If you don’t already have a project to connect to, you can start with a KV template. -
Pull Environment Variables: Run
vercel env pull .env.development.local
to sync the environment variables to your local project. -
Install the SDK: Run
npm install @vercel/kv
to add the Vercel KV SDK to your project. This package provides utilities for working with Vercel's key-value storage .
Send the text message to your LINE bot. The bot will reply with "You said: {message_content}".
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.