AI Content Assistant - Setup Guide
Walks through setting up a Gemini API key, configuring environment variables, and using an AI assistant for content generation across platforms.
What this file does
Walks through setting up a Gemini API key, configuring environment variables, and using an AI assistant for content generation across platforms.
When to use it
- Integrating a Gemini-powered content assistant into a campaign or post editor
- Adding platform-aware AI text generation for social media and messaging
- Providing users with a UI for generating image prompts from descriptions
- Offering iterative content refinement with chat history in a session
Assumes this stack
AI Content Assistant - Setup Guide
Quick Start
1. Get Gemini API Key
- Visit Google AI Studio
- Sign in with your Google account
- Click "Create API Key"
- Copy the generated key
2. Add to Environment Variables
Add this line to your .env file:
GEMINI_API_KEY=your_api_key_here
3. Restart Development Server
# Stop the current server (Ctrl+C)
# Then restart
npm run dev
Usage
Accessing the AI Assistant
- Navigate to any campaign post edit page
- Look for the floating Sparkles icon (✨) in the bottom-right corner of the message textarea
- Click the icon to open the AI Content Assistant dialog
Generating Text Content
- Quick Suggestions: Click any suggestion badge for instant generation
- Custom Prompts: Type your own request in the input field
- Platform-Aware: AI automatically adjusts tone based on selected platform
- Refinement: Continue the conversation to refine the generated content
Example Prompts:
- "Create an engaging LinkedIn post about our new product launch"
- "Make this message more professional"
- "Add emojis and make it fun for Instagram"
- "Shorten this to under 160 characters for SMS"
Generating Image Prompts
- Switch to the "Image Prompt" tab
- Describe the image you want
- Click "Generate Image Prompt"
- Copy the optimized prompt
- Use it with DALL-E, Midjourney, or Stable Diffusion
Example:
- Input: "A modern tech product on a clean background"
- Output: Detailed professional prompt optimized for image generation
Platform-Specific Features
The AI automatically adapts to your selected platform:
| Platform | AI Behavior |
|---|---|
| Professional format with subject line | |
| SMS | Concise, under 160 characters |
| Casual, friendly with emojis | |
| Engaging, conversational (1-2 paragraphs) | |
| Short, catchy with hashtags | |
| Professional, business-focused | |
| YouTube | Compelling descriptions with keywords |
| Descriptive and inspiring |
Features
✨ Smart Features
- Context Awareness: AI knows your platform and existing content
- Chat History: Continue conversations to refine content
- Quick Actions: Insert, Copy, or Apply generated content
- Platform Suggestions: Get platform-specific prompt ideas
- Real-time Generation: Fast responses (typically 2-5 seconds)
🎯 Use Cases
- Writer's Block: Get started with AI-generated drafts
- Content Refinement: Improve existing messages
- Tone Adjustment: Change from casual to professional (or vice versa)
- Platform Optimization: Adapt content for different platforms
- Idea Generation: Brainstorm creative angles
- Image Planning: Create detailed image prompts
Tips for Best Results
Writing Effective Prompts
✅ Good Prompts:
- "Create a professional LinkedIn post announcing our Q4 results with a positive tone"
- "Make this message more engaging and add 3 relevant emojis"
- "Shorten this email to 2 paragraphs while keeping the key points"
❌ Avoid:
- "Make it better" (too vague)
- Single words without context
- Extremely long prompts (keep under 200 words)
Iterative Refinement
- Start with a basic prompt
- Review the generated content
- Use follow-up prompts like:
- "Make it shorter"
- "Add more details about [topic]"
- "Change the tone to be more [casual/professional/friendly]"
Platform Selection
Always select your platform before opening the AI assistant for best results. The AI uses this context to generate appropriate content.
Troubleshooting
"API key not configured" Error
Solution: Make sure you've added GEMINI_API_KEY to your .env file and restarted the dev server.
Slow Generation
Possible causes:
- Network latency
- Complex prompts
- API rate limiting
Solutions:
- Simplify your prompt
- Wait a few seconds and try again
- Check your internet connection
Content Not Inserting
Solution:
- Make sure you click the "Insert" button (not just "Copy")
- Check that the dialog closes after insertion
- Verify the content appears in the textarea
Image Generation Not Working
Note: The current implementation generates optimized image prompts, not actual images. You'll need to:
- Copy the generated prompt
- Use it with an image generation service (DALL-E, Midjourney, etc.)
- Upload the generated image to your post
API Limits
Gemini API Free Tier
- 60 requests per minute
- 1,500 requests per day
- 1 million tokens per month
For production use, consider:
- Implementing rate limiting
- Monitoring usage
- Upgrading to paid tier if needed
Security Notes
- ✅ API key is stored server-side only
- ✅ User authentication required
- ✅ Prompts are not logged or stored
- ✅ Generated content is session-only (not persisted)
Support
Common Questions
Q: Can I use this for all post types? A: Yes! The AI assistant works with Email, SMS, WhatsApp, and all social media platforms.
Q: Does it remember previous conversations? A: Chat history persists during your current session but resets when you close the dialog.
Q: Can it generate images directly? A: Currently, it generates optimized prompts for image generation services. Direct image generation may be added in future updates.
Q: Is my data private? A: Yes, prompts are sent to Gemini API but not stored in our database.
Created: December 2024
Version: 1.0
Status: ✅ Production Ready
What's inside
7 sections: Quick Start, Usage, Features, Tips, Troubleshooting, API Limits, Security, Support. Includes 3 code blocks and 1 table.
Change this for your project
- Replace
GEMINI_API_KEYwith your own API key variable name if different - Replace
npm run devwith your project's dev server command - Replace
campzeoV1repository references with your own project name
Where it goes
Keep it in your repository where the agent or team that needs it will read it.
Worth borrowing
- Platform-specific AI behavior table (Email, SMS, WhatsApp, etc.) that adapts tone and length
- Iterative refinement workflow: start with a basic prompt, then follow up with shorter/more details/tone changes
- Separate tab for generating image prompts rather than images, with a note to use external services
Related Documents
50-best-ai-image-prompts
Lists 50 copy-paste-ready AI image prompts across 10 categories for Midjourney, DALL-E, and Stable Diffusion.
圖片提示詞專業技能 (Image Prompt Skill)
Defines a structured Chinese-language prompt format for AI image generation, replacing an older English-only convention.
Welcome to Stable Diffusion
Introduces a gallery of Stable Diffusion images with prompts, explaining the tool's basics and showcasing example outputs across themes.
Creative Prompts
Provides six structured prompt templates for creative writing and image generation, each with pro tips and example output.