Genesys Cloud CX

 View Only
Discussion Thread View
  • 1.  How match an string using Regular Expression into Script

    Posted 09-30-2022 22:40

    Hi Everyone,

    I'm working with a script and we have some problems to validate a value entered using 'Input script' element.
    Accordng documentation we could use Mathjs functions using dynamic variables, however I was unable to run the function i believe it works in order to match an string  using Regular Expressions.

    Mathjs function i believe it should works for me is math.filter.
    This function should works, according the documentation like this:

    math.filter(x, test)

    Where 'x' is the string entered into 'input element' and i want to evaluate and 'test' is the regular Expression i want apply to 'x' in order to validate.

    I tried anything but it didn't work.

    Could someone give me a tip, please?

    Thanks in advance.

    Regards 


    #ConversationalAI(Bots,AgentAssist,etc.)

    ------------------------------
    Josue Garcia
    Evolutio Cloud Enabler, S.A.
    ------------------------------


  • 2.  RE: How match an string using Regular Expression into Script

    Posted 10-06-2022 19:54
    I have experimented with the math.filter stuff, but I would suggest you use the Equal or IfElse found on this page:  Additional functions to use in dynamic variables - Genesys Cloud Resource Center (mypurecloud.com).  Many times, Genesys will support only a part of a standard like Markup and probably the MathJS stuff.  If you find something not working that should, consider opening a support ticket or submitting an Idea.

    ------------------------------
    Robert Wakefield-Carl
    Avtex Solutions, LLC
    Contact Center Innovation Architect
    https://www.Avtex.com
    https://RobertWC.Blogspot.com
    ------------------------------



  • 3.  RE: How match an string using Regular Expression into Script

    Posted 10-20-2022 18:36

    Hi Robert Wakefield-Carl,

    I checked with ifElse and the result is not the expected. What did you experiment with math.js filter? did you have good results?

    I opened this thread buecase I opened very days ago a ticket in order to get a solution of this, but they are not answer me for solution :(

    Regards



    ------------------------------
    Josue Garcia
    Evolutio Cloud Enabler, S.A.
    ------------------------------



  • 4.  RE: How match an string using Regular Expression into Script

    Top 25 Contributor
    Posted 10-20-2022 22:35
    Edited by Anton Vroon 10-20-2022 22:43
    Just to note the note on using mathjs functions in Script

    you drop the math prefix, so using math.add is just add, so to use the filter function is just filter(x, test)

    I haven't had much luck with it myself, it does requires an array or matrix, maybe with the list types introduced that is possible. And then passing a valid regular expression through I can see being problematic, maybe a separate dynamic variable with escaped characters where appropriate

    If it is an input, it might be easier to do that in the preceding flows, or pre-call rules, Do you have an example of what you are trying to filter? And what you tried with the ifElse Robert suggested.

    edit: If you are just trying to see if a value is in a list, you could just use indexOf(). If the value is anything but -1 then it exists, if it is -1 then its not present.


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



  • 5.  RE: How match an string using Regular Expression into Script

    Posted 10-22-2022 06:34

    Hi Anton Vroon,

    I used a matrix an arrays but it doesn't work.
    I addition I saw you said and I tried removing  math and without removing math word and it was not working.

    I can you and example, for example:

    I have a no dynamic variable called DNI. That variable is filled in using an input element into the script.

    After that i have a dynamic variable ( True / False ) to save this validation (  --> filter({{DNI}},^[0-9]{8}[A-Za-z]$|^[XYZxyz][0-9]{7}[A-Za-z]$) and it didn't work. I checked using other methods like filter("{{DNI}}",^[0-9]{8}[A-Za-z]$|^[XYZxyz][0-9]{7}[A-Za-z]$) or filter(["{{DNI}}"],^[0-9]{8}[A-Za-z]$|^[XYZxyz][0-9]{7}[A-Za-z]$) and it didn't work.

    Regards



    ------------------------------
    Josue Garcia
    Evolutio Cloud Enabler, S.A.
    ------------------------------