HTML component and JourneyIFrameClient

I am trying to communicate with an HTML component. The HTML is uploaded to the application on the Assets menu.

I think what happens is that the HTML that is uploaded does not recognise the 'JourneyIFrameClient' class. When I have the following code in the html file:

alert (“This is a warning message!”);
const JourneyClient = new JourneyIFrameClient();
alert (“This is NOT a warning message!”);

The second alert does not run. Should the source code for the JourneyIFrameClient perhaps be included in the html file that is uploaded? How does it know the definition of the JourneyIFrameClient class?

I am running this in a tutorial sandbox - testing environment.

The JourneyIFrameClient component is listed as typescript files on github.

Using the tsc command, it can be compiled into javascript.

Then these files can be pasted into an HTML file (but remove all the export and import and default keywords) and the HTML file uploaded to Journey.

(I am sure there are other ways of doing this too)

1 Like

As with any npm package, you will need to add the journey-iframe-client package to your project. You can then import it into your main JS/TS file:

const JourneyIFrameClient = require("journey-iframe-client");

Instead of copy and pasting the code, you can use something like webpack to bundle everything into one HTML file. You can do this for any npm packages.

1 Like