Genesys Cloud - Developer Community!

 View Only

Sign Up

  • 1.  Genesys CX Cloud with Salesforce Voice - Reuse same credentials with managed package

    Posted 6 days ago

    Hi everyone,

    We are currently using  Genesys Cloud CX with Salesforce Voice in our org.

    I am extending the integration with some custom Apex logic to handle bi-directional syncing of ACW (After Call Work) time. Specifically, I have an Apex class that makes REST calls to the Genesys Platform API (/api/v2/conversations/...) to update wrap-up codes and fetch durations.

    To get this working, I set up a custom Named Credential and External Credential in Salesforce to handle the authentication for my Apex callouts.

    My Assumption & Question: I understand the Genesys Managed Package likely maintains two types of connections:

    1. Client-Side: The user session for the Softphone/CTI (User Context).

    2. Server-Side: A background connection used for syncing call logs/tasks to Salesforce (System/Integration Context).

    Is it possible to "reuse" one of those existing connection established by the Managed Package for those callouts to close the ACW?

    Or is the package's authentication strictly isolated in its namespace, requiring us to maintain this parallel Named Credential for our custom logic? Or could the users session be used for those callouts?

    I want to ensure I'm following best practices and not creating redundant connections if the managed package exposes a global method or token for this purpose.



    Context (Code Snippet):
    Here is a simplified version of the callout logic I am using:

    Java
    // Current approach: Uses a custom Named Credential 'GenesysCloudAPI'
    private static AgentContext getAgentContext(String conversationId) {
        HttpRequest req = new HttpRequest();
        // Is there a way to use the Managed Package auth instead of this custom named cred?
        req.setEndpoint('callout:GenesysCloudAPI/api/v2/conversations/' + conversationId);
        req.setMethod('GET');
        
        Http http = new Http();
        HttpResponse res = http.send(req);
        // ... processing logic
    }
    

    Any advice on the recommended architecture for extending the integration would be appreciated!

    Thanks


    #Integrations
    #PlatformAPI

    ------------------------------
    Mario Zoske
    n/a
    ------------------------------


  • 2.  RE: Genesys CX Cloud with Salesforce Voice - Reuse same credentials with managed package

    Posted 6 days ago

    Maybe to add to this: Instead of using the same credentials, maybe the user session can be adopted and used that already exists.



    ------------------------------
    Mario Zoske
    n/a
    ------------------------------



  • 3.  RE: Genesys CX Cloud with Salesforce Voice - Reuse same credentials with managed package

    Posted 3 days ago

    I believe you're on the right track, Mario, in using the Salesforce Named/External Credentials pattern for your custom logic. I'm not aware of any way to leverage the authentication from the CX Cloud components. Hopefully, in a future release, Genesys will add a lightweight Apex SDK to the CX Cloud managed package, similar to what they did with the legacy Genesys Cloud CTI Adapter - to allow ad‑hoc Platform API calls.



    ------------------------------
    Jason Schlotterback
    N/A
    ------------------------------



  • 4.  RE: Genesys CX Cloud with Salesforce Voice - Reuse same credentials with managed package

    Posted 3 days ago

    Hi Jason,

    Thanks for the confirmation! It is helpful to know that the Managed Package doesn't officially expose those credentials to Apex yet.

    I actually managed to solve this by pivoting from a server-side (Apex) approach to a client-side (LWC) approach using the Genesys Cloud JavaScript SDK and PKCE, which allowed me to achieve the "User Session Adoption" I was looking for.

    The Solution: Instead of setting up parallel Named Credentials for the server side, I built a Lightning Web Component that runs directly in the utility bar (or page).

    1. Genesys JS SDK: I loaded the GenesysCloudJsSdk as a static resource in Salesforce.

    2. PKCE Authentication: Instead of relying on Salesforce server-side auth, I implemented the PKCE (Proof Key for Code Exchange) flow directly within the LWC.

      • This allows the component to authenticate the user securely against the Genesys Platform API from the client side.

      • If the user is already logged into the standard Genesys softphone in the same browser, the SSO/Session cookies often allow this second PKCE handshake to happen silently or with minimal friction, effectively "syncing" the session.

    3. Direct API Calls: Once the SDK is initialized and authenticated via PKCE, I can make the necessary platform calls (like updating ACW or fetching Queue Stats) directly from the browser using the agent's context.

    The Result: This completely bypasses the need for complex per-user Named Credentials in Salesforce. The custom component manages its own secure connection using the standard SDK patterns, keeping everything within the user's context.

    The Downside: While this avoids managing complex credentials in Salesforce Setup, it does introduce a few client-side complexities:

    • Pop-up Management: The PKCE flow usually requires a pop-up window for the initial handshake. While often automatic, agents need to allow pop-ups for the Salesforce domain.

    • Dual Sessions: Technically, the LWC maintains its own session token separate from the Managed Package's softphone. If one expires or disconnects, the other might remain active, requiring careful state management in the JavaScript to keep the UI in sync.

    • Browser Security: You have to manage Cross-Origin Resource Sharing (CORS) and ensure your Salesforce domain is allow-listed in your Genesys Cloud OAuth client settings.

    Thanks again for the help!



    ------------------------------
    Mario Zoske
    n/a
    ------------------------------