+220 XP

Capstone: a real end-to-end ChatGPT workflow

This lesson builds one realistic system end to end. It's a customer-support assistant for a small SaaS company. It answers from a knowledge base, pulls live order and account data, escalates hard tickets to a human, and emails a weekly health report to the founder every Monday. You already know the pieces individually. This lesson is about wiring them together and, more importantly, **choosing *which* piece to use where**.

The scenario and the constraints

"SupportBot" must do four things:

  1. Answer product questions from internal docs.
  2. Look up a customer's live subscription and recent tickets.
  3. Hand off to a human when confidence is low or the customer is angry.
  4. Produce a weekly report on ticket volume, resolution time, and top issues.

The constraints that drive every decision: the team is two people, the docs change weekly, and customer data lives in a Postgres database and Zendesk. They push us toward different surfaces for different jobs.

Decision 1: custom GPT or the API?

This is the central architecture fork, so resolve it first.

A Custom GPT (configured at chatgpt.com, shared via the GPT Store, a private link, or your workspace) is the right home for the *internal-facing* assistant. Your two support agents open it inside ChatGPT, paste a customer email, and get a drafted reply grounded in your docs. There's no hosting and no auth code. Your API is reachable through Actions.

The API (the Responses API) is the right home for anything customer-facing or automated: the widget on your website, the nightly report job. You need programmatic control, your own auth, logging, and the ability to run without a human in the loop.

So the answer is both, split by audience:

  • Agent-facing drafting tool: Custom GPT.
  • Website widget and scheduled report: API.

Don't force one surface to do everything. The Custom GPT is your fast path; the API is your durable path.

Decision 2: How docs get into the answer

The docs change weekly, so grounding strategy matters.

On the ChatGPT side, use the Google Drive app (ChatGPT renamed "connectors" to "apps" in late 2025) to link the live folder where the team keeps docs. ChatGPT searches that source at query time, so a Monday edit shows up Monday. Uploading static files to the GPT's knowledge would go stale and need re-uploading. Check help.openai.com for which apps your plan supports and how admins control them, since availability inside Custom GPTs varies by plan.

For the API-backed widget, you own retrieval. Either run your own vector search and pass results into the prompt, or use file search as a hosted tool on the Responses API. For a two-person team, hosted file search is the pragmatic choice because there's less infrastructure to babysit. A weekly cron job re-syncs the docs into the vector store.

Decision 3: Live data via Actions vs. function calling

The assistant needs getCustomer(email) and getRecentTickets(customerId). It's the same capability with two implementations, depending on surface.

In the Custom GPT, you expose these as GPT Actions: an OpenAPI spec pointing at your internal API, with auth configured in the GPT builder. The model decides when to call them.

In the API widget, the same operations become function calling with strict schemas, so the arguments arrive as schema-valid JSON every time. Here is the tool definition for the Responses API:

python
from openai import OpenAI

client = OpenAI()

tools = [{
    "type": "function",
    "name": "get_customer",
    "description": "Look up a customer's subscription and account status by email.",
    "parameters": {
        "type": "object",
        "properties": {
            "email": {"type": "string", "description": "Customer email address"}
        },
        "required": ["email"],
        "additionalProperties": False
    },
    "strict": True
}]

response = client.responses.create(
    model="gpt-5",
    input="What plan is taylor@acme.com on, and is their account in good standing?",
    tools=tools
)

print(response.output)

strict: True is the part to internalize. It guarantees the model's arguments conform to your schema, so your backend never has to defensively parse a malformed email field. Pick the model from the models page. A smaller variant like gpt-5-mini is often enough for lookups and cuts cost on a busy widget. The function calling guide covers the full loop, including how to send the tool result back for the model's final answer.

The same OpenAPI operations back both your GPT Actions and your function-calling tools. Write the API once, expose it twice.

Decision 4: Escalation and the human-in-the-loop boundary

Never let a support bot guarantee a refund or close a ticket on its own. Build an explicit escalation tool, escalate_to_human(reason, urgency), and instruct the model to call it when the customer is upset, asks for money, or the docs don't cover the question.

Make escalation a first-class tool with its own strict schema. When it's called, your code drops the conversation into a Zendesk queue and tells the customer a human is on it. "The bot got it wrong" becomes "the bot knew its limits," and that's the difference between a useful assistant and a liability.

Decision 5: Where the model orchestrates vs. where your code does

With several tools and multi-step logic (look up customer, check tickets, decide to answer or escalate), you have options:

  • Let the model orchestrate via the Responses API tool loop. Simple, good for linear flows.
  • Use the Agents SDK when you want typed agents, handoffs between specialized agents (a "billing agent" and a "technical agent"), guardrails, and tracing. For SupportBot's escalation-and-handoff pattern, the Agents SDK earns its keep because handoffs are a built-in primitive.
  • Use AgentKit, launched in October 2025. Agent Builder lets you lay out the same workflow visually. ChatKit gives you an embeddable chat UI, which can save you from building the website widget front end yourself.

The ChatGPT agent (the browsing, clicking, multi-step agent inside ChatGPT) is great for one-off investigations like "go find every open ticket mentioning the new billing bug." It's not where you run production traffic. Use ChatGPT agent for exploration and the Agents SDK or AgentKit for the deployed system.

Decision 6: The weekly report

This is where Code Interpreter (data analysis) shines. The report needs real computation: median resolution time, week-over-week ticket deltas, a chart of top issue categories.

You have two clean options.

Option A: a scheduled task in ChatGPT. ChatGPT tasks run a prompt on a recurring schedule and notify you with the result. Tasks run from a regular ChatGPT conversation, not from inside a Custom GPT. Put the instructions in the task itself, for example: "Every Monday at 8am, summarize last week's tickets from the Zendesk export in my Project, compute resolution stats, and flag the top three issues." It's the lowest-effort option and there's no code to host, but check what tools a task can use on your plan.

Option B: an API job on your own cron. A small script queries Postgres, hands the rows to the model with the Code Interpreter tool to crunch numbers and render a chart, then emails the result. It gives you more control, and it's version-controlled and testable. Choose this when the report feeds something downstream or the founder needs the same format every time.

For a two-person team, start with Option A. Graduate to Option B when the report becomes load-bearing or when you need it to pull live data unattended.

Building a Customer Support Agent with the OpenAI Agents SDK

Watch on YouTube

Knowledge check

1. In the SupportBot design, why is a Custom GPT chosen for the agent-facing drafting tool rather than the API?

2. The lesson concludes the answer to 'Custom GPT or API?' is 'both.' What principle drives that split?

3. Given that the docs change weekly, why does the lesson prefer linking a live Google Drive folder via Connectors over uploading static files to the GPT's knowledge?

MULTIPLE CHOICE

4. Select ALL tasks in the SupportBot scenario that are best served by the API rather than the Custom GPT.

Select all the correct answers.

MULTIPLE CHOICE

5. Select ALL constraints the lesson says should drive SupportBot's architecture decisions.

Select all the correct answers.

Putting the surfaces together

Here is the full picture, surface by surface:

JobSurfaceWhy
Agents drafting repliesCustom GPT + apps + ActionsFast, no hosting, live docs
Website chat widgetResponses API + file search + function calling (ChatKit for the UI)Programmatic, owns auth and logging
Multi-agent routing and escalationAgents SDK or Agent BuilderHandoffs and guardrails are built in
Weekly reportChatGPT task (start), then API + Code Interpreter (scale)Real computation on a schedule

One backend API serves the lookups, exposed as Actions to the GPT and as function tools to the API. One doc source (the Drive folder) feeds both the ChatGPT app and the file-search sync. You are not building four systems. You are building two integration points, your API and your docs, and pointing multiple surfaces at them.

Memory, Projects, and instructions

A few ChatGPT features quietly improve the agent-facing tool:

  • Put SupportBot's tone rules, escalation policy, and the "always cite the doc" rule in the Custom GPT's instructions, not in every prompt.
  • Group the team's support work in a Project so conversations, files, and instructions stay scoped together, separate from their other ChatGPT use.
  • Leave memory off for support work. You do not want it carrying assumptions between unrelated customers. Memory is great for a personal assistant and risky for a shared support tool.

A note on Canvas and Codex

When you're writing the report templates or the email copy, Canvas is a better editing surface than chat because you iterate on a document in place. The implementation work (the Responses API script, the OpenAPI spec, the cron job) is exactly what Codex is for. Use it to scaffold the function-calling loop and the Postgres query, then review every line before it touches customer data.

Failure modes to design for

Before you ship, decide in advance what happens when things break:

  • The lookup API is down. Your function should return a clear error object, and the model's instructions should say "if a lookup fails, escalate rather than guess."
  • The model invents a policy. Constrain it to answer only from retrieved docs. If retrieval returns nothing relevant, it should say so and escalate.
  • Rate limits or cost spikes. Log token usage per conversation. The website widget is your uncapped surface, so cap conversation length and add a fallback to human handoff.

Design these on paper first. They are cheaper to decide now than to debug in production.

Key Takeaways

  • Split by audience, not by feature. A Custom GPT serves your internal team (fast, no hosting). The Responses API handles customer-facing and automated flows (control, logging, auth).
  • Build the backend once and expose it twice. The same OpenAPI operations power your GPT Actions and your function-calling tools, and one doc folder feeds both the ChatGPT app and file search.
  • Make escalation a first-class tool with a strict schema. Instruct the model to escalate on failure or low confidence instead of guessing.
  • Start on the low-effort surface and graduate when the job becomes load-bearing. A ChatGPT task can handle the first weekly reports. An API + Code Interpreter cron job takes over when the report feeds something downstream.
  • Reach for the Agents SDK or AgentKit when you need handoffs, guardrails, tracing, or a ready-made chat UI. Keep ChatGPT agent for exploration, not production traffic.

What to do, from this lesson

These actions are compiled in the role's Playbook.

  • Let the model own only generation; gather, validate, and deliver in code
See the full action playbook →