Step-by-step guide to generating professional pitch decks from company URLs over Presenton
In this tutorial, we will generate detailed, multi-slide pitch decks for companies using a self-hosted Presenton’s API and a Python script that leverages OpenAI for intelligent question generation and structure creation.This tutorial extends Generate a PPT via API in 5 Minutes and shows you how to automate the creation of professional pitch decks from company URLs using Python and AI.So, do check it before continuing with this and make sure you have Presenton running locally or on any server, and you are able to generate presentations with it.
class QuestionsResponse(BaseModel): """Structured response for questions""" questions: List[str] = Field(description="List of exactly 3 questions to ask the user about their business")class PitchDeckGenerator: def __init__(self): self.presenton_base_url = "http://localhost:5000" self.openai_client = None self.last_questions = [] # Store the generated questions self.setup_openai()
def setup_openai(self): """Setup OpenAI client with API key""" api_key = os.getenv('OPENAI_API_KEY') if not api_key: print("❌ Error: OPENAI_API_KEY environment variable not set") print("Please set your OpenAI API key: export OPENAI_API_KEY='your-key-here'") sys.exit(1) self.openai_client = openai.OpenAI(api_key=api_key)
e. Generate Questions Using OpenAI with Structured Outputs
Copy
def generate_questions(self, company_info: Dict[str, str]) -> List[str]: """Generate questions using OpenAI based on company information""" print("🤖 Generating questions using OpenAI...") prompt = f"""Based on this company information, generate exactly 3 relevant questions to ask the user to better understand their business for creating a pitch deck:Company URL: {company_info['url']}Company Title: {company_info['title']}Company Description: {company_info['description']}H1: {company_info['h1']}First Paragraph: {company_info['first_paragraph']}Generate 3 specific, relevant questions that will help create a compelling pitch deck. Focus on understanding their business model, target market, unique value proposition, and growth plans.The questions should be clear, specific, and designed to gather essential information for creating a professional pitch deck.""" try: response = self.openai_client.chat.completions.create( model="gpt-4o-mini", messages=[{"role": "user", "content": prompt}], tools=[{ "type": "function", "function": { "name": "get_questions", "description": "Get exactly 3 questions to ask the user about their business", "parameters": { "type": "object", "properties": { "questions": { "type": "array", "items": {"type": "string"}, "description": "List of exactly 3 questions to ask the user about their business" } }, "required": ["questions"] } } }], tool_choice={"type": "function", "function": {"name": "get_questions"}}, max_tokens=300, temperature=0.7 ) # Extract questions from the tool call response tool_call = response.choices[0].message.tool_calls[0] arguments = json.loads(tool_call.function.arguments) questions = arguments.get('questions', []) # Ensure we have exactly 3 questions if len(questions) < 3: fallback_questions = [ "What is your company's main product or service?", "Who is your target market?", "What makes your solution unique?" ] questions = questions + fallback_questions[:3-len(questions)] else: questions = questions[:3] print("✅ Generated questions:") for i, question in enumerate(questions, 1): print(f" {i}. {question}") # Store the questions for later use in structure generation self.last_questions = questions return questions except Exception as e: print(f"❌ Error generating questions: {str(e)}") return [ "What is your company's main product or service?", "Who is your target market?", "What makes your solution unique?" ]
def get_user_answers(self, questions: List[str]) -> List[str]: """Get user answers to the generated questions""" print("\n📝 Please answer the following questions:") answers = [] for i, question in enumerate(questions, 1): print(f"\nQuestion {i}: {question}") answer = input("Your answer: ").strip() answers.append(answer) return answers
def generate_pitch_deck_structure(self, company_info: Dict[str, str], answers: List[str]) -> str: """Generate pitch deck structure using OpenAI""" print("🤖 Generating pitch deck structure...") prompt = f"""Create a comprehensive pitch deck structure in markdown format for this company:Company Information:- URL: {company_info['url']}- Title: {company_info['title']}- Description: {company_info['description']}- H1: {company_info['h1']}Questions Asked and User Answers:{chr(10).join([f"Q: {question}\nA: {answer}\n" for question, answer in zip(self.last_questions, answers)])}Generate a pitch deck structure with 8-12 slides covering:1. Title slide with company name and tagline2. Problem statement3. Solution overview4. Market opportunity5. Business model6. Competitive advantage7. Go-to-market strategy8. Financial projections9. Team10. Funding ask (if applicable)11. Contact informationUse the questions and answers provided to create a more targeted and relevant pitch deck structure.Format as markdown with clear slide titles and bullet points for content.""" try: response = self.openai_client.chat.completions.create( model="gpt-4o-mini", messages=[{"role": "user", "content": prompt}], max_tokens=1500, temperature=0.7 ) structure = response.choices[0].message.content.strip() print("✅ Generated pitch deck structure") return structure except Exception as e: print(f"❌ Error generating structure: {str(e)}") return self.get_default_structure(company_info)
🚀 Pitch Deck Generator==================================================Enter the company website URL: example.com🔍 Fetching information from: https://example.com✅ Successfully fetched company information Title: Example Company - Innovative Solutions Description: Leading provider of innovative solutions...🤖 Generating questions using OpenAI...✅ Generated questions: 1. What is your company's main product or service? 2. Who is your target market? 3. What makes your solution unique?📝 Please answer the following questions:Question 1: What is your company's main product or service?Your answer: We provide cloud-based project management softwareQuestion 2: Who is your target market?Your answer: Small to medium businesses with 10-500 employeesQuestion 3: What makes your solution unique?Your answer: Our AI-powered automation reduces project time by 40%🤖 Generating pitch deck structure...✅ Generated pitch deck structure🎨 Generating presentation using Presenton API...Presentation generation can take a couple of minutes, please wait...✅ Presentation generated successfully! Presentation ID: abc123 Download path: /downloads/presentation.pdf Edit URL: http://localhost:5000/edit/abc123🎉 Pitch deck generation completed!📄 You can download the pitch deck from: http://localhost:5000/downloads/presentation.pdf✏️ Edit the pitch deck at: http://localhost:5000/edit/abc123