[GH-ISSUE #20879] feat: send initial postMessage when OpenWebUI runs inside an iframe #34850

Closed
opened 2026-04-25 09:01:54 -05:00 by GiteaMirror · 1 comment
Owner

Originally created by @ragaslan on GitHub (Jan 22, 2026).
Original GitHub issue: https://github.com/open-webui/open-webui/issues/20879

Check Existing Issues

  • I have searched for all existing open AND closed issues and discussions for similar requests. I have found none that is comparable to my request.

Verify Feature Scope

  • I have read through and understood the scope definition for feature requests in the Issues section. I believe my feature request meets the definition and belongs in the Issues section instead of the Discussions.

Problem Description

When OpenWebUI is embedded in a cross-origin iframe, there is currently no reliable way to prefill or trigger an initial prompt without requiring user interaction inside the iframe. This limits automation and makes integration with external applications more complex.

Image

Desired Solution you'd like

I wrote this code in my fork repository.

Image

What does this do?

This adds support for sending an initial chat input to OpenWebUI when it is loaded inside an iframe. The chat message can be optionally initialized via a URL query parameter, allowing a host application to automatically submit a prompt as soon as the iframe is ready.

How does it work?

  • Reads an optional initMessage query parameter from the iframe URL
  • On mount, sends a postMessage event to the current window with the provided prompt payload
  • Reuses the existing message handling flow to trigger the same behavior as a manual chat submission

How was this tested?

  • Embedded OpenWebUI in a host application running on a different port and domain
  • Verified that the initial prompt is processed on load
  • Tested in Chrome

Notes

This approach keeps the integration stateless and avoids introducing new global configuration or build-time options.

Alternatives Considered

No response

Additional Context

Example usage:

Image
Originally created by @ragaslan on GitHub (Jan 22, 2026). Original GitHub issue: https://github.com/open-webui/open-webui/issues/20879 ### Check Existing Issues - [x] I have searched for all existing **open AND closed** issues and discussions for similar requests. I have found none that is comparable to my request. ### Verify Feature Scope - [x] I have read through and understood the scope definition for feature requests in the Issues section. I believe my feature request meets the definition and belongs in the Issues section instead of the Discussions. ### Problem Description When OpenWebUI is embedded in a cross-origin iframe, there is currently no reliable way to prefill or trigger an initial prompt without requiring user interaction inside the iframe. This limits automation and makes integration with external applications more complex. ![Image](https://github.com/user-attachments/assets/ee17b557-7dde-42d8-acc2-cb69756ba500) ### Desired Solution you'd like I wrote this code in my fork repository. <img width="1569" height="526" alt="Image" src="https://github.com/user-attachments/assets/ad34fc84-26f9-4f1b-8bf2-7d7eb811936b" /> ## What does this do? This adds support for sending an initial chat input to OpenWebUI when it is loaded inside an iframe. The chat message can be optionally initialized via a URL query parameter, allowing a host application to automatically submit a prompt as soon as the iframe is ready. ## How does it work? - Reads an optional `initMessage` query parameter from the iframe URL - On mount, sends a `postMessage` event to the current window with the provided prompt payload - Reuses the existing message handling flow to trigger the same behavior as a manual chat submission ## How was this tested? - Embedded OpenWebUI in a host application running on a different port and domain - Verified that the initial prompt is processed on load - Tested in Chrome ## Notes This approach keeps the integration stateless and avoids introducing new global configuration or build-time options. ### Alternatives Considered _No response_ ### Additional Context ### Example usage: <img width="710" height="327" alt="Image" src="https://github.com/user-attachments/assets/d6abc58d-1838-4e80-83dc-e4a20fd2bf75" />
Author
Owner

@ragaslan commented on GitHub (Jan 22, 2026):

I’ve implemented this feature and will open a PR shortly.
Happy to adjust the approach based on any feedback.

PR opened: #20880
Happy to iterate based on feedback.

<!-- gh-comment-id:3784779155 --> @ragaslan commented on GitHub (Jan 22, 2026): I’ve implemented this feature and will open a PR shortly. Happy to adjust the approach based on any feedback. PR opened: #20880 Happy to iterate based on feedback.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/open-webui#34850