This project is a FastAPI application that integrates with LINE Messaging API, Gemini AI, and Firebase to handle various types of messages and provide intelligent responses.
Our purpose is to develop a line bot to take care of our emotion. Users can record their daily emotions through the mood diary we provide. More information: https://www.canva.com/design/DAGKOx1JxqQ/TYKOf6XbZlJaWx0x4J4LDg/view?utm_content=DAGKOx1JxqQ&utm_campaign=designshare&utm_medium=link2&utm_source=uniquelinks&utlId=h3c581fbcd7
- Health Check Endpoint: Simple endpoint to check if the service is running.
- LINE Webhook Handler: Handles incoming messages from LINE and responds accordingly.
- Gemini AI Integration: Uses Gemini AI to process and generate responses based on the content of the messages.
- Firebase Integration: Stores and retrieves chat history from Firebase.
- Mood Diary HTML: https://github.com/Celinelinlin/celinelinlin.github.io
- Python 3.7+
- LINE Messaging API account
- Gemini AI API key
- Firebase project
- .env file with the following environment variables:
API_ENVLINE_CHANNEL_SECRETLINE_CHANNEL_ACCESS_TOKENLOGFIREBASE_URLGEMINI_API_KEYOPEN_API_KEY
-
Clone the repository:
git clone <repository_url> cd <repository_directory>
-
Create and activate a virtual environment:
python -m venv venv source venv/bin/activate # On Windows use `venv\Scripts\activate`
-
Install the dependencies:
pip install -r requirements.txt
-
Create a
.envfile in the root directory and add the required environment variables.
-
Run the FastAPI application:
uvicorn main:app --host 0.0.0.0 --port 8080 --reload
-
The application will start and listen for incoming requests on the specified port.
- GET /health: Health check endpoint to verify if the service is running.
- POST /webhooks/line: Webhook endpoint to handle incoming messages from LINE.
API_ENV: Set toproductionordevelop.LINE_CHANNEL_SECRET: Your LINE channel secret.LINE_CHANNEL_ACCESS_TOKEN: Your LINE channel access token.LOG: Logging level (default isWARNING).FIREBASE_URL: Your Firebase database URL.GEMINI_API_KEY: Your Gemini AI API key.OPEN_API_KEY: Your Open Data API key.
The application uses Python's built-in logging module. The log level can be set using the LOG environment variable.
This project is licensed under the MIT License.