Your exclusive blessing assistant! "Blessing Buddy" is a LINE chatbot that transforms into a "Fubao" (blessing baby) holding a heart, using AI to quickly generate and share beautiful images with warm blessings.
In daily digital communication, a warm greeting image can instantly bring people closer. The birth of "Blessing Buddy" is precisely to make the transmission of this sentiment easier and more personalized. It's like a smiling little cloud of images, always ready to serve you. Users simply make selections, choosing themes and styles, and can attach custom blessing messages. AI will then generate a customized image full of warmth, allowing you to easily share warmth and blessings with every important person in your life.
- Themed Generation: Built-in multiple blessing themes, such as
Good Morning,Happy Birthday,Health and Peace, etc. - Style Customization: Supports diverse artistic styles like
Soft Realistic,Oriental Ink Wash,Illustration, etc. - Custom or AI Blessing Messages: In addition to entering your own blessing text, you can also choose AI (Google Gemini) generated messages.
- Dual AI Engines: Integrates Pollinations.ai for artistic image generation and uses Google Gemini to produce creative blessing texts.
- Instant Sharing: After generation in LINE, images can be instantly forwarded to friends or groups with one click.
- Lightweight Design: Images are transmitted immediately after generation, not retained on the server, respecting privacy and saving resources.
This project adopts a Serverless architecture, deployed on the Vercel platform, and integrates multiple cloud services to achieve its functionality.
- Platform: LINE Messaging Platform
- Backend: Node.js / TypeScript
- Deployment: Vercel Serverless Functions
- AI Image Generation: Pollinations.ai
- AI Text Generation: Google Gemini API
- Image Processing:
@napi-rs/canvas(High-performance Node.js canvas tool) - Image Storage: Cloudinary (for temporary image storage and public URL generation)
This project uses Redis to temporarily store user conversation states to ensure a smooth user experience.
The system saves the temporary state when the user makes a selection:
- Theme Selection: Records the
Themeselected by the user. - Style Selection: Records the
Styleselected by the user.
The system uses the user's sourceId (User ID) as the key to store the UserState object.
To allow for restart and prevent state confusion, data in Redis is deleted in the following scenarios:
- Flow Completion: System automatically clears the state after the image is successfully generated and sent to the user.
- Manual Reset: Old state is cleared if the user inputs trigger keywords (like "Start", "Generate Image") to restart the flow.
- Auto Expiration: If the user is inactive for 5 minutes (default
300seconds) after a selection, Redis TTL (Time To Live) mechanism will automatically delete the data.
To protect your privacy and optimize resources, this service adopts an "Instant Generation, Instant Deletion" policy for image processing:
- Upload Timing: Immediately after the AI generates the image and overlays the text, the system uploads the image to Cloudinary to obtain a public URL.
- Deletion Timing: Once the image URL is successfully sent to you on LINE, the system waits for approximately 10 seconds (buffer time) before calling the deletion command to remove the image from Cloudinary.
- Reason for Deletion:
- LINE Forwarding Mechanism: After the image is sent via LINE, it is temporarily cached on LINE's servers. You can directly forward or share it without relying on the Cloudinary link.
- Cost and Privacy Considerations: This significantly reduces Cloudinary storage costs and ensures that your personalized images are not permanently retained on third-party servers.
Please follow these steps to set up and run this project in your local environment.
Please ensure you have Node.js (recommended v20.x or above) and npm installed in your development environment.
git clone https://github.com/your-username/line-blessing-bot.git
cd line-blessing-botnpm installCopy the .env.example file to .env and fill in your API keys and settings.
cp .env.example .envThen, edit the .env file:
# .env
# LINE Bot
LINE_CHANNEL_ACCESS_TOKEN="YOUR_LINE_CHANNEL_ACCESS_TOKEN"
LINE_CHANNEL_SECRET="YOUR_LINE_CHANNEL_SECRET"
# Google Gemini API
GEMINI_API_KEY="YOUR_GEMINI_API_KEY"
GEMINI_MODEL="gemini-2.5-flash" # Optional, uses default model if not set
# Cloudinary
CLOUDINARY_CLOUD_NAME="YOUR_CLOUDINARY_CLOUD_NAME"
CLOUDINARY_API_KEY="YOUR_CLOUDINARY_API_KEY"
CLOUDINARY_API_SECRET="YOUR_CLOUDINARY_API_SECRET"
# Redis (for State Management)
REDIS_URL="redis://..."npm run devTo allow the LINE platform to forward messages to your local development server, you need a public HTTPS URL. It is recommended to use ngrok to create a tunnel.
ngrok http 3000After starting ngrok, fill in the obtained https- prefixed URL (e.g., https://xxxx-xxxx.ngrok-free.app) into the Webhook URL field in the LINE Developer console, and append /api/index to the URL.
Example: https://xxxx-xxxx.ngrok-free.app/api/index
Now, you can start interacting with your bot on LINE!
| Variable Name | Description | Required |
|---|---|---|
LINE_CHANNEL_ACCESS_TOKEN |
Channel Access Token for LINE Messaging API | Yes |
LINE_CHANNEL_SECRET |
Channel Secret for LINE Messaging API | Yes |
GEMINI_API_KEY |
Google Gemini API Key (for AI text generation) | Yes |
GEMINI_MODEL |
Google Gemini text model (e.g., gemini-2.5-pro) |
No |
CLOUDINARY_CLOUD_NAME |
Cloud Name for Cloudinary | Yes |
CLOUDINARY_API_KEY |
API Key for Cloudinary | Yes |
CLOUDINARY_API_SECRET |
API Secret for Cloudinary | Yes |
REDIS_URL |
Connection URL for Redis database (for state management) | Yes |
.
βββ api/ # Main entry point for Vercel Serverless Functions
βββ assets/ # Static resources, such as custom fonts
βββ src/ # Core project source code
β βββ ai.ts # AI Prompt combination logic
β βββ cloudinary.ts # Cloudinary integration
β βββ config.ts # Environment variables and configuration
β βββ gemini.ts # Google Gemini API integration
β βββ image.ts # Image processing (text overlay)
β βββ state.ts # User state management
β βββ types.ts # TypeScript type definitions
βββ tests/ # Jest test files
βββ themes.json # Theme configuration file
βββ styles.json # Style configuration file
βββ package.json # Project dependencies and scripts
βββ tsconfig.json # TypeScript compiler configuration
Contributions to this project are welcome! You can participate in the following ways:
- Fork this repository.
- Create your feature branch (
git checkout -b feature/AmazingFeature). - Commit your changes (
git commit -m 'Add some AmazingFeature'). - Push to the branch (
git push origin feature/AmazingFeature). - Open a Pull Request.
You are also welcome to open an Issue to report bugs or suggest features.
This project is licensed under the MIT License.



