Genesys Cloud - Main

 View Only

Sign Up

  Thread closed by the administrator, not accepting new replies.
  • 1.  dataaction failure

    Posted 12-06-2023 11:07
    No replies, thread closed.

    Hello everyone,

    I am currently using a data action to count the number of calls on a DID in order to calculate a ratio for triggering a recording.

    _____

    /api/v2/analytics/conversations/details/query 

    {
      "interval": "${input.Interval}",
      "paging": {
        "pageSize": 25,
        "pageNumber": 1
      },
      "segmentFilters": [
        {
          "type": "or",
          "predicates": [
            {
              "type": "dimension",
              "dimension": "dnis",
              "operator": "matches",
              "value": "${input.DNI}"
            }
          ]
        }
      ]
    }

    ______

    During unit testing, there is no issue, but things get complicated when I move to production.

    At the end of the day, the response returns more than 80,000 lines, whereas I only need the "totalhits." Due to the long execution time, the calls fail when invoking the data action in a flow.

    How can I optimize the response to get only the total hits or the minimum information?

    The interval is calculated like this: append(ToString(MakeDateTime(year(GetCurrentDateTimeUtc()), month(GetCurrentDateTimeUtc()), day(GetCurrentDateTimeUtc()), 00, 00, 00)),"/",ToString(MakeDateTime(year(GetCurrentDateTimeUtc()), month(GetCurrentDateTimeUtc()), day(GetCurrentDateTimeUtc()), 23, 59, 59)))

    If I can't optimize the response (even with a pagesize: 1, it remains too long), how can I retrieve the last quarter-hour within the interval? For example, at 10:10:00, I would need the interval 09:45:00-10:00:00.

    Thank you for your assistance.


    #ArchitectureandDesign
    #Integrations
    #Routing(ACD/IVR)
    #Telephony

    ------------------------------
    Arnaud
    ------------------------------


  • 2.  RE: dataaction failure

    Posted 12-06-2023 19:35
    No replies, thread closed.

    Hi Arnaud,

    Depending on your need, then instead of using the details query, use the aggregates query

    POST /api/v2/analytics/conversations/aggregates/query

    {
      "filter": {
        "type": "and",
        "clauses": [
          {
            "type": "or",
            "predicates": [
              {
                "dimension": "dnis",
                "value": "${input.DNI}"
              }
            ]
          }
        ]
      },
      "metrics": [
        "nConnected"
      ],
      "interval": "${input.Interval}"
    }

    The result should then look something like this:

    And your success template is going to be looking for something like $.results[0].data[0].metrics[0].stats.count

    {
      "results": [
        {
          "group": {
            "mediaType": "voice"
          },
          "data": [
            {
              "interval": "2023-12-06T11:00:00.000Z/2023-12-07T00:00:00.000Z",
              "metrics": [
                {
                  "metric": "nConnected",
                  "stats": {
                    "count": 8
                  }
                }
              ]
            }
          ]
        }
      ]
    }


    ------------------------------
    Anton Vroon
    ------------------------------



  • 3.  RE: dataaction failure

    Posted 12-07-2023 04:07
    Edited by Gurwan Duplenne 12-07-2023 04:09
    No replies, thread closed.

    Hello Arnaud, 

    The error you mentioned is not due to the long execution time, but this is the huge data that is returned back by the API and so triggers an error memory.

    From that being said, when you just need partial data, you don't need to return the full json like : 

    {
      "translationMap": {},
      "translationMapDefaults": {},
      "successTemplate": "${rawResult}"
    }

    But you would prefer to update your success template as Anton said something like : 

    {
      "translationMap": {
        "totalHits": "$.totalHits"
      },
      "translationMapDefaults": {},
      "successTemplate": "{\"totalHits\": ${totalHits}}"
    }

    I attached your data action updated (https://contentmanagement.mypurecloud.com/document-viewer/#/1/rijzmkow5vhz5dl3yf2akl6aoe),

    let us know.



    ------------------------------
    Gurwan Duplenne
    Genesys - Employees
    ------------------------------



  • 4.  RE: dataaction failure

    Posted 12-15-2023 11:40
    No replies, thread closed.

    as you sugested, problem solve with response : 

    {
      "translationMap": {
        "totalHits2": "$.totalHits"
      },
      "translationMapDefaults": {},
      "successTemplate": "{\"totalHits\": ${totalHits2}}"

    thank you !



    ------------------------------
    Arnaud
    ------------------------------