Communication between parent website and Retool iFrame

We have a website built with Webflow and one of the pages uses Retool iFrame, it gets connected like this:

window.retool.RetoolDashboard(
  document.getElementById('foobar-retool-app-container'),
  'https://foobar.retool.com/embedded/public/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx'
)

At some point in time the parent website should ask our Retool app to run some query and send results back. Hence, I was looking for way for a parent-Retool two-way communication. I have found a way for the Retool app to send data to the parent using parent.postMessage and it is working great! However, if you need to send data from parent to Retool iFrame, you only have an option to use Parent Window Query Embed web apps | Retool Docs
However, it's not clear how to use it and how it is supposed to work. Could you please describe more how it can help me in my case? I need my parent website at some random point in time to ask Retool to run a query. I also need to pass some parameters from parent to Retool that the query will use.

I actually found another way of parent -> Retool communication by accident. Turns out, you can use
retoolIframeEl.contentWindow[1].postMessage(eventObject, '*')
or
retoolIframeEl.contentWindow[0].postMessage(eventObject, '*')
where
const eventObject = { literally: 'any', thing, you, want, to, send }

But it's unreliable and is not recommended to be used in production.
So, my second question is: are you planning to make this official in future? It would be great to have a parent -> Retool counterpart of postMessage. It is much more easy-to-understand than Parent Window Query.

Thank you! Retool is great.

1 Like

@JohnSmith very helpful workarounds!!

Did you ever figure out how to do this properly/reliably?

The official guide indeed has some resources, but it’s not very straightforward how to achieve what you mentioned above (I’m looking to do the exact same thing).

@victoria any thoughts?

Hey @matei, were you having issues using the Parent Window Query? Can you share how you have this set up and what errors you were running into?