Genesys Cloud - Developer Community!

 View Only

Sign Up

  • 1.  Data Action: Getting Agent Details to Update Salesforce (Multiple Agents Scenario)

    Posted 20 days ago

    I'm working on a workflow where I need to retrieve agent details, wrap-up code, and call duration using a Data Action. The goal is to update a Salesforce case when the agent disconnects the interaction.

    Currently, I'm using the following API endpoint:

    /api/v2/conversations/${input.conversationId}

    to collect the conversation details.

    Initially, I tried handling this in the workflow using a loop with the following condition:

    ToString(GetJsonObjectProperty(Flow.participants[State.participantLoopCount], "purpose")) == "agent"

    However, we're encountering errors when parsing the full JSON response. later, we filtered the output using JSONPath expressions like:

    "wrapupNotes": "$.participants[?(@.purpose == 'agent')].wrapup.notes",
    "UserId": "$.participants[?(@.purpose == 'agent')].userId",
    "wrapupCode": "$.participants[?(@.purpose == 'agent')].wrapup.code",
    "agentName": "$.participants[?(@.purpose == 'agent')].name",
    "startTime": "$.startTime",
    "attributes": "$.participants[0].attributes",
    "endTime": "$.endTime",
    "customerName": "$.participants[0].name",
    "queue": "$.participants[?(@.purpose == 'agent')].queueName",
    "direction": "$.participants[0].calls[0].direction",
    "wrapupName": "$.participants[?(@.purpose == 'agent')].wrapup.name"

    The challenge arises when multiple agents are involved in the same conversation. The API response returns multiple agent participants, so these fields come back as arrays. This makes it difficult to reliably extract the specific agent's wrap-up details and duration that we need for the Salesforce update.

    Is there a more specific API endpoint or recommended approach to retrieve agent-level details (including wrap-up code and duration) more efficiently in scenarios where multiple agents are part of the same conversation?

    Appreciate any guidance or best practices you can share. Thanks!


    #API/Integrations
    #ArchitectandDesign
    #Implementation

    ------------------------------
    Mohamed Shibil
    Contact Center Engineer
    ------------------------------


  • 2.  RE: Data Action: Getting Agent Details to Update Salesforce (Multiple Agents Scenario)

    Posted 20 days ago

    Hello Mohamed, 

    I am moving this to the developer community as this is more of a developer question since you are looking for advice to developing a work flow. 

    As for your API endpoint I believe you are using the correct one, I dont think we have anything more specific. But the developer community would know best. 

    Cheers, 



    ------------------------------
    Cameron
    Online Community Manager/Moderator
    ------------------------------



  • 3.  RE: Data Action: Getting Agent Details to Update Salesforce (Multiple Agents Scenario)

    Posted 14 days ago

    Mohamed, olá!

    Você está no caminho certo e o retorno como array é esperado!

    Para identificar a qual agente pertence cada WrapUp você deverá executar um loop no workflow e cada posição do indice vai indicar arelação de agente vs wrapup.



    ------------------------------
    Augusto Aranha
    Gerente de Desenvolvimento de Sistemas e Planejamento
    ------------------------------



  • 4.  RE: Data Action: Getting Agent Details to Update Salesforce (Multiple Agents Scenario)

    Posted 14 days ago
    Edited by Kaio Oliveira 14 days ago

    Olá Mohamed S

    I don't know if this will help you, but I'll explain what I do in a development project here at my company.
     
    I have an API whose response captured some data:

    response: 

    {
      "translationMap" : {
        "WrapupName" : "$.participants[?(@.purpose == 'agent' && @.wrapup.name=='Queda de chamada - Callback')].wrapup.name" ,
        "AgentName" : "$.participants[?(@.purpose=='agent' && @.wrapup.name=='Queda de chamada - Callback')].name" ,
        "AgentId" : "$.participants[?(@.purpose=='agent' && @.wrapup.name=='Queda de chamada - Callback')].userId"
      },
      "translationMapDefaults" : {},
      "successTemplate" : "{\"WrapupName\": ${WrapupName},\"AgentName\": ${AgentName},\"AgentId\": ${AgentId}}"
    }
    (In my scenario, I use an API in a workflow, but to create callbacks based on a specific wraup.)
    Since there can also be multiple agents in the interaction, in the workflow I send everything to the variables.
    In the API for creating the callback, I pass the variable I get the list of agent names (which was returned in the first API), I use Count in [] with "-1", and that way I guarantee that I will always get the last agent who answered the call.
    I hope this idea makes sense in your context.



    ------------------------------
    Kaio Oliveira
    GCP - GCQM - GCS - GCA - GCD - GCO - GPE & GPR - GCWM

    PS.: I apologize if there are any mistakes in my English; my primary language is Portuguese-Br.
    ------------------------------