Is a DateDiff between two variables possible in an agent script?

Hello all,

Has anyone attempted a date diff in an agent script?

We are passing a date/time variable from architect into a screen pop/script and then setting the answer date/time in a script. Both of those seem to be working. What we hope to then do is a datediff between those two date/times variables to get a time difference in ms or seconds.

Has anyone tried something like this?

Thanks,
Shane

Hi Shane

I haven't tested myself but I believe its possible using the dynamic variables. You will need to first convert Dates to Milliseconds using dateToMilliseconds then find the difference and lastly convert to readable format using formatDuration

Hope this helps
Zubair

2 Likes

Thank you Zubair, this indeed seems to be working. REALLY appreciate the assist.

A follow-up that you or someone else may be able to assist with. I'm now simply trying to call a data action from within the script to set a custom attribute so that it can be stored as a Custom Attribute, I continue to get an 'unknown error occurred' when trying it. I've tried calling the data action from a button, on page load, etc and all fail with the dreaded unknown error.

In testing this Genesys Cloud set custom attribute action from Actions, it works perfectly fine.

Do you or anyone else have experience setting a custom attribute via data action from an agent script?

We are passing in {{Scripter.Interaction ID}} and {{Scripter.Customer Participant ID}} along with a string text for the attributeValue.

We are using the following in the Data Action configuration:

Request:
Patch
Request URL Template: /api/v2/conversations/${input.conversationId}/participants/${input.participantId}/attributes
Request Body Template:
{"attributes": {"AnsweredTime": "${input.attributeValue}"}}

Adding this detail as well, our JSON Response is configured as such: (was thinking maybe it has something to do w the Response).

{
"translationMap": {},
"translationMapDefaults": {},
"successTemplate": "${rawResult}"
}

Thanks again,
Shane

Not a problem, Shane.

There are two things I can think of around patch attribute failure via script.

  1. If you haven't already try passing the string with quotes i.e. "String"
  2. Check the Data Action Integration (oAuth) permissions

I hope this helps

Zubair

This topic was automatically closed 31 days after the last reply. New replies are no longer allowed.