Legacy Dev Forum Posts

 View Only

Sign Up

About registerPlugin and startConversation

  • 1.  About registerPlugin and startConversation

    Posted 06-05-2025 18:37

    IvanDg | 2023-07-14 04:51:57 UTC | #1

    We are creating a headless sdk mode, and it is almost done but I have few items to ask on the initialization process. Our current flow is the following: Load genesys script→ registerPlugin(on success and error call start Conversation) → initialize event listeners on different events.

    1. May I know what registerPlugin does? We are invoking it after on load of script just because it is in the documents.
    2. We call startConversation on success and error of registerPlugin. Is this correct?
    3. We added timeout on startConversation because we get errors without it. And our timeout's magic number is 3000ms. If I changed it to 1000 or 2000, I get the following error:

    Why I also call startConversation on error case, is because sometimes "Can't register plugin, name already exists" occurs and in that case, our conversation doesn't start.


    RanjithManikanteSa | 2023-07-19 21:05:33 UTC | #2

    Hi @IvanDg,

    1. registerPlugin registers a plugin with the namespace you provide. It can contain commands and events that can be used later after the plugin is initialized. Note that you can register a plugin 'X' only once, if you try to register again, you will get the error Can't register plugin, name already exists, which is what you ran into already. To avoid this, you can simply store the instance of a plugin in a variable and check for it before registering it.
        var oMyPlugin = "";
    
        if (!oMyPlugin) {
          Genesys("registerPlugin", "MyPlugin", function(oPlugin){
              oMyPlugin = oPlugin;
              .....
              .....
          });
       }
    
    2. No, you should only call startConversation, once the plugin is successfully registered. The error callback is for you to handle the failure.
    
    3. It could be that MessagingService plugin command is called too early before its ready. Please try subscribing to `MessagingService.ready` [event](https://developer.genesys.cloud/commdigital/digital/webmessaging/messengersdk/SDKCommandsEvents/messagingServicePlugin#messagingservice-ready) before calling its commands.

    system | 2023-08-18 21:05:48 UTC | #3

    This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.


    This post was migrated from the old Developer Forum.

    ref: 20976