Setting custom attribute data action in a script - Unknown error

Hello there,

We have a need to set a custom attribute via a data action from within an agent script. We have created a data action that seems to work well and actually does set the variable/value when testing from data action itself. When we attempt to call it from a script, we get an 'Unknown error'.

Has anyone ran across this before? We've tried calling the data action on page load, from a button press, and even hard code the data action. All seem to fail with the unknown error.

Below are some screenshots of our data action. Fingers crossed someone has ran into this before. We are probably missing something simple.

Thanks as always,
Shane

Data Actions execute under a Client Credentials grant OAuth client. That grant type doesn't have a user context, and the ability to update participant attributes requires a user context.

I'd suggest that you use the built-in Script Actions in Scripter: Available script actions - Genesys Cloud Resource Center. There is a "Set Variable" action and I'm pretty sure that updates the participant attributes for the agent participant. You'll need to create a variable: Add a script variable - Genesys Cloud Resource Center and the name of that variable should be the key name of the participant attribute. Then any value you set in the "Set Variable" should be saved.

Thanks Jim. Sorry for my delayed response. I originally went down the path of using the built-in Set Variable action and that did work. However, we only want the Answered Date set the first time a call is answered, so even if I set a condition to only set the Answered Date when a call isn't transferred, I think because I have the variable set as Output, it will ultimately overwrite my Answered Date for a transferred call with a blank date/time.

Scenario is:

  1. Call is routed to Queue 1 and answered by an agent. Our transferred variable set in Architect is False and thus a proper date/time is set using the Set Variable action. In this scenario, AnswereDate is set as an Output so it can get written as Participant data.

  2. If the call above gets transferred to Queue 2, our transferred flag in Architect gets set to true. In that case, I have a condition in the script that says do not write a new Answered Date. This condition is working, however I think because AnsweredDate is set as an Output, it then overwrites the proper date time from above with a blank entry.

If there is a way to avoid this, I'd prefer to use Set Variable vs. calling a data action.

Also, I was able to figure out the problem with the data action to set an attribute from a script. It was the Request Body Template. I had to adjust it to the below and now the script doesn't throw the unknown error any longer and it works. Was strange that testing the data action itself worked fine. Only when trying to call it from a script did the unknown error and request body template begin causing issues.

The request body template below allowed the script to call the data action successfully:
{"attributes": {"$esc.jsonString(${input.attributeName})": "$esc.jsonString(${input.attributeValue})"}}

Appreciate the response and if you happen to have any ideas on if set variable can work conditionally and not overwrite in the scenario described above, we'd much prefer to use that.

Thanks again,
Shane

I think I'd make Answered Date both an input and output variable. Then you can have an If/Then condition that check if Answered Date is not set, then set it. If it is already set then you leave it as is.

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