How To Use OpenAI Agent Builder For Advanced Users

By corbin

Share:

Key Concepts

  • OpenAI Agents: AI entities capable of performing tasks by interacting with tools and processing information.
  • Zapier MCP (Multi-Channel Protocol): A Zapier feature that allows OpenAI agents to access and interact with over 8,000 applications and their APIs.
  • Payload Formatter: An agent designed to extract and structure data (payload) from user input into a standardized format, typically JSON.
  • JSON Schema: A declarative language used to define the structure and validation rules for JSON data.
  • Reasoning Effort (Low/High): A setting in agent builders that dictates the AI's cognitive load. "Low" is for simple data extraction, "High" is for complex tasks requiring self-correction and tool usage.
  • Set State: A mechanism within agent workflows to store and pass dynamic data (variables) between different agent blocks, making it accessible throughout the entire workflow.
  • Bumpup's API: A third-party API used in this workflow to analyze YouTube video content and answer questions about it.
  • YouTube Data API: Google's API for accessing YouTube data, used here to retrieve video metadata like thumbnail, title, and duration.
  • Custom Widget UI: A user interface component created dynamically by an agent to display specific data in a visually appealing format within the chat output.
  • API Key: A unique identifier used to authenticate and authorize access to an API.
  • Metadata: Data that provides information about other data, such as a video's title, duration, or thumbnail URL.
  • Enum (Enumerated Type): A data type that consists of a set of named values, often used for predefined options (e.g., bump-1.0 for a model, text for output format).
  • String, Number, Boolean: Fundamental data types used to define the nature of variables (text, numerical value, true/false).
  • state.variableName: A syntax used within the agent builder to dynamically access variables that have been stored in the workflow's "state."

Introduction and Workflow Overview

The video demonstrates building a practical OpenAI agent using Zapier's Multi-Channel Protocol (MCP) to create a YouTube bot. Unlike generic examples, this bot offers a real-world use case: analyzing any YouTube video link, answering user-specific questions about its content, and presenting key video metadata (thumbnail, title, duration) in a custom chat widget. The workflow is designed to be free-form, allowing users to ask diverse questions like "key points," "X tweets," "blog post," or "top 10 quotes." Zapier sponsors this video, highlighting its role in empowering OpenAI agents with access to over 8,000 applications.

The demonstration showcases a preview where a user inputs a YouTube link and a prompt like "what are the three main points about this video." The bot processes this, extracts the main points, and then displays a custom widget containing the video's thumbnail, title, and duration.


Building the YouTube Bot Workflow

The process involves setting up three main agent blocks within the OpenAI Agent Builder. This video is part of a larger series that will eventually cover deploying this code to a real website using Chatkit.

1. Agent Block: Data Grabber / YouTube Helper

  • Purpose: This initial agent's sole function is to extract the user's YouTube URL and their question (prompt) from the input message and format it into a structured payload.
  • Prompt: "You are a payload formatter. User will provide the YouTube URL and set it as a JSON schema for URL. And then the user will ask a question about the video and set that for the prompt."
    • Payload: A developer term for data being sent between different software components.
    • Dynamic Variables: The prompt uses "setting" to establish dynamic variables (URL, prompt) that will be updated with each new user session.
  • Output Format: JSON.
  • Model: Steco DBT5 is recommended for beginners as a "one-size-fits-all" model.
  • Reasoning Effort: Set to Low. Since this agent only extracts and formats data without complex reasoning, a low reasoning effort is faster and sufficient.
  • Schema Configuration (Simple):
    • Payload Name: user data.
    • Properties:
      • relevant URL: Type string (for the YouTube link).
      • prompt: Type string (for the user's question).
    • Importance of Data Types: The video emphasizes selecting the correct data type (string, number, boolean) to prevent errors when sending payloads to third-party applications. It suggests using AI models like ChatGPT to confirm correct API data types.
    • Naming Convention: Naming the properties URL and prompt is crucial for later integration with Bumpup's API.
  • Testing: A preview test confirms that the agent correctly extracts the YouTube URL into the URL parameter and the user's question into the prompt parameter, visible in the "evaluate" section under "post response." This structured output makes the user's natural language input legible for AI processing.

2. Passing Data in Complex Workflows: Set State

  • Challenge: In complex workflows, data extracted by one agent isn't automatically accessible by subsequent agents.
  • Solution: The "Set State" block is used to assign extracted data to workflow-level variables, making them globally accessible.
  • Process:
    • Connect the "Set State" block after the "YouTube Helper."
    • Assign Values: Map the data from the user data payload to new variables:
      • URL (from user data) is assigned to YouTube URL (workflow variable).
      • prompt (from user data) is assigned to prompt (workflow variable).
      • Additional variables for Bumpup's API parameters are also set: model, language, output format.
    • Recommendation: Use consistent naming for variables (e.g., model for both the payload property and the workflow variable) to avoid confusion.
  • Benefit: This fundamental skill allows data to be passed and utilized throughout the entire workflow, regardless of its complexity.

3. Agent Block: YTBot (Core Logic and API Integration)

  • Purpose: This agent performs the core task of analyzing the YouTube video content using external APIs.
  • Tools: Zapier MCP Server.
    • Setup: Create a new MCP server named YTbot, selecting OpenAI API as the client.
    • Adding Tools:
      • YouTube: Add the find video action to retrieve video metadata.
      • Bumpup's API: Add the send chat action. This API allows asking specific questions about a YouTube video given its link. Other Bumpup's functions (e.g., generating timestamps) are available but not used in this specific workflow.
    • Connecting Accounts: Standard API key retrieval process (e.g., for Bumpup's: Profile -> Settings -> API -> Create API Key). The secret key is copied and pasted into the Zapier MCP connection.
  • Reasoning Effort: Set to High. For agents performing complex tasks involving external API calls and potential errors, "High" reasoning allows the agent to self-correct and intelligently handle issues, preventing it from "running into a wall."
  • Prompt Construction:
    • The prompt includes the expected data structure for the Bumpup's send chat payload, copied directly from the MCP tool documentation.
    • Payload for Bumpup's send chat:
      • URL: state.YouTube URL
      • model: state.model (e.g., bump-1.0, an enum type)
      • prompt: state.prompt
      • language: state.language (e.g., English, a string type)
      • output format: state.output format (e.g., text or markdown, an enum type)
    • state.variableName Explanation: This syntax (state.YouTube URL) is used to dynamically access the variables previously stored in the "Set State" block, ensuring the agent uses the correct, user-provided data.
    • Final Instruction: "Use the MCP tool and receive its response and put it in chat."

4. Agent Block: Custom Widget UI (YT UI)

  • Purpose: This agent is responsible for fetching additional video metadata and displaying it in a custom-designed widget within the chat output.
  • Tools: Zapier MCP Server (using the same API key).
    • Tool: YouTube find video (its sole purpose here).
  • Prompt Construction:
    • The prompt specifies the YouTube find tool action and requests specific variables: URL, max res, duration, and title.
    • Identifying Variable Names:
      • Option 1 (API Documentation): Consult the YouTube Data API documentation (e.g., search.list event) to find parameter names like videoDuration or URL max res for high-resolution thumbnails.
      • Option 2 (AI Model): Ask an AI model (e.g., ChatGPT) "YouTube API, what is the API data point for the duration of a video?"
    • Specific Details: URL max res is chosen for the best thumbnail quality.
    • Instruction: "Then place in widget."
  • Widget Creation:
    • Use the "Text Check Widget" and "Add Widget" feature.
    • Prompt for Widget Creator: "We need a YouTube widget that will showcase video thumbnail, URL, max res, video duration, and title."
    • Tip: Emphasizes the importance of a precise initial prompt for the widget creator to avoid errors. If errors occur, retrying with a better prompt is recommended.
    • Upload Widget: The generated .widget file is downloaded and then uploaded back into the agent builder. The low-resolution preview is noted as temporary, as the actual data will populate it during runtime.
    • Final Instruction: "Here is a YouTube video add context YouTube URL." (To link the widget to the specific video).

Workflow Testing and Refinements

The complete workflow is tested with a prompt like "what is the best quote from this video" and a YouTube link.

  • Execution Flow:
    1. Data extraction (user's prompt and URL).
    2. Data is set as variables for YTbot and YT UI.
    3. YTbot initiates, analyzing the video via Bumpup's API to find the quote.
    4. Approval Step: The agent pauses for user approval before executing the tool.
      • Disabling Approval: This can be turned off by navigating to the bot's settings: Bot -> Tools -> Zapier -> Approval -> "Never require approval for any tool" -> Update.
    5. YT UI initiates, fetching video metadata and displaying the custom widget with the thumbnail, title, and duration.
  • Example Output: The bot successfully extracts a quote from the video ("This is a developer heavy, but don't worry. I'm going to make it sound very easy, almost like you're going to McDonald's and ordering your favorite Happy Meal.") and displays the video's metadata in the widget.

Conclusion and Future Plans

This detailed workflow demonstrates how to build a powerful OpenAI agent capable of interacting with external APIs (YouTube, Bumpup's) via Zapier MCP to provide specific, actionable insights from YouTube videos and present them in a custom UI. The creator plans to further develop this project, making all the code open-source and freely available on GitHub, and expanding its capabilities in future videos. Zapier's integration significantly enhances the power of OpenAI agents by providing access to a vast ecosystem of over 8,000 applications.

Chat with this Video

AI-Powered

Load the transcript when you're ready to chat so the initial page stays lighter.

Ready to summarize another video?

Summarize YouTube Video