Genesys Cloud - Developer Community!

 View Only

Sign Up

  • 1.  Architect ability to parse topics array from the v2.speechandtextanalytics.conversation.{id}.topics

    Posted 5 days ago
    Edited by Shane Jenkins 5 days ago

    Hi all,

    I've browsed the forum and seen several threads over the last few years on this, but I am struggling.

    I have a trigger created using the topic name of v2.speechandtextanalytics.conversation.{id}.topics and my goal is to trigger based upon certain STA topics being detected. This trigger and it's associated workflow are both working great. 

    What I want to do is extract the topics array from the JSON object and specifically the topicName in Architect using an expression. I can get the topics array and store it as either a JSON collection or a String Collection to carve out just the topics. 

    Question: Is it possible to then parse out each unique topicName (i.e. Greeting, Closing, Escalate to Supervisor, etc) from this topics array (or JSON collection / string collection)? 

    Any ideas or has anyone succeeded in something similar? As you know the topics array here could contain 1 value or 2, 3, 4 etc. depending on how many STA topics were detected. 

    I would like to be able to extract each unique topic name so that we can display them in a nicely formed email to a supervisor later on in the workflow.

    Here is the event schema for STA Topics:

    {
      "conversationId": "string",
      "communicationId": "string",
      "recordingId": "string",
      "transcriptId": "string",
      "mediaType": "string",
      "programId": "string",
      "topics": [
        {
          "participant": "string",
          "topicId": "string",
          "topicName": "string"
        }
      ],
      "participants": [
        {
          "userId": "string",
          "queueId": "string",
          "divisionId": "string",
          "purpose": "string",
          "flowId": "string"
        }
      ]
    }

    Thanks as always,


    #Architect
    #DataActions
    #Triggers

    ------------------------------
    Shane Jenkins

    ------------------------------



  • 2.  RE: Architect ability to parse topics array from the v2.speechandtextanalytics.conversation.{id}.topics

    Posted 5 days ago

    Hi Shane,

    We implemented something similar where we needed to process the STA topics array dynamically within a workflow.

    What worked well for us was looping through the topics array using Count(State.topics), and then using GetAt(State.topics, State.loopIndex) to access each topic object. From there, we extract the topicName (and participant where needed) for each iteration.

    Inside the loop, we either:

    • Set flags based on specific topic names for decision logic, or

    • Build a string/collection if we want to include all detected topics in a notification

    This approach handles any number of topics (1, 2, 3, etc.) since each item is processed individually within the loop.

    Hope this helps.



    ------------------------------
    Phaneendra
    Technical Solutions Consultant
    ------------------------------



  • 3.  RE: Architect ability to parse topics array from the v2.speechandtextanalytics.conversation.{id}.topics

    Posted 4 days ago

    Thanks Phaneendra! 

    I have been trying to accomplish the above and seem to be banging my head against the wall. I hate to ask, but can you possible shed any more light or color on how you setup your loop and extracted the STA topicNames?

    The trigger I have is passing in the initial data as Flow.jsonData, so I'm using JSON as the initial input to the workflow. I've successfully used Update Data and pulled out the topics array as a JSON collection. That JSON collection is named Flow.STA_TopicsArray from there, I cannot seem to determine how to properly count / extract the topics array and each topicName.

    I've tried various methods / combinations using JsonParse and GetJsonObjectProperty. I just can't quite get the syntax right. I'll keep trying (I am obviously not a fulltime developer 😀, but I try to knock out what I can as I can)

    Any additional guidance or suggestions are appreciated. If I get it working, I'll report back to this thread.

    Thanks again!



    ------------------------------
    Shane Jenkins
    IT Sys Admin Mgr
    ------------------------------



  • 4.  RE: Architect ability to parse topics array from the v2.speechandtextanalytics.conversation.{id}.topics

    Posted 4 days ago

    Ok, I do have this mostly working now!

    I believe I have one more challenge that I need help with.

    My challenge now is that I want to extract the userId and queueId from the participants array which as you know has a purpose of "agent".

    Any suggestions on the proper expression to get both of these values? Do I have to iterate through each participant or since I know it will always be in the participant of an "agent", can I more simply target it specifically?

    Below is how I accomplished my goal of extracting the topicName for each STA topic: There may be a more elegant way, but this seems to work and maybe it'll help others.

    1. Configured a loop using a Flow.TopicIndex with an initial value of 0 (The Current Index Data Name set to Flow.TopicIndex and the Maximum Loop Count to the variable below Flow.TopicCount)
    2. Setting an integer value named Flow.TopicCount and then expression of count(Flow.jsonData.topics) to count how many total topics we have 
    3. Inside the loop used the following Update Date - tostring(Flow.jsonData.topics[Flow.TopicIndex].topicName) -- as the loop iterates it then grabs each topicName
    4. Next inside the loop, I created a String variable named Flow.TopicNameList and used an Update Data step with the following expression:
      If(
      IsNotSetOrEmpty(Flow.TopicNameList),
      Flow.TopicName,
      Flow.TopicNameList + ", " + Flow.TopicName
      ) -- This expression creates a comma separated string with each TopicName as the loop iterates --

    If I resolve the issue with the path to get the userId and/or queueId, I'll update or edit this posting.

    Thanks all,



    ------------------------------
    Shane Jenkins
    IT Sys Admin Mgr
    ------------------------------



  • 5.  RE: Architect ability to parse topics array from the v2.speechandtextanalytics.conversation.{id}.topics
    Best Answer

    Posted 4 days ago
    Edited by Shane Jenkins 4 days ago

    Hi Shane,

    That’s a solid approach and very similar to what we ended up doing as well. Your loop and topicName extraction logic looks spot on 👍

    For the participants array, you’ll want to iterate through it just like you did with topics. Even if you expect only one agent, Architect doesn’t guarantee position, so it’s safer to loop and filter.

    What worked for us was:

    • Create a loop using:
      count(Flow.jsonData.participants)
    • Inside the loop, access each participant using:
      Flow.jsonData.participants[Flow.ParticipantIndex]
    • Then check for the agent using:
      Flow.jsonData.participants[Flow.ParticipantIndex].purpose == “agent”

    On the matching record, you can extract the values using:

    • userId:
      tostring(Flow.jsonData.participants[Flow.ParticipantIndex].userId)
    • queueId:
      tostring(Flow.jsonData.participants[Flow.ParticipantIndex].queueId)

    From there, we enriched the data as follows:

    • Agent name → using a Data Action (e.g. Get User by ID via userId)
    • Queue name → using an Architect expression to resolve queueId

    Even if there’s typically one agent, I’d still recommend looping rather than assuming index [0], as the order isn’t guaranteed.

    You’re definitely on the right track here.



  • 6.  RE: Architect ability to parse topics array from the v2.speechandtextanalytics.conversation.{id}.topics

    Posted 4 days ago

    For the queueId specifically, we extracted it directly inside the participants loop using:

    tostring(Flow.jsonData.participants[Flow.ParticipantIndex].queueId)

    On the same condition where purpose == "agent", we stored that value in a variable and then used it outside the loop to resolve the queue name.



    ------------------------------
    Phaneendra
    Technical Solutions Consultant
    ------------------------------



  • 7.  RE: Architect ability to parse topics array from the v2.speechandtextanalytics.conversation.{id}.topics

    Posted 4 days ago

    Thanks again Phaneendra!

    I managed to get this working and as you said above, followed nearly the same logic with participants as I did with the topicNames. When purpose == "agent" then added logic to get the queueId and userId. Then used the FindQueueById and FindUserById expressions to get the friendly names once we had the IDs. I think I'm in great shape now. 

    Thanks again! 



    ------------------------------
    Shane Jenkins
    IT Sys Admin Mgr
    ------------------------------