This project demonstrates how to create a LINEBot with memory capabilities, allowing for continuous and context-aware conversations. The bot leverages several platforms for its development and deployment.
- LINE Developers: To create and configure the LINEBot.
- Gemini Pro: To enable conversational AI capabilities.
- Google Cloud Functions: To deploy the Python code and generate a webhook for the LINEBot.
- Firebase: To establish a real-time database for storing conversation history.
- Channel type: Set to Messaging API (mandatory).
- Provider: Use an existing one or create a new one if you haven't used it before.
- Other options: Fill in the details as required.
- Bot profile image: Upload a custom image.
- Privacy policy URL, Terms of use URL: These can be left blank.
After creating the bot, find the Channel secret on the Basic Setting page and the Channel access token on the Messaging API page. These will be used in the code.
Note: If you issue or reissue these credentials, remember to update them in your code.
Set aside the bot for now. Once the program is deployed, paste the URL back into the Webhook URL field on the Messaging API page.
Refer to the official Gemini Pro website and tutorials for guidance. Remember to save your API Keys securely as they can only be copied at the time of creation.
Click on 'Get Started'.
Click on 'Add Project' and make sure to enable Google Analytics.
After entering Realtime Database, create a new database in locked mode and then modify it.
Once you see a URL like https://XXX.firebaseio.com/
, that's the URL you'll use in the program to set the data storage location.
In the 'Rules' section, change false
to true
to allow external writes.
Google Cloud offers a suite of cloud computing services, including computing, data storage, data analytics, and machine learning.
Click on 'Console' or 'Start a Free Trial' on the website.
Find Cloud Functions in the menu or under the 'Serverless' category.
Set the environment to the first generation and the region to asia-east1
(Taiwan). Set the trigger to HTTP and allow unauthenticated invocations.
Add four runtime environment variables:
GEMINI_API_KEY
: Your Gemini Pro secret key.LINE_BOT_TOKEN
: Your LINE Developers Channel access token.LINE_BOT_SECRET
: Your LINE Developers Channel secret.FIREBASE_URL
: Your Firebase URL.
After setting up the function, deploy it. Once deployed, you'll find a 'Trigger URL' that you'll paste back into your LINEBot.
You can check the conversation history stored in Firebase.
With this setup, you have successfully created a LINEBot with memory capabilities, allowing for more engaging and contextually aware conversations.