A futuristic, clean graphic showing the logos of GitHub, HeyGen, and ElevenLabs connected by glowing data streams, representing an API workflow. The background is a dark blue with abstract code elements. The style is professional tech illustration. --ar 16:9

How to Automate Personalized AI Video Pull Request Summaries in GitHub Using HeyGen and ElevenLabs

🚀 Agency Owner or Entrepreneur? Build your own branded AI platform with Parallel AI’s white-label solutions. Complete customization, API access, and enterprise-grade AI models under your brand.

Picture this: It’s 3 p.m. on a Tuesday, and your engineering team is deep in a development sprint. An engineering manager, Sarah, glances at her notifications. It’s a flood of automated GitHub alerts, a wall of text detailing pull requests, comments, and merge confirmations. Each notification requires her to stop, switch context, click through to the repository, and piece together the importance and scope of each change. Research from GitLab’s DevSecOps survey suggests developers spend only about 25% of their time writing code, with the rest lost to meetings, planning, and navigating complex toolchains. This constant context switching isn’t just inefficient; it’s a silent killer of productivity and deep work, turning crucial updates into background noise. How can teams stay aligned and informed without drowning in a sea of text-based notifications?

The challenge lies in the medium, not the message. Text is static and requires active cognitive load to parse. For complex pull requests involving multiple file changes and intricate logic, a brief text summary often fails to convey the full picture, leading to delayed reviews and communication gaps. What if you could transform these routine, text-heavy notifications into dynamic, engaging, and easily digestible video summaries? Imagine receiving a one-minute video for each new pull request, featuring a realistic AI avatar that verbally outlines the author, the purpose of the change, and the key details from the PR description, all delivered directly to your team’s communication channel. This moves beyond simple notification; it becomes an active briefing.

This is not science fiction. By orchestrating a workflow between GitHub Webhooks, the generative AI video platform HeyGen, and the ultra-realistic text-to-speech capabilities of ElevenLabs, you can build a powerful automation engine that does exactly this. In this technical walkthrough, we will guide you step-by-step through the process of creating a system that automatically generates personalized AI video summaries for every new pull request in your GitHub repository. We will cover setting up the architecture, capturing events, generating dynamic voice narration, producing the final video, and exploring advanced applications. Get ready to revolutionize your development workflow, reduce notification fatigue, and significantly improve your team’s communication efficiency.

The Architectural Blueprint: Connecting GitHub, HeyGen, and ElevenLabs

Before diving into the code, it’s essential to understand the high-level architecture of our automation system. The entire process is event-driven, kicking off the moment a developer creates a pull request. At its core, the system acts as a smart intermediary, catching an event from GitHub, processing its data, and using AI services to generate a new type of asset: a video summary.

Understanding the Workflow: From PR to Personalized Video

The data flow is linear and can be broken down into a few key stages:

  1. Event Trigger (GitHub): A developer opens a new pull request in a configured repository. GitHub fires a pull_request event via a webhook.
  2. Data Ingestion (Middleware): A serverless function (e.g., AWS Lambda, Vercel Function, or a simple Flask/Express server) acts as our endpoint, receiving the JSON payload from the GitHub webhook. This payload contains all the necessary information, such as the PR title, author, description, and links.
  3. Script Generation: The middleware parses the JSON to extract key details and dynamically constructs a script for the video narration. For example: “New pull request from [author’s name] titled ‘[PR title]’. This update proposes changes to the [base branch] from the [head branch].”
  4. Audio Generation (ElevenLabs): The script is sent to the ElevenLabs API, which converts the text into a natural-sounding audio file. This file is temporarily stored or its URL is passed to the next stage.
  5. Video Synthesis (HeyGen): The middleware then calls the HeyGen API. It provides the audio file from ElevenLabs, along with dynamic text (like the PR title or author’s name to be displayed on-screen) and specifies a video template or avatar.
  6. Delivery: HeyGen processes the request asynchronously. Once the video is rendered, our middleware can retrieve the final video URL and post it to a destination like a Slack channel, Microsoft Teams, or even a comment back on the original pull request.

Prerequisites and Tech Stack Setup

To follow along with this guide, you will need accounts and API keys for the following services:
* GitHub: A repository where you have administrative privileges to set up webhooks.
* HeyGen: An account to access their API for video generation. You can begin with a free plan to test the functionality. Try HeyGen for free now.
* ElevenLabs: An account for their text-to-speech API. Their free tier is sufficient for building and testing this project. Sign up for ElevenLabs here.
* A Hosting Environment: A place to run your middleware code. Serverless platforms like Vercel or AWS Lambda are ideal for their scalability and cost-effectiveness. For this tutorial, we will use Python with Flask as a simple framework.

Step 1: Capturing Pull Request Events with GitHub Webhooks

The entire automation hinges on reliably capturing events from GitHub. Webhooks are the perfect tool for this, as they provide a push-based notification system that triggers your code in real-time.

Creating and Configuring Your Webhook

  1. Navigate to Your Repository Settings: In your GitHub repo, go to Settings > Webhooks.
  2. Add a New Webhook: Click the “Add webhook” button.
  3. Configure the Payload URL: This is the most crucial step. You need to enter the public URL of your deployed middleware function (e.g., https://your-app.vercel.app/api/webhook). During development, you can use a tool like ngrok to expose your local server to the internet.
  4. Set the Content Type: Change the “Content type” to application/json.
  5. Secure Your Webhook: It is highly recommended to set a “Secret.” This is a random string of text that GitHub will use to sign its payloads. Your application can then verify this signature to ensure the requests are genuinely from GitHub.
  6. Select Individual Events: Instead of sending all events, select “Let me select individual events.” Check the box for Pull requests. This ensures your webhook only fires for PR-related activities.
  7. Create the Webhook: Click “Add webhook.” GitHub will send a ping event to your URL to confirm it’s reachable.

Building the Endpoint to Receive Webhook Payloads

Now, let’s create a simple Python Flask application to receive and process these webhook events. This code will act as our central orchestrator.

# app.py
import os
from flask import Flask, request, jsonify

app = Flask(__name__)

@app.route('/api/webhook', methods=['POST'])
def github_webhook():
    # TODO: Add signature verification for security

    if request.headers.get('X-GitHub-Event') == 'pull_request':
        payload = request.json
        action = payload.get('action')

        if action == 'opened':
            pr_title = payload['pull_request']['title']
            pr_author = payload['pull_request']['user']['login']
            pr_body = payload['pull_request']['body']
            pr_url = payload['pull_request']['html_url']

            print(f"New PR opened by {pr_author}: {pr_title}")

            # --- This is where we will trigger our video generation logic ---
            # generate_video_summary(pr_title, pr_author, pr_body)

            return jsonify({'status': 'success', 'message': 'PR event received'}), 200

    return jsonify({'status': 'ignored', 'message': 'Event not a PR opening.'}), 200

if __name__ == '__main__':
    app.run(port=5000)

This simple server listens for POST requests on /api/webhook, checks if it’s a pull_request event with the action opened, and then extracts the relevant data.

Step 2: Generating Dynamic Voice Narration with ElevenLabs

With the PR data in hand, the next step is to create a compelling audio narration. A flat, robotic voice would undermine the goal of creating engaging content. This is where ElevenLabs shines, offering incredibly lifelike AI voices.

Crafting the Perfect Script from PR Data

First, we’ll write a function to generate a script from the pull request payload. A good script is concise and informative.

# In your application logic
def create_script_from_pr(title, author, body):
    # Basic script
    script = f"New pull request submitted by {author}. The title is: {title}. "

    # Add the body if it exists
    if body and len(body) > 0:
        # Clean up the body for narration
        cleaned_body = body.replace('#', 'heading').replace('*', '')
        script += f"The description provided is: {cleaned_body[:500]}" # Truncate for brevity
    else:
        script += "No description was provided."

    return script

Integrating the ElevenLabs API for Realistic Text-to-Speech

Next, we’ll send this script to the ElevenLabs API. You’ll need to install their Python client: pip install elevenlabs.

# In your application logic
from elevenlabs import generate, set_api_key
import os

set_api_key(os.getenv("ELEVENLABS_API_KEY"))

def generate_audio_summary(script):
    try:
        audio = generate(
            text=script,
            voice="Bella", # Choose from available voices or create your own
            model="eleven_multilingual_v2"
        )

        # Save the audio to a file
        audio_path = "pr_summary.mp3"
        with open(audio_path, "wb") as f:
            f.write(audio)

        print(f"Audio summary saved to {audio_path}")
        return audio_path
    except Exception as e:
        print(f"Error generating audio: {e}")
        return None

This function takes our script, generates an MP3 audio file using the chosen voice, and saves it locally. This file is the input for our next and final step.

Step 3: Producing Automated Video Summaries with HeyGen

Now we combine our audio with visuals using HeyGen. The HeyGen API lets you programmatically create videos using templates, avatars, and dynamic elements.

Choosing a Template and Customizing Avatars

Before you start, log in to your HeyGen account and either choose a public template or create your own with a specific background, branding, and an avatar. For this use case, a simple template with an avatar on one side and a text area on the other works well. You will need your TEMPLATE_ID and AVATAR_ID for the API call.

Stitching It All Together: Combining Audio and Visuals

The HeyGen API for video generation from a template is straightforward. You provide the template ID, variables for dynamic elements (like text overlays), and your audio.

Here’s how you can make the API call using Python’s requests library:

# In your application logic
import requests
import time
import os

HEYGEN_API_KEY = os.getenv("HEYGEN_API_KEY")

def generate_video_summary(title, audio_path):
    # First, upload the audio to a publicly accessible URL
    # (This step depends on your cloud provider, e.g., AWS S3)
    # For this example, let's assume you have a function `upload_to_s3(audio_path)`
    # that returns a public URL.
    audio_url = upload_to_s3(audio_path)

    headers = {
        "X-Api-Key": HEYGEN_API_KEY,
        "Content-Type": "application/json"
    }

    payload = {
        "video_inputs": [
            {
                "template_id": "your_template_id_here",
                "variables": {
                    "pr_title_variable": title, # The variable name from your HeyGen template
                },
                "audio": {
                    "audio_url": audio_url
                }
            }
        ],
        "test": True # Set to False for production runs
    }

    response = requests.post(
        "https://api.heygen.com/v2/video/generate", 
        json=payload, 
        headers=headers
    )

    if response.status_code == 200:
        video_id = response.json()['data']['video_id']
        print(f"Video generation started. Video ID: {video_id}")
        return video_id
    else:
        print(f"Error starting video generation: {response.text}")
        return None

Handling Video Generation and Retrieval

Video rendering is an asynchronous process. After you start the generation, you need to poll HeyGen’s API to check the status. Once the status is "succeeded", you can fetch the final video URL.

# Polling function
def poll_for_video_url(video_id):
    url = f"https://api.heygen.com/v1/video_status.get?video_id={video_id}"
    headers = {"X-Api-Key": HEYGEN_API_KEY}

    while True:
        response = requests.get(url, headers=headers)
        if response.status_code == 200:
            data = response.json()['data']
            if data['status'] == 'succeeded':
                video_url = data['video_url']
                print(f"Video successfully generated: {video_url}")
                return video_url
            elif data['status'] == 'failed':
                print("Video generation failed.")
                return None
            else:
                print("Video is still processing...")
                time.sleep(10) # Wait 10 seconds before polling again
        else:
            print(f"Error checking video status: {response.text}")
            return None

With the final video_url, your application can now post it to Slack, Teams, or wherever your team communicates, closing the loop on a fully automated, highly engaging notification system.

That overwhelmed engineering manager, Sarah, no longer has to sift through text. Instead, she watches a quick, clear video briefing for each PR, right in her team’s channel. She can immediately gauge the priority and complexity, ask better questions, and assign reviewers faster. This is the power of moving from static text to dynamic media. You haven’t just sent a notification; you’ve delivered a concise, human-centric intelligence briefing that saves time and boosts team alignment. Ready to revolutionize your team’s development workflow? Start building more engaging and efficient communication channels today. Try HeyGen for free now to create your first AI video, and use ElevenLabs to give your projects a professional voice. By integrating these powerful tools, you can transform routine notifications into powerful insights and give your team back its most valuable resource: time.

Transform Your Agency with White-Label AI Solutions

Ready to compete with enterprise agencies without the overhead? Parallel AI’s white-label solutions let you offer enterprise-grade AI automation under your own brand—no development costs, no technical complexity.

Perfect for Agencies & Entrepreneurs:

For Solopreneurs

Compete with enterprise agencies using AI employees trained on your expertise

For Agencies

Scale operations 3x without hiring through branded AI automation

💼 Build Your AI Empire Today

Join the $47B AI agent revolution. White-label solutions starting at enterprise-friendly pricing.

Launch Your White-Label AI Business →

Enterprise white-labelFull API accessScalable pricingCustom solutions


Posted

in

by

Tags: