globe-pointerEmbedded UI

Get Started

To embed the Yofi UI into your website, use the following code snippet:

<iframe
    ref={iframeRef}
    title="portal"
    src="THE-EMBED-URL"
    style={{ border: 'none', width: '100%', height: '100%' }}
></iframe>
circle-exclamation

Send events to the iframe

const message = {
    type: "EVENT_TYPE",
    data: "YOUR_DATA"
};
iframeRef.current.contentWindow.postMessage(message, 'THE-EMBED-ORIGIN');

Supported Messages

Event
Message Sample

Show customer detail

{ type: 'SHOW_CUSTOMER_DETAIL', data: { id: 'CUSTOMER-ID', token: 'JWT-TOKEN(OPTIONAL)' } }

Show order detail

{ type: 'SHOW_ORDER_DETAIL', data: { id: 'ORDER-ID', token: 'JWT-TOKEN(OPTIONAL)' } }

Set auth token (How to)

{ type: 'SET_TOKEN', data: 'JWT-TOKEN' }

Reload page

{ type: 'RELOAD' }

Listen to events from the iframe in your app

The iframe may send messages back to your application. For instance, it might send an TOKEN_REFRESH event if the token expires. Here's how you can listen for messages from the iframe:

Passing the Token via Query Parameter

You can also pass the token to the iframe by including it as a query parameter in the iframe's URL.

You can open order page and customer page with:

Please change https://embed.yofi.ai to https://embed.botnot.ioif you want to use this in production env.

Key Notes

  • Ensure the iframe source (src) and origin (urlOrigin) are correctly set to match your environment.

  • Always verify the origin of incoming messages to prevent security vulnerabilities.

  • Use the provided event types and data structures to communicate effectively with the iframe.


React Sample

Last updated

Was this helpful?