This project is a LINE bot that listens to messages in a LINE group and summarizes the conversation from the last 24 hours into bullet points upon receiving the trigger command "CHAT SUMMARY". The bot uses the LINE Messaging API and OpenAI's GPT-3 API for generating summaries.
- Listens to messages in LINE groups or individual chats.
- Stores messages in memory for up to 24 hours.
- When triggered by the command "CHAT SUMMARY", it summarizes the last 24 hours' conversation into bullet points using OpenAI's GPT-3.
To run this project, you'll need:
- Python 3.7 or higher
- LINE Channel Access Token and Channel Secret
- OpenAI API Key
The following Python packages are required:
- Flask (for creating the web server)
- line-bot-sdk (for interacting with LINE's Messaging API)
- openai (for GPT-3 integration)
All dependencies are listed in the requirements.txt
file:
To install the dependencies, run:
pip install -r requirements.txt
To configure the bot, set the following environment variables:
LINE_CHANNEL_ACCESS_TOKEN
: Your LINE channel access token.LINE_CHANNEL_SECRET
: Your LINE channel secret.OPENAI_API_KEY
: Your OpenAI API key.
-
Clone the repository:
git clone <repository-url> cd <repository-folder>
-
Install dependencies:
pip install -r requirements.txt
-
Set the required environment variables:
export LINE_CHANNEL_ACCESS_TOKEN='your_line_channel_access_token' export LINE_CHANNEL_SECRET='your_line_channel_secret' export OPENAI_API_KEY='your_openai_api_key'
-
Run the Flask app:
python app.py
-
Use a tunneling service like ngrok to expose the Flask server to the internet:
ngrok http 8080
-
Set the webhook URL in the LINE Developer Console to point to your ngrok URL:
https://<your-ngrok-subdomain>.ngrok.io/callback
- Add the bot to your LINE group.
- The bot will start storing messages from the group.
- To get a summary of the last 24 hours, send the message "CHAT SUMMARY" to the group.
- The bot stores messages in memory, which means it will lose all messages if the server is restarted. For persistent storage, consider integrating a database.
- OpenAI API usage may incur costs depending on the amount of text summarized.
This project is licensed under the MIT License. Feel free to use and modify it as needed.
Contributions are welcome! Please open an issue or submit a pull request if you'd like to improve this bot.