AI-Powered NPC Generator & Roleplay Assistant for D&D Game Masters
Transform your tabletop RPG sessions with intelligent, voice-enabled NPCs that bring your world to life. NPC Assistant uses cutting-edge AI to generate rich, detailed characters and enables natural conversations with authentic voice synthesis.
npx netlify devLocal URL: http://localhost:8888
(This is required for Netlify Functions to work properly)
Describe an NPC in plain English and watch AI create a complete character profile with personality, motivations, secrets, and visual descriptions. The system intelligently generates everything needed for rich roleplay.
AI automatically selects the perfect voice from 100+ premium options (Gemini + ElevenLabs) by analyzing character traitsโgender, age, and personality. Don't like it? Regenerate for a different match.
A unique approach: First, an LLM analyzes your character and crafts the perfect DALL-E prompt. Then DALL-E 3 generates a stunning 1024x1024 fantasy portrait. The result? Professional-quality character art that actually matches your vision.
NPCs stay in character across entire conversations, remembering history and reacting based on their personality, goals, and secrets. They won't reveal secrets unless tricked or forcedโjust like a real character.
Set rich, contextual scenes that guide NPC interactions. AI automatically generates atmospheric scene descriptions complete with location, time, mood, and player objectives. The system intelligently tracks scene goals and celebrates when your players achieve themโthen seamlessly transitions to the next scene. Perfect for structured adventures or spontaneous roleplay.
Share your favorite NPCs with other GMs instantly. Send complete character packagesโincluding personality, voice, portrait, and optionally a protected starting sceneโto any user by email. Recipients get a fully functional copy ready for their own campaigns. Perfect for sharing recurring characters across connected campaigns or building a shared world with your fellow GMs.
Any character trait can be regenerated or expanded with AI. Personality too bland? Regenerate it. Secret too simple? Expand it. Every field is editable and AI-enhanceable.
Built on Firebase + Netlify Functions with complete user isolation. API keys never touch the client. Your NPCs are private, synced across devices, and always available.
- Node.js 16+ and npm
- Firebase project (free tier works great)
- Google AI API key (Gemini)
- OpenAI API key (for DALL-E image generation)
- Cloudinary account (for image storage)
- ElevenLabs API key (optional, for premium voices)
-
Clone the repository:
git clone <your-repo-url> cd npc_assistant
-
Install dependencies:
npm install
-
Configure environment variables:
Copy
.env.exampleto.envand fill in your API keys:cp .env.example .env
Required variables:
GOOGLE_AI_API_KEY=your_gemini_api_key OPENAI_API_KEY=your_openai_api_key CLOUDINARY_CLOUD_NAME=your_cloud_name CLOUDINARY_API_KEY=your_cloudinary_key CLOUDINARY_API_SECRET=your_cloudinary_secret ELEVENLABS_API_KEY=your_elevenlabs_key # Optional
-
Set up Firebase:
Update
index.htmlwith your Firebase config:window.__firebase_config = JSON.stringify({ apiKey: "your-api-key", authDomain: "your-app.firebaseapp.com", projectId: "your-project-id", storageBucket: "your-app.appspot.com", messagingSenderId: "123456789", appId: "your-app-id" });
-
Deploy Firestore rules:
firebase deploy --only firestore:rules
Run the local development server with Netlify Functions:
npx netlify devThe app will be available at http://localhost:8888
Deploy to Netlify:
netlify deploy --prod- Frontend: React 18, Vite, TailwindCSS
- Backend: Netlify Functions (serverless)
- Database: Firebase Firestore
- Authentication: Firebase Auth
- AI Models:
- Google Gemini 2.0 (character generation, conversations, voice selection)
- OpenAI DALL-E 3 (image generation)
- Voice Synthesis:
- Google Gemini TTS (100+ voices)
- ElevenLabs (premium voices)
- Image Storage: Cloudinary
- Icons: Lucide React
npc_assistant/
โโโ src/
โ โโโ NPC_Generator_Chatbot.jsx # Main application component
โ โโโ firebaseConfig.js # Firebase initialization
โ โโโ voices.js # Voice configuration
โ โโโ main.jsx # Entry point
โโโ netlify/
โ โโโ functions/
โ โโโ gemini.js # Gemini API proxy
โ โโโ generate-image.js # DALL-E image generation
โ โโโ elevenlabs-tts.js # ElevenLabs TTS proxy
โ โโโ delete-image.js # Cloudinary cleanup
โโโ firestore.rules # Firestore security rules
โโโ voices.json # Voice library data
โโโ netlify.toml # Netlify configuration
- Click "Add New NPC"
- Describe your character in natural language:
- "A gruff old dwarf blacksmith who secretly works for the thieves guild"
- "An enthusiastic young elf bard seeking fame and fortune"
- AI generates complete character profile with voice and portrait
- Review and edit any fields as needed
- Select an NPC from your list
- Set a Scene (optional): Click "Set a Scene" to establish context with location, mood, and objectives
- Type your message in the conversation panel
- NPC responds in character, staying true to their personality and scene context
- Click the speaker icon to hear their voice (100+ premium voices)
- Enable auto-play for automatic voice responses
- Track scene goalsโwhen achieved, seamlessly transition to the next scene
- GM Details Panel: View/edit personality, wants, secrets, and pitfalls
- Scene System:
- AI-generated scene descriptions with atmospheric details
- Automatic goal extraction and tracking from scene context
- "Set Next Scene" button appears when goals are achieved
- Seamless scene transitions that maintain conversation flow
- Type
/sceneanytime to set a new scene - Rollback to any scene to try different story branches
- NPC Sharing: Share characters with other GMs by email
- Include starting scene (becomes protected for the recipient)
- Recipient gets complete character with voice and portrait
- Perfect for collaborative worldbuilding
- Voice Selection: Regenerate or manually select from 100+ voices
- Image Regeneration: Create new character portraits anytime
- Field Regeneration: Use AI to regenerate individual character traits
- Mobile Optimized: Full-featured experience on phones with responsive design
- API keys secured in Netlify Functions (never exposed to client)
- User authentication required for all operations
- Firestore rules enforce user data isolation:
- Personal NPCs stored in
users/{userId}/npcs - Shared NPCs stored in
users/{userId}/shared_npcs - Each user can only access their own collections
- Personal NPCs stored in
- Environment variables for sensitive configuration
- Cloudinary secure image uploads
Contributions are welcome! Please feel free to submit issues or pull requests.
This project is licensed under the MIT License.
- Built with Google Gemini for AI generation
- Images powered by OpenAI DALL-E 3
- Voice synthesis by Google Gemini TTS and ElevenLabs
- Hosted on Netlify
- Database by Firebase
Happy GMing! ๐ฒโจ