Genesys Cloud - Developer Community!

 View Only

Sign Up

  • 1.  Run custom JavaScript code on Genesys Cloud startup.

    Posted 16 days ago
    Edited by Mykola Selivanov 16 days ago

    Dear Community,

    I have a use-case I would like to ask for help with.

    The business requirement is the following: agent opens Genesys Cloud in a browser > logs in > a new browser tab (or a separate window) with CRM is automatically opened.

    This CRM is an <iframe>.

    The goal is to be able to manage this tab (or window) with the CRM fully from Genesys Cloud. CRM could send data via postMessage method back to Genesys Cloud. To do that, I imagine some JavaScript code would have to be run somewhere during Genesys Cloud startup.

    Has anyone any suggestions on achieving this?

    I realise my description might be confusing - please, ask any questions you have.

    Thanks in advance for your support.

    All the best

    Mykola


    #Uncategorized

    ------------------------------
    Mykola Selivanov
    NA
    ------------------------------



  • 2.  RE: Run custom JavaScript code on Genesys Cloud startup.

    Posted 2 hours ago

    Hello @Mykola Selivanov, let me know if any of these helps (if it does and is the best solution, please flag it as such ;-)) :

    So I understand you want to automatically open a CRM in a new browser tab/window when an agent logs into Genesys Cloud, with the CRM as an iframe that can communicate back to Genesys Cloud via postMessage. Let me outline several approaches I can think of to achieve this:

    1) Client Application Integration (Embedded in Genesys Cloud) : the most native approach is to use a Client Application Integration that embeds your CRM iframe directly within the Genesys Cloud interface.

    How it works:

    Create a Custom Client Application integration in Genesys Cloud
    Configure it with your CRM URL (must be HTTPS)
    The app is embedded as an iframe within Genesys Cloud's interface (not a separate tab)
    Available iframe sandbox options: allow-forms, allow-modals, allow-popups, allow-presentation, allow-same-origin, allow-scripts, allow-downloads
    Use the Client App SDK to enable communication between your CRM and Genesys Cloud

    Here is how I would set it up:

    Go to Admin > Integrations > +Integrations
    Install a Client Application integration
    Configure the Application URL with your CRM
    Specify iframe sandbox options
    Assign to groups/users
    Communication: The Client App SDK handles bidirectional communication and provides APIs for:

    Alerting
    Navigation
    Lifecycle management
    UI manipulation
    Access to conversation data

    BIG Limitation: This embeds the CRM within Genesys Cloud, not as a separate tab/window ;-)

    2) Screen Pop with Custom Action (Opens New Tab/Window)

    Using an Inbound Script or Interaction Widget with a custom action to automatically open your CRM in a new browser tab/window.

    How it works:

    Create a script with a "Custom Action" that opens a URL
    Configure it to trigger on page load or agent login
    Uses JavaScript window.open() to launch your CRM URL in a new tab/window

    How I would set it up:

    Go to Admin > Contact Center > Scripts
    Create a new script
    Add a Custom Action with your CRM URL (e.g., https://yourcrm.com)
    Set "Open in New Window" option
    Configure page load actions to trigger automatically
    Communication Challenge:

    For postMessage communication between separate browser tabs/windows, you'll need to:
    Keep a reference to the opened window: const crmWindow = window.open(url)
    Use crmWindow.postMessage(data, origin) from Genesys Cloud
    Set up event listeners in your CRM: window.addEventListener('message', handleMessage)
    Your CRM can send messages back using window.opener.postMessage() if it has a reference to the parent


    See there is an Aha! Idea (OP-I-1005) requesting iframe sandbox parameter allow-top-navigation which indicates some CRM integrations face navigation restrictions with the current implementation.

    3) Genesys Cloud Embeddable Framework (Reverse Integration)

    If you want the CRM to be the primary interface with Genesys Cloud embedded within, this is

    Your CRM hosts the page
    Genesys Cloud is embedded as an iframe in your CRM
    You control the window/tab behavior
    The dedicatedLoginWindow option can open a separate login window
    Configuration:

    {
      dedicatedLoginWindow: true,  // Opens separate login window
      embeddedInteractionWindow: false  // Pops interactions as separate window
    }

    This is best for scenarios where the CRM is the primary workspace and Genesys Cloud is secondary.

    4) Custom Browser Extension or User Script (Advanced)


    For truly custom behavior like auto-opening a specific tab on login I could also try the following approach:

    Create a browser extension (Chrome/Firefox)
    Inject custom JavaScript when agents load Genesys Cloud
    Use window.open() to launch your CRM on login detection
    Establish postMessage communication between windows

    Consider that this requires custom development so wont be supported by Genesys
    Must be installed on all agent browsers (tip: Chrome for Work allows enterprise deployment)

    For the postMessage Communication:

    // From Genesys Cloud to CRM window
    crmWindow.postMessage({ type: 'interaction', data: {...} }, 'https://yourcrm.com');

    // In your CRM iframe - listening for messages
    window.addEventListener('message', (event) => {
      if (event.origin === 'https://apps.mypurecloud.com') {
        console.log('Received from Genesys:', event.data);
      }
    });

    // From CRM back to Genesys Cloud
    window.opener.postMessage({ type: 'update', data: {...} }, 'https://apps.mypurecloud.com');
    Browser Pop-up Blockers:

    User must allow pop-ups from Genesys Cloud domain
    Configure browser settings to whitelist Genesys Cloud
    Security:

    Always validate message origins in postMessage handlers
    Use HTTPS for all URLs
    Configure proper CORS headers on your CRM

    hope some of these helps you!



    ------------------------------
    Joaquin Garcia Fink
    Senior Customer Success Manager
    Genesys - Employees
    ------------------------------