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.
------------------------------
Original Message:
Sent: 03-23-2020 14:23
From: Melissa Bailey
Subject: DateTime Difference - PureCloud Data Action
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
Original Message:
Sent: 03-23-2020 13:39
From: Angel Rodriguez
Subject: DateTime Difference - PureCloud Data Action
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.
Original Message:
Sent: 08-02-2019 14:03
From: Melissa Bailey
Subject: DateTime Difference - PureCloud Data Action
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
Original Message:
Sent: 08-02-2019 06:22
From: Charaf Eddine Chemlal
Subject: DateTime Difference - PureCloud Data Action
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
#PureCloud QA Episode
------------------------------
Charaf Eddine Chemlal
Dimension Data France
------------------------------