Dominik_Libner
October 21

My form is hidden by default. I load the SDK and wait for the Messenger.ready event. On that event, I need to know whether to show the form, but the only events available for subscribtion are those informing about a running conversation (which would hide the form). In there was no conversation at all, there is no way to show the form other than setting a timeout for X seconds and waiting for conversation restoration. If the time elapses, the form will be show. I don't find this solution elegant.

Am I missing something? Isn't there a straightforward way to explicitly define whether there is a conversation to restore when the SDK is ready?


Visit Topic to respond.


In Reply To

edgars.dudins
October 18
Launcher.visible if I am correct is being displayed every time that circle button appears, which opens the chat, no matter if it is started or not. Could I ask you if you use any custom button for the form to appear? Because actually our web devs have achieved similar functionality and it went suc…

Previous Replies

edgars.dudins
October 18

Launcher.visible if I am correct is being displayed every time that circle button appears, which opens the chat, no matter if it is started or not.

Could I ask you if you use any custom button for the form to appear?

Because actually our web devs have achieved similar functionality and it went successfully. Probably it is a good point to show Form and Web Messaging only when all the plugins have loaded successfully and load the form only when there is not on-going conversation & hide chat by that time and launch it only when form is fulfilled.

The main idea if you want everything to fire in proper way, allow SDK to fully load and then perform actions on it, if the idea is understandable. Because if you make the form appear immediately when site is launched, you do not leave any space of time for SDK to do its actions on back-end, because it has to load all the plugins.

Dominik_Libner
October 17

Thank you for your answer. Technicaly "MessagingService.restoring" is equivalent to "Launcher.visible" for me because it indicates that Messenger is going to be displayed and I don't want to show my form component. This scenario is still "event racing" because I would like to show my form component as soon as possible if there is no session to restore. I actually need an information that there is no session to restore when "Messenger.ready".

Concept:

Genesys("subscribe", "Messenger.ready", function(data){
        if(!data.session){
              //show form component
        }else{
              //do not show form component
        }
});

Can you see any equivalent solution for this?

Ranjith_Manikante_Sa Genesys Employee
October 16

Hi @Dominik_Libner,

To determine if there is an active session available or not, you could rely on MessagingService.restoring event. This is something new that we added recently which is published when we detect that there is an active session to restore. This would be the earliest way for you determine any active conversation.You will soon see this available in our MessagingService Plugin documentation.

Alternatively, you could also rely on MessagingService.restored event which is published a bit later than MessagingService.restoring event as it waits until after the conversation history is fetched. Hope this helps, let us know.

Angelo_Cicchitto Genesys Employee
October 16

Hi @Dominik_Libner trying to better understand the criteria for showing the form: it sounds like you would need an Event from MessaigngService Plugin when a session already exists, to avoid showing the form again?

Dominik_Libner
October 16

Hi all,

We would like to help our client to create an interactive form that will put "participant data" into the conversation.
We are facing a problem during page reload because we can't define if there is an active session or not. Based on this information the form is being shown or not. The session information is stored in a cross-domain localStorage that cannot be fetched.
For this moment I use setTimeout and a helping flag set on Launcher.visible event but this solution is very "ugly":

<script type="text/javascript" charset="utf-8">
    (function (g, e, n, es, ys) {
      g['_genesysJs'] = e;
      g[e] = g[e] || function () {
        (g[e].q = g[e].q || []).push(arguments)
      };
      g[e].t = 1 * new Date();
      g[e].c = es;
      ys = document.createElement('script'); ys.async = 1; ys.src = n; ys.charset = 'utf-8'; document.head.appendChild(ys);
    })(window, 'Genesys', 'https://apps.mypurecloud.ie/genesys-bootstrap/genesys.min.js', {
      environment: '..............',
      deploymentId: '...............'
    });
</script>

<script type="text/javascript">
    Genesys("subscribe", "Messenger.ready", function(){
        //hiding form
        Genesys("subscribe", "Launcher.visible", function(){
            window.launcherVisible = true;//helping flag for page reload with active session
            document.getElementById("custom-form").style.display = "none";
        });
        //showing form after conversation is closed
        Genesys("subscribe", "Launcher.hidden", function(){
            document.getElementById("custom-form").style.display = "flex";
        });
        //showing form
        Genesys("subscribe", "Launcher.ready", function(){
            console.log("Launcher.ready");
            setTimeout(()=>{
                if(!window.launcherVisible){
                    document.getElementById("custom-form").style.display = "flex";
                }
            }, 1000);

        });
    });
    
</script>

<script type="text/javascript">
    //submit form and start GC Messenger
    function submitFormToMessenger(){
        //some validation
        if(!document.getElementById("custom-form-name").value || !document.getElementById("custom-form-surname").value)
        {
            alert("Please provide name and surname.");
            return;
        }
        //inicjalizacja
        Genesys("command", "Database.set", { messaging: { customAttributes: {
                custom_name: document.getElementById("custom-form-name").value,
                custom_surname: document.getElementById("custom-form-surname").value 
            }}},
            function(data){ /* fulfilled, returns data */
                Genesys("command", "Messenger.open",
                {},
                    function() {
                        /*fulfilled callback*/
                    },
                    function() {
                        /*rejected callback*/
                    }
                );
            }, 
            function(){ /* rejected */ 
                
            });
    }
</script>

<!-- some form -->
<form id="custom-form" style="margin:auto; width: 250px; display: none; flex-direction: column; padding: 16px; border-radius: 8px; background-color: #cccccc;">
    <input placeholder="Name" type="text" id="custom-form-name" value=""/>
    <br />
    <input placeholder="Surname" type="text" id="custom-form-surname" value=""/>
    <br />
    <button type="button" onclick="submitFormToMessenger()">Submit</button>
</form>


Can you see more clean solution to find out if the chat session is active during a page loading?

BR,
Dominik


Visit Topic to respond.

You are receiving this because you enabled mailing list mode.

To unsubscribe from these emails, click here.