About PubGPT
PubGPT is an AI-powered pub quiz game that generates new trivia questions on demand. It’s played as a 10-question game — a completely arbitrary number I picked, just for fun!
Hey there! I’m Sean 👋 — a software engineer who’s always loved building little games and experiments to explore cool tech. Whether it’s quirky side projects or tools to learn something new, I’m all about having fun while coding. 🎲✨
That’s what inspired me to create PubGPT: an AI-driven pub quiz experience that whips up fresh trivia questions on the fly.
I use the OpenAI API (specifically the GPT-4 model) to dynamically generate unique pub-style quiz questions based on a carefully crafted prompt. Each question includes four plausible multiple-choice answers, written in the fun, competitive tone you’d expect at a traditional trivia night. 🧠
By leveraging GPT-4, PubGPT ensures each quiz session is fresh, unpredictable, and just a little bit cheeky.
Under the hood, the trivia engine randomly selects from a huge pool of themed categories spanning movies, TV, sports, science, culture, and tons more. Here’s a peek at how the categories and prompts look behind the scenes:
// EXAMPLES OF TRIVIA CATEGORIES // (just a sampling — there are literally hundreds!) MOVIES - Classic Cinema - Superhero Films - Movie Soundtracks MUSIC - Pop Music Through the Decades - Hip-Hop & Rap - Music Festivals GEOGRAPHY & TRAVEL - World Geography - Cities of the World - Flags of the World SPORTS & GAMES - NFL Trivia - Olympic History - Esports & Video Games FUN & RANDOM - Mythology & Legends - Weird But True - Pop Culture Moments // PROMPT USED TO GENERATE A QUESTION export const generateTriviaJSONPrompt = (topic) => ` You are an expert pub quiz master. Your task is to generate one fun and challenging multiple-choice trivia question about the topic: "${topic}". Requirements: - Make the question engaging and well-phrased—not too dry. - Avoid repeating common trivia questions; aim for unique angles or surprising facts. - Vary question styles: facts, identification, or “which of these is true?” - Ensure all four choices are diverse and plausible. - The correct answer must be accurate and verifiable. - Keep the question concise (max 2-3 sentences). - Return ONLY the JSON object. No extra commentary. Schema: { "question": "string (the trivia question)", "choices": { "A": "string", "B": "string", "C": "string", "D": "string" }, "answer": "A" | "B" | "C" | "D" } `;
After receiving GPT-4’s answer, PubGPT strips any extra formatting, safely parses the JSON, and serves up your next question. The result? A seamless, ever-changing quiz experience that feels like you’re right at the pub. 🍻
Want to peek under the hood or contribute? Check out the code on GitHub.
Got feedback? Found a funny question? Just wanna say hi? Ping me on Twitter — I’d love to hear what you think!
Enjoying PubGPT and wanna buy me a pint? 🍺 You can send a virtual round my way on Venmo. Cheers!