DEV Community

 AI Automation Enterenpeur
AI Automation Enterenpeur

Posted on

Turn a Live Q&A Transcript Into a Lesson and Recap With Python

If you run a community, a course, or even a team office hour, you probably record live Q&A sessions. Then the recording sits there. Nobody rewatches an hour of video.

The fix is to repurpose each call into smaller pieces: a lesson built from the best answer, a short recap, and a list of questions you didn't get to. Here's a small Python script that does the boring part for you.

The input

Most meeting and recording tools can export a transcript. We'll assume a plain text file where questions start with "Q:" and answers start with "A:". If your tool's format is different, a quick find-and-replace gets you there.

Q: How do I automate lead follow-up?
A: Start with one trigger, a new form submission, and send one personal email within five minutes...
Q: Should I use Zapier or write code?
A: Use no-code until it gets expensive or limiting...
Q: What about CRMs?
Enter fullscreen mode Exit fullscreen mode

Notice the last question has no answer. That's next month's agenda.

The script

import re
from pathlib import Path

def parse_transcript(text):
    pairs = []
    for block in re.split(r"\n(?=Q:)", text.strip()):
        q_match = re.match(r"Q:\s*(.+)", block)
        a_match = re.search(r"A:\s*(.+)", block, re.S)
        if q_match:
            pairs.append({
                "question": q_match.group(1).strip(),
                "answer": a_match.group(1).strip() if a_match else "",
            })
    return pairs

def build_outputs(pairs):
    answered = [p for p in pairs if p["answer"]]
    unanswered = [p["question"] for p in pairs if not p["answer"]]
    best = max(answered, key=lambda p: len(p["answer"]), default=None)

    lesson = ""
    if best:
        lesson = f"# {best['question']}\n\n{best['answer']}\n\nAction step: try this before next call.\n"

    recap = "Call recap:\n" + "\n".join(
        f"- {p['question']}" for p in answered[:5]
    )
    agenda = "Next month's agenda:\n" + "\n".join(f"- {q}" for q in unanswered)
    return lesson, recap, agenda

if __name__ == "__main__":
    text = Path("transcript.txt").read_text(encoding="utf-8")
    lesson, recap, agenda = build_outputs(parse_transcript(text))
    Path("lesson.md").write_text(lesson, encoding="utf-8")
    Path("recap.txt").write_text(recap, encoding="utf-8")
    Path("agenda.txt").write_text(agenda, encoding="utf-8")
    print(recap)
    print()
    print(agenda)
Enter fullscreen mode Exit fullscreen mode

How it works

parse_transcript splits the file at each new "Q:" line, so every block holds one question and its answer, if there is one.

build_outputs sorts the pairs into answered and unanswered. It uses the longest answer as a simple stand-in for the "best" one. Long answers usually mean the topic needed real explaining, which makes it a good lesson candidate. You can swap that rule for anything: chat reactions, a manual pick, or an LLM call that scores each answer.

The script then writes three files: lesson.md, ready to paste into your course section; recap.txt, five bullets for a discussion post; and agenda.txt, your unanswered questions for next time.

Where to take it next

Pull transcripts automatically from your recording tool's export folder. Run the script on a schedule the morning after each call. Send the recap to a webhook that posts it to your community or Slack. Add a summarization step so each recap bullet carries a one-line answer, not just the question.

The point isn't the code. It's that one live hour turns into a week of useful content without you rewriting anything by hand.

I'm running this monthly Q&A system in my community for builders working on automation. Come join: https://www.skool.com/automation-enterenpeur-7666

Top comments (0)