Load plugin in hidden iframe - Extreme HARD

Hi,

i have chatbot platform and i need to load initial chat page in hidden iframe on every page view. Only when user click button and iframe appear, i need to load rest (group with searches, etc…). So i made listener for post message when somebody clicks the button.

Now i need to trigger workflow when message come. So i created very easy plugin to trigger workflow, when i call function “event_trigger”.

Problem is, that this element plugin loads with page (and works) only if i have iframe opened. So, if iframe is loaded in background without visibility, plugin doesnt load and bubble doesnt find plugin function “event_trigger”.

Here is element code:

function(instance, properties, context) {
  var fnName = "event_trigger";
  window[fnName] = function(value) {
        instance.triggerEvent("event");   
    }
}

Is possible to somehow make it works?

Thank you for any responses.

Michal