Genesys Cloud - Main

 View Only

Discussion Thread View
  • 1.  DateTime Difference - PureCloud Data Action

    Posted 08-02-2019 06:22
    Edited by Matt Lawson 08-06-2019 08:52
    Hello,

    I would like to know if it would be possible to use PureCloud Data Actions in order to calculate the difference between two DateTime and return values as a Duration ?

    There is a built-in funciton in Architect to do so (DateTimeDiff).

    Regards,


    #Implementation

    ------------------------------
    Charaf Eddine Chemlal
    Dimension Data France
    ------------------------------


  • 2.  RE: DateTime Difference - PureCloud Data Action

    GENESYS
    Posted 08-02-2019 14:03
    No.  The PureCloud Data actions hit the PureCloud api (see https://developer.mypurecloud.com/developer-tools/#/api-explorer for the available endpoints).  There isn't an endpoint to do date calculations.  The DateTimeDiff function in architect is executed by the engine executing the flow.  None of the architect functions are available in the api.

    ------------------------------
    Melissa Bailey
    Genesys - Employees
    ------------------------------



  • 3.  RE: DateTime Difference - PureCloud Data Action

    Posted 08-02-2019 14:12

    I needed to subtract two dates from the script by calling a PureCloud Data Action.

    But I managed to develop this using the built-in functions of the scripts and it works just fine :)

    Thank you again 



    ------------------------------
    Charaf Eddine Chemlal
    Dimension Data France
    ------------------------------



  • 4.  RE: DateTime Difference - PureCloud Data Action

    Posted 03-23-2020 13:39
    Edited by Angel Rodriguez 03-23-2020 13:40

    Hi there,

    We have a need for the customer to be able to enter their date of birth, and route to a specific flow if they're over 21 years of age. Is it possible that the IVR can collect the date the customer provided or calculate / compare against a range of time?

    For example: IF    DATE ENTERED < (DATE ENTERED - 7665)     THEN route to A;  ELSE route to B. 7665 being the date 21 years prior.

    Also, how would that look in Architect? It would be greatly appreciated if someone could assist, or provide best practice for this circumstance.



    ------------------------------
    Angel R.
    ------------------------------



  • 5.  RE: DateTime Difference - PureCloud Data Action
    Best Answer

    GENESYS
    Posted 03-23-2020 14:23
      |   view attached

    Use a collect input action to get their birthday.  Transform that into a date time variable and check to see if it's old enough.  In this example, the collect input action collects exactly 8 digits (2 digit month, 2 digit day, 4 digit year).  The update data action splits those up into variables for each, then constructs a datetime variable.

    The expression for Task.month is ToInt(SubString(Task.digits, 0, 2))
    Task.day is ToInt(SubString(Task.digits, 2, 2))
    Task.year is ToInt(SubString(Task.digits, 4, 4))
    Task.birthday is MakeDateTime(Task.year, Task.month, Task.day)

    The expression for the decision action is AddYears(Task.birthday, 21) < GetCurrentDateTimeUtc().  I'm checking to see if their 21st birthday is before right now.  The calculation is inclusive, if today is exactly their 21st birthday the expression evaluates to true.

    7665 = 365 * 21, but it's not actually the number of days in 21 years; you forgot about leap years.



    ------------------------------
    Melissa Bailey
    Genesys - Employees
    ------------------------------



  • 6.  RE: DateTime Difference - PureCloud Data Action

    Posted 03-24-2020 14:27
    Hi Melissa,

    Thanks so much for your help. I was trying so many different methods, and my eyes were already blurry from scouring the articles pages for anything remotely close to this. Your explanation and screenshot was perfect!

    One quick follow-up, is there standard practice for confirming that the date entered is legit? I have seen this done in different ways now, but I'm wondering what's best. Originally, I built it to request for the information in three parts:

    For example:
    Collect Input [task.month] - "Please enter the 2-digit month"
    Collect Input [task.day] - "Now, please enter the 2-digit day"
    Collect Input [task.year] - "finally, please enter the 4-digit year"

    At each, I asked Architect to calculate if the number was within a specific range.

    For example:
    Task.month<="12"
    Task.day<="31"
    For Task.year, I was thinking of just confirming whether it's between 10 and 100 years, or just under 100 (not exactly sure of the range yet)

    This allows us to confirm that they are entering valid date ranges At the end, I had it read back the full date back to the caller (by the way, the orange section of the expression was the only way I could figure out how to read back the year in a decent format without saying: one thousand nine hundred and eighty four):

    Append(Toaudiotts(ToString(Task.month)),Toaudiotts(ToString(Task.day)),Toaudiotts(ToString(left(Task.year,2))),Toaudiotts(ToString(right(Task.year,2))))


    With your suggested build, if the caller enters a bogus date range, it plays the default error message and moves forward in the IVR. How do you suggest incorporating a method of verification into your build?



    ------------------------------
    Angel R.
    ------------------------------



  • 7.  RE: DateTime Difference - PureCloud Data Action

    GENESYS
    Posted 03-24-2020 16:53
    MakeDateTime will fail if the month, day, or year is not within an acceptable range.

    Invalid values will send the caller into error handling.  If you don't want that (for example if you want to ask them again), you need to verify the month, day, & year are within the necessary ranges before you use MakeDateTime.  Also MakeDateTime will not error if you enter MakeDateTime(2020, 2, 31) even though February 31st is not a real date; if you want to do even more validation like checking to see if 29, 30, or 31 is valid day for a particular month, that's up to you.

    You need to insert the appropriate actions (I'm guessing Transfer to ACD) in the Yes & No output paths of the decision action. 


    https://help.mypurecloud.com/articles/set-default-error-handling-behavior/
    https://help.mypurecloud.com/articles/access-functions-help/


    ------------------------------
    Melissa Bailey
    Genesys - Employees
    ------------------------------



Need Help finding something?

Check out the Genesys Knowledge Network - your all-in-one access point for Genesys resources