Consultants, agency owners, and account managers waste hours after client calls wrestling with messy transcripts, scribbled notes, and blank presentation templates. It's tedious work. Done manually, slide creation invites typos, drops critical action items, and delays getting proposals out the door. Building an Ai agent workflow for small business teams replaces that drafting slog with a straightforward Python script that turns unstructured notes into clean, multi-slide PowerPoint decks.
Workflow at a glance
| Dimension | Details |
|---|---|
| Problem it solves | Eliminates manual retyping, summarizing, and formatting of discovery notes into client-facing presentation decks. |
| Manual steps it replaces | Reading messy call notes, summarizing action items into slide bullets, opening PowerPoint, manually pasting text into slide placeholders, and verifying typography consistency. |
| Trigger | New text file dropped into an incoming folder or manual execution via command line with a note file path. |
| Output | A fully formatted Microsoft PowerPoint (.pptx) file containing title, agenda, findings, solution, and next steps slides. |
| Tools | Python 3 runtime, OpenAI API (Responses API), python-pptx library, and python-dotenv. |
| Skill level needed | Intermediate Python scripting and basic command line usage. |
| Complexity | Medium. Requires parsing unstructured text into validated JSON, mapping the structured output into PowerPoint shapes via python-pptx, and handling API exceptions gracefully. |
What you need before you start
Got ten minutes to configure your environment? Make sure you have these prerequisites checked off on your machine before running any code:
- Python 3 Runtime: Grab a current release straight from Python.org downloads. Just run
python3 --versionorpython --versionin your terminal to verify what you're on. - You'll need an active OpenAI Platform Account. Log in to the developer console to pull your secret key. If you haven't done this before, the OpenAI API authentication documentation explains how to provision server-side keys with Bearer authentication.
- Project Directory and Virtual Environment: Set up a fresh folder and spin up an isolated virtual environment (keeps your system-level packages uncluttered).
- Sample Meeting Notes: Just a dirty
.txtfile from a recent client discovery call so you have real text to throw at the script.
How the workflow runs
- Trigger: You feed the script a file path to your notes file (for example,
notes/discovery_acme.txt). - Text Ingestion: Python reads the text, checks that you didn't pass an empty file, and bundles everything into the prompt envelope.
- The script hands your notes over to the model. As outlined in the platform docs, OpenAI's Responses API supports direct model requests, tool use, audio, image, and text inputs, and stateful interactions.
- Schema Validation: The API returns JSON matching our predefined deck structure—slide titles, subtitles, bullet points, and speaker notes.
- Presentation Generation: Next,
python-pptxreads that JSON, applies layout coordinates, injects typography, and writes the slides. - File Output: Done. The deck drops right into your output folder labeled with the client's name and timestamp.
Build it step by step
Step 1: Set up the project directory and virtual environment
First, open your terminal. Create a clean project folder and fire up a Python virtual environment right away. It saves you from dependency headaches later.
mkdir slide-agent-workflow
cd slide-agent-workflow
python3 -m venv venv
source venv/bin/activate
# On Windows, activate with: venv\Scripts\activateNow pull in the dependencies: openai handles the model requests, python-pptx builds the deck, and python-dotenv manages your API keys.
pip install openai python-pptx python-dotenvCheck: Run pip list and confirm that openai, python-pptx, and python-dotenv appear in the installed packages list without errors.
Step 2: Configure environment variables securely
Never hardcode your API credentials into source code. Instead, create a .env file in your root folder and drop your key there. That way it stays local.
Keep in mind that the OpenAI API authentication documentation says API-key revocations take effect within a few seconds, making key regeneration quick if a leak ever occurs.
OPENAI_API_KEY="sk-your-actual-api-key-here"Add a quick .gitignore so you don't accidentally push secrets to GitHub:
.env
venv/
output/
__pycache__/Check: Create a temporary file called test_env.py with from dotenv import load_dotenv; import os; load_dotenv(); print(os.getenv('OPENAI_API_KEY')[:7]). Run it and confirm it prints sk-your without showing the full key.
Step 3: Define the structured JSON schema for slides
LLMs drift if you let them. To make sure python-pptx gets predictable data every single run, enforce a strict JSON schema right in the prompt. Put this in a file named schema.py.
SLIDE_DECK_SCHEMA = {
"type": "object",
"properties": {
"deck_title": {"type": "string"},
"client_name": {"type": "string"},
"slides": {
"type": "array",
"items": {
"type": "object",
"properties": {
"slide_number": {"type": "integer"},
"layout_type": {
"type": "string",
"enum": ["title", "agenda", "content", "next_steps"]
},
"title": {"type": "string"},
"bullets": {
"type": "array",
"items": {"type": "string"}
},
"speaker_notes": {"type": "string"}
},
"required": ["slide_number", "layout_type", "title", "bullets"],
"additionalProperties": False
}
}
},
"required": ["deck_title", "client_name", "slides"],
"additionalProperties": False
}Check: Import SLIDE_DECK_SCHEMA in Python interactive mode to confirm there are no syntax errors.
Step 4: Build the OpenAI parsing module with retry logic
Create a file named extractor.py. This handles reading your raw text, hitting the API, and decoding the returned JSON. In practice, this means you need basic retry handling—transient rate limits happen all the time. As documented, OpenAI documents that a temporary rate-limit error returns a 429 and may include a Retry-After header; its guidance recommends exponential backoff when retrying.
import json
import time
import os
from openai import OpenAI, RateLimitError
from dotenv import load_dotenv
load_dotenv()
client = OpenAI(api_key=os.getenv("OPENAI_API_KEY"))
def extract_deck_structure(raw_notes: str, max_retries: int = 3) -> dict:
system_prompt = (
"You are a corporate presentation architect. Analyze the provided meeting notes "
"and extract a structured pitch or status deck. You must return valid JSON only, matching "
"the required schema with slides of types: title, agenda, content, or next_steps. "
"Keep bullet points clear, concise, and focused on decisions, challenges, and milestones."
)
user_prompt = f"Transform these raw meeting notes into a client presentation structure:\n\n{raw_notes}"
for attempt in range(max_retries):
try:
response = client.chat.completions.create(
model="gpt-6.1-sol",
messages=[
{"role": "system", "content": system_prompt},
{"role": "user", "content": user_prompt}
],
response_format={"type": "json_object"}
)
raw_content = response.choices[0].message.content
return json.loads(raw_content)
except RateLimitError as e:
wait_time = (2 ** attempt) + 1
print(f"Rate limit reached (429). Retrying in {wait_time} seconds...")
time.sleep(wait_time)
if attempt == max_retries - 1:
raise e
except json.JSONDecodeError as err:
raise ValueError(f"Model returned invalid JSON: {str(err)}")Check: Test this function against a short sample string to verify that it outputs a Python dictionary with keys deck_title, client_name, and slides.
Step 5: Build the slide deck renderer with python-pptx
Now build renderer.py to turn that parsed dictionary into a real file. Here's what actually happens: we use widescreen 16:9 dimensions and standard layout placeholders so the output opens properly on PowerPoint, Google Slides, or Keynote without misaligned text frames.
import os
from pptx import Presentation
from pptx.util import Inches, Pt
from pptx.dml.color import RGBColor
def create_presentation(deck_data: dict, output_filepath: str) -> str:
prs = Presentation()
prs.slide_width = Inches(13.333)
prs.slide_height = Inches(7.5)
# Slide 0: Title layout, Slide 1: Content layout
title_layout = prs.slide_layouts[0]
bullet_layout = prs.slide_layouts[1]
for slide_info in deck_data.get("slides", []):
layout_type = slide_info.get("layout_type", "content")
if layout_type == "title":
slide = prs.slides.add_slide(title_layout)
title = slide.shapes.title
subtitle = slide.placeholders[1]
title.text = slide_info.get("title", deck_data.get("deck_title", "Client Update"))
subtitle.text = f"Prepared for: {deck_data.get('client_name', 'Valued Client')}"
else:
slide = prs.slides.add_slide(bullet_layout)
title = slide.shapes.title
title.text = slide_info.get("title", "Key Takeaways")
body_shape = slide.shapes.placeholders[1]
text_frame = body_shape.text_frame
text_frame.clear()
bullets = slide_info.get("bullets", [])
for index, bullet_text in enumerate(bullets):
paragraph = text_frame.paragraphs[0] if index == 0 else text_frame.add_paragraph()
paragraph.text = bullet_text
paragraph.font.size = Pt(18)
paragraph.level = 0
# Attach speaker notes if present
speaker_notes_text = slide_info.get("speaker_notes", "")
if speaker_notes_text:
notes_slide = slide.notes_slide
notes_slide.notes_text_frame.text = speaker_notes_text
os.makedirs(os.path.dirname(output_filepath), exist_ok=True)
prs.save(output_filepath)
return output_filepathCheck: Call create_presentation() with mock dictionary data. Verify that a .pptx file is created in your output directory and that opening it in PowerPoint or Keynote shows formatted title and bullet slides.
Step 6: Combine components into an executable pipeline
Tie it all together. Create run_pipeline.py as your CLI entry point. It takes the text file, kicks off extraction, passes the data to the renderer, and logs the output path.
import sys
import os
from extractor import extract_deck_structure
from renderer import create_presentation
def main():
if len(sys.argv) < 2:
print("Usage: python run_pipeline.py <path_to_notes_file>")
sys.exit(1)
input_file = sys.argv[1]
if not os.path.exists(input_file):
print(f"Error: File '{input_file}' not found.")
sys.exit(1)
with open(input_file, "r", encoding="utf-8") as f:
notes_text = f.read().strip()
if not notes_text:
print("Error: The input notes file is empty.")
sys.exit(1)
print(f"Processing notes from {input_file}...")
structured_deck = extract_deck_structure(notes_text)
clean_client_name = structured_deck.get("client_name", "Client").replace(" ", "_")
output_filename = f"output/{clean_client_name}_Presentation.pptx"
created_path = create_presentation(structured_deck, output_filename)
print(f"Presentation generated successfully: {created_path}")
if __name__ == "__main__":
main()Check: Run python run_pipeline.py sample_notes.txt. The console should log processing steps and output Presentation generated successfully: output/Client_Presentation.pptx.
Prompts and templates
Here are the exact prompts and target JSON models used inside the script.
System Prompt
You are a professional business presentation designer. Your task is to transform raw client discovery notes, transcripts, or status updates into a clean, presentation-ready JSON outline.
Follow these strict rules:
1. Identify the client name and main engagement topic.
2. Structure the presentation logically: Title slide, Agenda, Findings/Challenges, Proposed Solution/Milestones, and Next Steps.
3. Every bullet point must be concise, professional, and actionable. Do not write full paragraphs on slides.
4. Add concise speaker notes to explain the background of each slide where appropriate.
5. Return valid JSON only, without markdown fences or additional conversational commentary.User Prompt Template
Transform the following raw meeting notes into a complete client presentation deck JSON structure.
MEETING NOTES:
{raw_notes}Expected JSON Output Schema
{
"deck_title": "Discovery Findings and Strategic Roadmap",
"client_name": "Acme Logistics",
"slides": [
{
"slide_number": 1,
"layout_type": "title",
"title": "Discovery Findings and Strategic Roadmap",
"bullets": [],
"speaker_notes": "Welcome the Acme Logistics leadership team and introduce the review agenda."
},
{
"slide_number": 2,
"layout_type": "agenda",
"title": "Agenda",
"bullets": [
"Current State Challenges",
"Target System Architecture",
"Phased Rollout Timeline",
"Next Steps and Deliverables"
],
"speaker_notes": "Walk through the four sections covered in today's review."
},
{
"slide_number": 3,
"layout_type": "content",
"title": "Current State Challenges",
"bullets": [
"Order routing delays across 3 regional fulfillment centers",
"Manual inventory reconciliation taking 6 hours per week",
"Lack of real-time visibility into vendor dispatch status"
],
"speaker_notes": "Highlight bottlenecks identified during the warehouse manager interviews."
},
{
"slide_number": 4,
"layout_type": "next_steps",
"title": "Immediate Action Items",
"bullets": [
"Finalize API access credentials by Friday",
"Approve phase 1 sprint scope by next Tuesday",
"Schedule technical architecture kickoff with engineering"
],
"speaker_notes": "Confirm ownership for each action item before adjourning."
}
]
}Test it before you trust it
Always sanity check the pipeline before sending raw output to prospects. Edge cases happen.
| Test Input | Description / Edge Case | Expected Behavior | Failure Indicator |
|---|---|---|---|
| Standard Discovery Notes | 300 words of standard meeting notes with client name, challenges, and dates. | Generates a 4-to-5-slide presentation with populated title and bullet points. | Script errors or missing slides in the output file. |
| Empty File | Zero-byte text file passed as input argument. | Script catches empty input early and terminates with message: Error: The input notes file is empty. | Unhandled exception or empty API call that wastes credits. |
| Malformed / Minimal Notes | Single sentence notes: "Met with John about website bugs." | Generates minimum viable 2-slide deck (Title and Next Steps) without crashing. | JSONDecodeError or missing keys causing KeyError in renderer. |
| Large Transcript | Unedited meeting transcript containing 4,000 words. | Correctly compresses lengthy transcript into distinct thematic slides under token limits. | API rate limit failure or truncated, invalid JSON payload. |
| Special Characters | Notes with symbols: &, <, >, quotes, and international currency symbols. | Preserves characters properly across XML structures in the PPTX container. | PowerPoint displays XML corruption warning upon opening deck. |
Where it breaks and how to fix it
- API Key Revocation or Expiry: If your environment variable contains an expired key, the client throws an
AuthenticationError. The OpenAI API authentication documentation outlines proper key provisioning. Fix: Generate a fresh key in the console and replace it in your.envfile. - Hit an unexpected HTTP 429? That's rate limiting during peak volume. As platform guidance notes, OpenAI API rate limits can be measured in requests per minute, requests per day, tokens per minute, tokens per day, images per minute, and audio minutes per minute; limits vary by model and apply at organization and project levels. Fix: Lean on exponential backoff (like we built in
extractor.py) or bump your organization's usage tier. - Schema Drift / Invalid JSON: Sometimes models wrap JSON in markdown ticks or skip an optional key. Fix: Stick with JSON mode in the API parameters, and use safe dictionary lookups via
.get()insiderenderer.pyso missing keys don't blow up execution. - Custom layouts can cause PowerPoint Placeholder Mismatches. If your agency template moved slide placeholders around, indexing 0 or 1 might grab the wrong box (or crash entirely). Fix: Loop through
prs.slide_layoutsto inspect placeholder names directly instead of hardcoding numeric indexes.
Ai agent workflow for small business running costs and limits
How much does this actually cost to run? Pennies. Your expenses boil down to token usage on each script call. Per the official documentation, OpenAI API pricing is based on the selected model's input and output token rates; the Responses API is not priced separately.
To put real numbers on it, OpenAI's published pricing page lists gpt-6.1-sol at $2.00 per 1M input tokens and $10.00 per 1M output tokens. That means feeding in 1,500 words of messy notes and getting back an 800-token JSON deck outline costs less than a single cent. It's essentially negligible.
Watch out for account-level spending caps, though. Depending on your tier, OpenAI's rate-limit documentation lists monthly usage limits of $100 for Free, $500 for Build, $5,000 for Launch, and $200,000 for Grow. Keep an eye on your developer dashboard so you don't hit an unexpected limit mid-month.
Variations and extensions
- Branded Corporate Master Template: Skip the blank canvas. Load your own deck using
prs = Presentation("templates/company_brand.pptx"). Your fonts, brand color palette, and header logos carry over automatically without manual formatting. - Drop a file watcher on an
inbox/directory withwatchdog. Whenever Whisper outputs a transcript, the pipeline turns it into a presentation right away. - Slack or Email Delivery Bot: Wire up a webhook to ping the completed deck straight to an account rep in Slack. Quick turnarounds impress clients.
- Two-Step Editing Agent: Run an extra LLM pass (a quick style-check prompt) to tighten bullet copy against brand guidelines before generating slides.
Hand this to ChatGPT or Claude
Want your coding assistant to build or tweak this for your setup? Copy this prompt block straight into ChatGPT or Claude.
GOAL:
Build an automated Python script that reads unstructured client meeting notes, extracts a structured slide deck JSON object using OpenAI's API, and compiles a .pptx presentation using python-pptx.
TRIGGER:
CLI execution: python run_pipeline.py <path_to_notes.txt>
STEPS:
1. Ingestion: Read text content from the file provided via command-line argument. Validate that the input is non-empty.
2. Extraction: Send prompt to OpenAI model (gpt-6.1-sol) requesting JSON output matching the slide schema. Implement exponential backoff for HTTP 429 rate limits.
3. Parsing: Validate JSON containing deck_title, client_name, and an array of slide objects (slide_number, layout_type, title, bullets, speaker_notes).
4. Deck Rendering: Use python-pptx to generate slides. Layout 0 for title, Layout 1 for content. Insert bullets and attach speaker notes to the notes slide.
5. Save: Store presentation in output/ directory named <client_name>_Presentation.pptx.
DATA FIELDS:
- deck_title (string)
- client_name (string)
- slides (array of objects):
- slide_number (int)
- layout_type (string: 'title' | 'agenda' | 'content' | 'next_steps')
- title (string)
- bullets (array of strings)
- speaker_notes (string)
ACCEPTANCE TESTS:
- Provide valid 300-word meeting notes: Script generates a 4-to-5-slide .pptx file.
- Provide empty file: Script exits cleanly with an error message without calling the API.
- Rate limit hit: Script logs wait time and retries with backoff.
CONSTRAINTS:
- Use python-pptx without external GUI dependencies (must run headless on macOS, Linux, or Windows).
- Use .env for API key storage.
- No hardcoded secrets.Frequently Asked Questions
Do I need Microsoft PowerPoint installed on my machine to run this workflow?
No. python-pptx writes the raw OpenXML files directly to disk. You can run this completely headless on a Linux droplet, inside Docker, or on a local terminal without Microsoft Office anywhere near the machine.
Can I apply custom brand colors and custom fonts to the slides?
Yes. You can hardcode exact RGB shades with RGBColor(r, g, b) and specify typography using paragraph.font.name = 'Arial' in your renderer code. But in most setups, passing a pre-styled .pptx master template is much faster.
What happens if the meeting notes are extremely short?
The model adjusts. Even with two sentences of context, it will outline a minimal two-to-three-slide deck with a title, high-level bullets, and remaining open questions.
How do I prevent the model from hallucinating false business metrics?
Give the model clear guardrails. Add a direct constraint in your system prompt: "Do not invent metrics, dates, or deliverables not present in the notes." What most guides miss is that negative constraints keep extraction scripts grounded.
Can this pipeline run inside a cloud function or container?
Yes. The script has no native OS display dependencies. It deploys cleanly to AWS Lambda, Google Cloud Run, or a standard Docker container without friction.
Your first step
Spin up a clean test directory, install openai and python-pptx, and test Step 1 with a quick five-line text file. Once the base pipeline runs cleanly, you can hook it into your agency's slide templates and stop retyping client call notes by hand.