How to create a customer support chat box on saas product and user can use that on their website?

Suppose a SaaS platform, which is about to create a customer support chat box for user’s websites. When a user creates a chat box on this SaaS platform, the platform provides a JavaScript script tag with a specific src. When users use this script into their website, the chat box becomes visible on their website.

Now, my question is, how can I develop such a feature? Could someone please provide an explanation? Can i use Next.js?