Genesys Cloud - Developer Community!

 View Only

Sign Up

  • 1.  Parse JSON for specific text string

    Posted 10-01-2025 15:24

    Hello, I am attempting to get SIP header information from calls being transferred back into our org to assist with call routing. My understanding is that the vendor is adding some context to the user-to-user field of the SIP header. So far in architect I have the get SIP header action. I've tried to convert the JSON to String, as well as using GetAt(JsonParse("\"user-to-user\""),1) but this only appears to grab the first character of the string that I need and not the entire string length. If anyone has any better ideas for how to get the info from the sip header, I'm open to other ideas!


    #Architect

    ------------------------------
    Tyler
    NA Bon Secours Mercy Health
    tmerk@mercy.com
    ------------------------------


  • 2.  RE: Parse JSON for specific text string

    Posted 10-01-2025 15:51

    Hi Tyler, there is a native Get UUI function available to Architect that predates the get SIP header action.  You'll get the content of that essentially as a string already that you can then put into a collection if it's delimited.  From there you can then use your GetAt functions to pull parts of it out, or just use a Left or substring function.



    ------------------------------
    Vaun McCarthy
    ------------------------------



  • 3.  RE: Parse JSON for specific text string

    Posted 10-02-2025 02:49
    Edited by Jerome Saint-Marc 10-02-2025 02:52

    Hello,

    As Vaun mentioned it, there is a possibility to retrieve the value sent as UUI in the Architect flow, without making use of the SIP headers.

    UUI Data is made available as an Architect built-in variable -> Call.UUIData

    This will work if the UUI header name and value are properly defined (header name, proper definition of the value with encoding ascii or hex, ...) - as shown here: UUI Data formats

    As you mention transfer back, the header to use depends on the type of transfer.

    If the call getting to your org is a new call (SIP INVITE) - i.e. the vendor "trombones" the call (they stay in the signalling path) - the User-to-User or x-User-To-User headers are the one to use to carry the value.

    If the vendor transfers back the call to your org, getting out of the signalling path (i.e. resources/call released on vendor side), this is to be done with a SIP REFER, and in this case the value is sent via the Refer-to header (Refer-To: <sip:address@ip?User-to-User=XXhexdata%3Bencoding%3Dhex>), as shown at the bottom of the UUI Data formats page.

    Call.UUIData Architect variable will automatically retrieve the value in case of INVITE or REFER.

    This is probably too much details :-)

    If your vendor has already done an integration with Genesys Cloud, then they are likely using the right header/method. And in this case, you do not need to worry about it and just use this Call.UUIData variable.

    The Call.UUIData is a string with the full UUI value. As you mention JSON, the vendor would have stringified it (to make it a normal string). You can then transform it back to a JSON object with the JsonParse function, and store it in a variable of JSON type (and then access the different properties you are interested in).

    Regards,



    ------------------------------
    Jerome Saint-Marc
    Senior Development Support Engineer
    ------------------------------



  • 4.  RE: Parse JSON for specific text string

    Posted 10-02-2025 09:17

    Jerome, thank you for all the additional context! I just looked at a recent interaction and it does not look like the call.UUI value is set. The vendor is attempting to send the call back via SIP REFER. Would this indicate that the vendor does not have the correct refer-to header set? 

    Thanks!



    ------------------------------
    Tyler Merk
    NA Bon Secours Mercy Health
    tmerk@mercy.com
    ------------------------------



  • 5.  RE: Parse JSON for specific text string

    Posted 10-02-2025 10:06

    Hello,

    It could indeed be that they are not sending UUI data in the Refer-to header (and they are using User-to-User instead). Unless that it is not an available option on their gateway/SBC, it is usually doable (to use Refer-to).

    Or if they do so (i.e. use of Refer-to), it could be that what they are sending as asciidata or hexdata is invalid, or that they haven't specified ;encoding=hex or ;encoding=ascii (always better to set this to make sure it will work).

    The best way would be to ask them.

    You can also check this yourself if you are familiar with SIP and reading pcap - the flow is not that complex - you would just have to look for the SIP REFER message. I used to use Wireshark application to open/view the pcap file. This will show the different SIP messages and their header. So you should be able to spot if they use User-To-User or Refer-To (that would contains something like this in its value: ?User-to-User=hexdata;encoding=hex).

    The PCAP file is available on the Interaction details (in Genesys UI) - see "SIP diagnostics" section at the bottom of this resource center page: https://help.mypurecloud.com/articles/view-an-interactions-details-tab/

    I believe that your user needs to have a set of permissions to see it (I mean to see the pcap and SIP traces files for download in Interaction Details) - see this resource center page: https://help.mypurecloud.com/articles/sip-diagnostics/

    As of the Architect Get SIP Headers action (https://help.mypurecloud.com/articles/get-sip-headers-action/), I am not sure it can capture headers from the SIP REFER. The page mentions SIP INVITE (the original call that reached your platform - before transferring it to this vendor). I must say I have never used it on a REFER (I mean recently). This was released after I stopped "playing" with UUI Data (but I did use the Refer-to approach at that time).

    Regards,



    ------------------------------
    Jerome Saint-Marc
    Senior Development Support Engineer
    ------------------------------



  • 6.  RE: Parse JSON for specific text string

    Posted 10-02-2025 13:25

    Jerome, I pulled the pcap and ran it through wire shark. It looks like they are sending it as a Refer-to, here is the snippet I found .Refer-To: <sip:Q_MH_Scheduling@XX.XXX.XX.XXX?User-to-User=00Header%3DAppointment%20scheduling%3Bencoding%3Dascii>



    ------------------------------
    Tyler Merk
    NA Bon Secours Mercy Health
    tmerk@mercy.com
    ------------------------------



  • 7.  RE: Parse JSON for specific text string

    Posted 10-02-2025 14:24
    Edited by Jerome Saint-Marc 10-03-2025 00:57

    I don't know for sure but the doubt I have are:

    • if the = (%3D) in the value could be an issue when/if ascii is used. Do you have a way to try a different value for UUI data - something without space and equal characters (just to verify if that can be due to this or not)?

    And questions:

    • is the transfer done to an ACD Queue (just an assumption given the Q_MH_Scheduling as transfer target)?
    • And if so, are you trying to extract the UUI Data from an Architect In-Queue flow or from an another flow (I mean where the call would be transferred from the In-Queue flow)?

    I had tried with hex encoding, and transferring to a number/DID with an Architect Inbound flow loaded on it.

    I don't have ways to test this nowadays. I mean I don't have an available SIP Trunk to a target that can manipulate the Refer to try different variations. I'll see if I can figure out something (probably not tomorrow).

    Another question regarding this vendor. Is this the first time they integrate with Genesys Cloud or do they have other integrations in place apart from yours (like if they are an AppFoundry partner)? This is just to help on troubleshooting to focus on one part or another (i.e. if it is not their first integration, it'd mean that they have used encoding=ascii somewhere else and I don't need to dig on that side).

    I'll disconnect for today (I am based in France/Paris) :-)

    ------------------------------
    Jerome Saint-Marc
    Senior Development Support Engineer
    ------------------------------



  • 8.  RE: Parse JSON for specific text string

    Posted 10-07-2025 11:39

    Hey Tyler,

    Interesting case - I've worked on something similar where the vendor used REFER-based UUI propagation, and we ran into the same limitation when trying to extract the data through the Get SIP Header action in Architect.

    In these cases, the UUI value doesn't always survive the transfer context as a readable header, especially if the call is re-INVITED or REFERed outside the initial signaling path. Architect may only expose part of it, which explains why you're seeing the first character or truncated content.

    A practical approach that worked for us was:

    • First, check if the Call.UUIData variable populates automatically - when it does, it's the cleanest option to parse or pass through flows.

    • If not, capture the raw SIP header using the Get SIP Header action, store it in a participant data attribute, and then parse it via a Function Data Action (Lambda). That way, you can sanitize and decode the header (replacing %3D, %20, etc.) before converting it back with JsonParse().

    This keeps the parsing logic out of Architect expressions and makes it reusable for future integrations or different carriers that format headers differently.

    Hope that helps clarify the behavior and gives you another integration path to test. Would be great to hear if the REFER headers decode properly once you clean them before parsing.

    -
    Bruno Costa dos Santos
    Tech Lead @ NIBI



    ------------------------------
    Bruno Costa dos Santos
    ------------------------------