locked
Building a livechat Api for 3rd party merchant RRS feed

  • Question

  • User-2097295820 posted

    Dear All,

    I have a livechat platform which I built on signalr. Unfortunately My system is quite primitive compare to most modern live chat system.

    On my platform I give my client a landing page with livechat icon.  So their customers have to redirect from to my via a pop window.

    I looked at modern livechat platforms like tawk.to.

    They give api codes that merchant can put in their website and the livechat box just appears on the right hand corner of the site.

        var Tawk_API = Tawk_API || {}, Tawk_LoadStart = new Date();
        (function () {
            var s1 = document.createElement("script"), s0 = document.getElementsByTagName("script")[0];
            s1.async = true;
            s1.src = 'https://embed.tawk.to/57c9a10414a31b655abc078b/default';
            s1.charset = 'UTF-8';
            s1.setAttribute('crossorigin', '*');
            s0.parentNode.insertBefore(s1, s0);
        })();
    

    That is a sample api code. So am trying to implement this on my own platform. Please can someone explain the software architecture behind this system. 

    I would love to layer my codes so that I can give my merchants apis too.

    Thanks alot.

    Friday, September 14, 2018 8:37 PM

All replies

  • User475983607 posted

    The JavaScript function shown is a Immediately Invoked Function Expression if that is what you are asking.

    https://developer.mozilla.org/en-US/docs/Glossary/IIFE

    Friday, September 14, 2018 9:20 PM
  • User61956409 posted

    Hi skliz4rel,

    It seems that you build a livechat system, and you'd like to enable others to embed your livechat to their website(s).

    To achieve the requirement, you can write a JavaScript function/library for dynamically creating elements on web page in order to load other required scripts and build chat window on target web page. And then others can reference to the JS library that you provided in their website web page to embed your livechat system in their own websites.

    Besides, using <iframe> would be a easy approach to embed your livechat in other websites. 

    the livechat box just appears on the right hand corner of the site.

    If you want your livechat display at specified position on web page, you can put the chat window in a container <div> element, and set the position CSS property to position the container element.

    With Regards, 

    Fei Han

    Monday, September 17, 2018 3:02 AM