ChatGPT App - Enable punchout button with dynamic url

Hello

I’m building an MCP server with a widget and need help with the punch-out button.

The Problem
When my tool generates content, it creates a unique URL with a parameter (e.g., https:/example.com/item?id=ABC123). I want the punch-out button to open this specific URL, but it only opens the static base domain (https:/example.com) that I set in the resource’s _meta.

What I’ve Tried
I’ve tried setting openai/widgetDomain in:

  1. The resource definition (in resources/read response)
  2. The tool response _meta
  3. The widget resource’s _meta inside the tool response

None of these approaches make the punch-out button use the dynamic URL.

The Question
How do I make the punch-out button open a different URL for each tool invocation?

I know Canva does this - when you generate a design, the punch-out button opens that specific design’s editor, How is this achieved?

Any guidance would be appreciated! Thanks!

2 Likes

Hi!

If your punch-out button is inside your widget, use window.openai.openExternal({ href: url}) method to open any URL.

Of course, this URL could be dynamic.

Thank you for responding. I believe the punch-out button is enabled when openai/widgetDomain is set as mentioned in the OpenAi apps-sdk docs. It’s the one that says “Open in Canva” from the screenshot below.

image