Nicholas_Simmonds | 2023-12-13 14:34:54 UTC | #1
Hi all,
I'm new to custom data actions and need a little help on the Architect side in terms of defining a decision Expression that filters correctly on the data action output. In this case the output is an array with an agent id(s) depending on how many agents are available.
My data action query is: /api/v2/routing/queues/${input.QueueId}/members?languages=${input.LanguageSkill}&routingStatus=${input.RoutingStatus}
With inputs of of queue id, language skill and routing status of idle in this case.
The JSON output is:
{ "type": "object", "properties": { "AgentId": { "type": "array", "items": { "title": "Item 1", "type": "string" } } }, "additionalProperties": true }
My translation map response is: { "translationMap": { "Filter1": "$.entities[*].id" }, "translationMapDefaults": {}, "successTemplate": "{\r\n\"AgentId\":${Filter1}}" }
I need to find an expression that provides a YES or NO to the presence of entries in the Output AgentID array.
I've tried the following plus many others to obtain a Yes if there are no entries in the array but i'm yet to hit the correct filter.
IsSet(true) IsSet("") IsSet("Null")
Any help or ideas on this one would be really helpful.
Cheers.
Jerome.Saint-Marc | 2023-12-13 15:46:01 UTC | #2
Hello,
A first comment. I would recommend to escape the LanguageSkill parameter at least (if your language could contain characters that need url escaping). Something like:
{
"requestUrlTemplate": "/api/v2/routing/queues/${input.QueueId}/members?languages=$esc.url($input.LanguageSkill)&routingStatus=$esc.url($input.RoutingStatus)",
"requestType": "GET",
"headers": {
"Content-Type": "application/json"
},
"requestTemplate": "${input.rawRequest}"
}
Regarding your question, you should be able to use the IsNotSetOrEmpty() function in an architect expression. Assuming you have stored your Data Action AgentId output parameter (array of strings) in an architect variable - e.g. State.myAgentIds You would then test IsNotSetOrEmpty(State.myAgentIds) - if it is equals to true, the array contains no entries (is Not set or empty). If false, it contains entries.
Regards,
Nicholas_Simmonds | 2023-12-13 16:08:54 UTC | #3
Perfect this works. I can see the what i was doing wrong now. Previously i thought the decision was already aware of the value of the outcome from the success of the data action. Noted on the $esc usage also for the languages and routing status.
Thanks for your help with this.
system | 2024-01-12 16:09:17 UTC | #4
This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
This post was migrated from the old Developer Forum.
ref: 23683