---
name: building-chatgpt-apps
description: |
Guides creation of ChatGPT Apps with interactive widgets using OpenAI Apps SDK and MCP servers.
Use when building ChatGPT custom apps with visual UI components, embedded widgets, or rich
interactive experiences. Covers widget architecture, MCP server setup with FastMCP, response
metadata, and Developer Mode configuration. NOT when building standard MCP servers without
widgets (use building-mcp-servers skill instead).
---
# ChatGPT Apps SDK Development Guide
## Overview
Create ChatGPT Apps with interactive widgets that render rich UI inside ChatGPT conversations. Apps combine MCP servers (providing tools) with embedded HTML widgets that communicate via the `window.openai` API.
---
## window.openai API Reference
Widgets communicate with ChatGPT through these APIs:
### sendFollowUpMessage (Recommended for Actions)
Send a follow-up prompt to ChatGPT on behalf of the user:
```javascript
// Trigger a follow-up conversation
if (window.openai?.sendFollowUpMessage) {
await window.openai.sendFollowUpMessage({
prompt: 'Summarize this chapter for me'
});
}
```
**Use for**: Action buttons that suggest next steps (summarize, explain, etc.)
### toolOutput
Send structured data back from widget interactions:
```javascript
// Send data back to ChatGPT
if (window.openai?.toolOutput) {
window.openai.toolOutput({
action: 'chapter_selected',
chapter: 1,
title: 'Introduction'
});
}
```
**Use for**: Selections, form submissions, user choices that feed into tool responses.
### callTool
Call another MCP tool from within a widget:
```javascript
// Call a tool directly
if (window.openai?.callTool) {
await window.openai.callTool({
name: 'read-chapter',
arguments: { chapter: 2 }
});
}
```
**Use for**: Navigation between content, chaining tool calls.
---
## Critical: Button Interactivity Limitations
**Important Discovery**: Widget buttons may render as **static UI elements** rather than interactive JavaScript buttons. ChatGPT renders widgets in a sandboxed iframe where some click handlers don't fire reliably.
### What Works
- `sendFollowUpMessage` - Reliably triggers follow-up prompts
- Simple onclick handlers for `toolOutput` calls
- CSS hover effects and visual feedback
### What May Not Work
- Complex interactive JavaScript (selection APIs, etc.)
- Multiple chained tool calls from buttons
- `window.getSelection()` for text selection features
### Recommended Pattern: Suggestion Buttons
Instead of complex interactions, use simple buttons that suggest prompts:
```html