This project is a side project that integrates a LINE Bot with OpenAI's GPT model to create an intelligent conversational assistant. The bot is designed to provide helpful and friendly responses to user messages, making it suitable for various use cases such as customer support, personal assistance, or entertainment.
- LINE Bot Integration: The bot is connected to the LINE Messaging API to handle user messages and send replies.
- OpenAI GPT Model: Utilizes OpenAI's GPT model to generate intelligent and context-aware responses.
- Conversation History: Maintains a short conversation history to provide context for better responses.
- Customizable Settings: Easily adjust parameters like response randomness (temperature) and conversation history length.
- Node.js installed on your system.
- A LINE Developer account with a Messaging API channel.
- An OpenAI API key.
-
Clone this repository:
git clone <repository-url> cd <repository-folder>
-
Install dependencies:
npm install
-
Set up environment variables: Create a
.envfile in the root directory and add the following:OPENAI_API_KEY=your_openai_api_key LINE_CHANNEL_ACCESS_TOKEN=your_line_channel_access_token LINE_CHANNEL_SECRET=your_line_channel_secret PORT=8080
-
Start the server:
node index.js
-
Set up the LINE webhook URL to point to your server's endpoint (e.g.,
https://your-domain.com/webhook). -
Interact with the bot through your LINE app.
- Temperature: Adjust the
temperatureparameter in the OpenAI API call to control the randomness of responses. - Conversation History Length: Modify the logic to keep more or fewer messages in the
conversationHistoryarray.
index.js: Main application file containing the server and bot logic.package.json: Project dependencies and scripts.
This project is licensed under the MIT License. Feel free to use and modify it for your own purposes.