Genesys Cloud - Main

 View Only

Sign Up

  Thread closed by the administrator, not accepting new replies.
  • 1.  Split a message into two variables

    Posted 11-13-2023 05:54
    No replies, thread closed.

    Hey all, 

    We have deployed a post call survey via SMS, it writes the data back into a data table for us. 

    At the end of a call a SMS is sent out asking for a rating of 1 to 5, we are getting results back with some free text, example "5 thank you for your help"

    Is there a way that i can get the numeric value entered into a column into our data table and the free text in another?

    I looked at using Split(Message.Message.body, " ") but not sure how to add the free text into the second column. 

    thanks


    #ArchitectureandDesign


  • 2.  RE: Split a message into two variables

    Posted 11-13-2023 16:13
    No replies, thread closed.

    Hello Richard,

    If you know that it will always be the number first you could do something like

    Left(Message.Message.body, 1) to get the number and

    Trim(Right(Message.Message.body, Count(Message.Message.body) - 1)) to get the rest



    ------------------------------
    Jan Heinonen
    Contact Center Specialist
    GlobalConnect AB
    ------------------------------



  • 3.  RE: Split a message into two variables

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

    Are you able to be certain the message will always have the number first? What if someone answers "Great experience, I think you deserve a 5", or (possibly even worse) "I think a 5 is justified here"?



    ------------------------------
    Paul Simpson
    ------------------------------



  • 4.  RE: Split a message into two variables

    Posted 11-17-2023 01:23
    No replies, thread closed.

    There are a few ways to do this.  Here is what I would do...

    • Task.Transcript = "I give the agent 5 thank you for your help"
    • Update Data
      • New Collection
        • String
          • Variable name: Task.TranscriptArray
          • Value: [Expression] Split(Flow.Transcript, " ")
    • You can now parse thru each object of the array...
      • Example: 
        • Task.TranscriptArray[0]
          • Value: I
        • Task.TranscriptArray[1]
          • Value: give
        • Task.TranscriptArray[2]
          • Value: the
        • Task.TranscriptArray[3]
          • Value: agent
        • Task.TranscriptArray[4]
          • Value: 5
      • You can try and compile a Parse(Contains(Task.TranscriptArray, 0,1,2,3,4,5))
        • I'm not entirely sure if this works.  I know in PowerShell you can loop thru an array with a ForEach iteration.  There may be a way for you to set a bool in there of true or false.  

    I quickly threw together this sample inbound flow, where I used several steps to compile a method to loop thru each word using the baked in loop function and leveraging the Object[Int] position to reference each word in the array.  The loop counter and evaluation is very primitive, but does function by picking up an integer of AnyOneOfThese(0,1,2,3,4,5) from any position of the transcript array.  Go ahead and publish it in your sandbox and call it, let me know if that was something you were looking for. 

    I an unable to upload .yaml or .i3InboundFlow file types into this forum, so after you download them, revert the file extension to the respective type before you review or import. 



    ------------------------------
    Carlos Albor
    Senior Principal PS Consultant
    ------------------------------

    Attachment(s)



  • 5.  RE: Split a message into two variables

    Posted 11-17-2023 11:03
    No replies, thread closed.

    Jose, good solution!

    FYI, the documentation implies there is a "ForEach()" loop construct, but in fact there isn't. You have to get the length of the collection and then loop through it the hard way.

    There is an idea here to provide this functionality.

    HTH



    ------------------------------
    Paul Simpson
    ------------------------------



  • 6.  RE: Split a message into two variables

    Posted 11-17-2023 14:43
    No replies, thread closed.

    Thanks Paul.  I voted for the idea and added a comment to the idea.



    ------------------------------
    Carlos Albor
    Senior Principal PS Consultant
    ------------------------------