Pulling Skills that were used to Route from a conversation using ConversationID

Hello all, bear with me as I am a bit new to using the Genesys cloud data action schema.

I would like to pull the Skills that were assigned given the conversation ID but I am having trouble formulating the syntax. I am configuring in Admin/integration/Action to place under the configuration Request URL template.

I would like to output the skill(s) and the Language used with a single input value of conversationID (not the en-"" but the name of the skill AND language as we labeled it in the skills/language in Cloud Admin.

Finally, I would like to call this skill and input it into a list on my inbound call script. Any pointers on the syntax and steps to define the action/variable in the Script would be appreciated.

Hi @bholden,

To get the routing skills and language assigned to a specific conversation, you can make an API call to the following endpoint:

GET /api/v2/conversations/{conversationId}

The data action should take the conversationId as input and provide two outputs: language (a string representing the assigned language) and skills (an array containing all ACD skills associated with the conversation). Finally, you need to adjust the translationMap and success template as the following:

{
  "translationMap": {
    "Skills": "$.participants[?(@.purpose === 'acd')].conversationRoutingData.skills[*].id",
    "LanguageSkill": "$.participants[?(@.purpose === 'acd')].conversationRoutingData.language.id"
  },
  "translationMapDefaults": {
    "Skills": "[]",
    "LanguageSkill": "\"\""
  },
  "successTemplate": "{\"LanguageSkill\": ${successTemplateUtils.firstFromArray(\"${LanguageSkill}\")}, \"Skills\": ${Skills}}"
}

Example:
In this inbound call scenario, English is assigned as the language, and three ACD skills (VIP, CX, and Support) are assigned.

By calling the data action, below is the result:

The retrieved data includes the corresponding Ids for both language and skills, which will be replaced by their corresponding names shortly.

The next step is about displaying these names/labels to agents within the script component.

On the default script page, I created a custom action named "Fetch Skills & Language" and used it as a Page Load Action. This action invokes the data action with conversationId as input, returning the language and skills.

image

For language, obtaining the name is straightforward. I created another data action that takes a languageId as input and returns the language name by calling:

GET /api/v2/routing/languages/{languageId}

This task is completed within the "Get Language Name" custom action.

The challenge (at least for me) lies in retrieving skill names because the skills are stored as an array, and there's no built-in loop mechanism for iterating through them. To address this, I created a:

  • new custom action called "Get Skill Name".
  • skillList variable of type List of strings.
  • dimension variable of type dynamic number, to capture the size of the skills array using the size({{Skills}}) method.
  • Index variable of type number for the loop
  • Data action (Get Skill by Id) that accepts a skillId as input and returns the skill name by calling :
GET /api/v2/routing/skills/{skillId}

The process involves looping through each skillId, calling the data action (Get Skill by Id) on it.

As you can see, the action begins by comparing the index variable (initialized to 0) against the dimension variable. If the index is less than the dimension, the data action is called using the function getIndexValue({{Skills}}, {{index}}).

The result is temporarily stored and then added to the skillList variable by using the Push action.
image

The index is incremented, and the custom action is recursively called until all skills are processed.
image

Once all skills are handled, the loop ends.

In addtion, a Set Variable action (highlighted in blue) can be used to display skill names in a table using the markdown component if needed. This is an optional approach rather than using a dropdown.
image

Note:

  • If you are unable to see the List section in the actions menu, you need to activate it in the script settings.
    Go to Script properties and enable the List feature.

  • skillList needs to be used as a Variable within the dropdown component, not as a List.

The final result in the script:

Attached below is the data actions I used to assist in getting started :slight_smile:
Get-Skills--Language-by-conversationId-20230821185439.custom.json (1.5 KB)
Get-Skill-by-Id-20230821185450.custom.json (941 Bytes)
Get-language-by-Id-20230821185457.custom.json (953 Bytes)

I hope that helps and let me know if you have any additional questions or clarification.

Best regards,

Charaf

3 Likes

OMG thanks Charaf! very thorough. I ran Ran into an error testing 10. Apply output transformation:

{
"message": "Transform failed to process result using 'successTemplate' template due to error:'Unexpected character (',' (code 44)): expected a valid value (JSON String, Number, Array, Object or token 'null', 'true' or 'false')\n at [Source: (String)"{"LanguageSkill": , "Skills": [ "c538969d-4c39-44a1-9f89-0173ea71c3e2" ]}"; line: 1, column: 20]'\n Template:'{"LanguageSkill": ${successTemplateUtils.firstFromArray("${LanguageSkill}")}, "Skills": ${Skills}}'.",
"code": "bad.request",
"status": 400,
"messageParams": {},
"contextId": "7caabf2f-4fee-447b-a4f1-4e616a3a92c9",
"details": [
{
"errorCode": "ACTION.PROCESSING"
}
],
"errors": []
}

This Progress is exciting!!

Hi @bholden,

This issue occurs when a conversation has no language assigned. I apologize for not considering the default value when the language is undefined.

I updated the success template as follows:

 "successTemplate": "{\"LanguageSkill\": ${successTemplateUtils.firstFromArray(\"${LanguageSkill}\", \"$esc.quote$esc.quote\")}, \"Skills\": ${Skills}}"

Now, even if a conversation lacks language, the result will provide an empty string for the language and an empty array for skills, rathe than returning an error.

Could you please make a test using a conversation in which you have assigned skills or language?

Attached a new version of the updated data action:
Get-Skills--Language-by-conversationId-v2-20230821223607.custom.json (1.5 KB)

Thanks to this issue, I've come to realize that when a language is not assigned to a conversation, nothing will be displayed in the script. To address this, I implemented an initial check within the "Get Language Name" section. If the languageId is empty (indicating that the conversation lacks an assigned language), there's no need to expend an API call to retrieve the language name.

Let me know if that resolves the issue.

Best regards,

1 Like

Ahh I see. But I still want my Skill to pull even if the language skill isn't there.
Getting a little further but new error this time:

{
"message": "JSON failed output schema validation for the following reasons: Schema: # @/properties/LanguageSkill. Error location: /LanguageSkill. instance type (string) does not match any allowed primitive type (allowed: ["array"])",
"code": "invalid.schema",
"status": 400,
"messageParams": {},
"contextId": "0d2a79ea-6284-4ce2-a263-2c16b6cbd20f",
"details": [
{
"errorCode": "ACTION.PROCESSING"
}
],
"errors": []
}

To your suggestion, I will even though I will need to fix my flow to get the language assigned.
It's seems I have found another issue with my Script the language is not being assigned even though I am assigning it in my Inbound Call flow (Transfer to ACD action).

I believe you are currently defining the variable "LanguageSkill" as an array in the output contract of your data action. Please consider configuring it as a string instead.

Getting so much closer, This gave me a passing test but 2 blank outputs. However, In this test case I didn’t have a language which may happen at times even after I fix it, but this test case did have a skill so I did expect a blank in the language but not the skill output slot. .

currently I am still working to determine why my transfer to ACD action won’t and is not assigning a language as I set it but , then I will do what you asked to test a case where both conditions are met then with a pass I will proceed to step 2: to display the output on the script but ideally I will return the skill back if only it exist in the conversation and then the language only or both skill and language both exist..

Could you please ensure that you are configuring the ACD skills correctly in the Transfer to ACD block in Architect? Also, verify if the ACD skills are visible in the Queue Activity view.

image

Best Regards,

Charaf

Thanks Charaf,

I fixed the flow in Architect, I am now getting proper dual skill assignments and can see them in Queue Activity view now but when I run the test only the Language shows, even though I had both assigned and verified with both interactions and queue activity reports.

Could you please share with me the data action you are using by uploading it?

Charaf,

Sure Here ya go!

GetLanguageSkill-20230822103210.custom.json (1.4 KB)

Thank you @bholden,

I identified the problem :slight_smile:

In fact, there were 2 problems:

  1. Within your output contract, the "Skills" should be defined as an Array instead of a string.

  2. In the response template, the variable name used in the successTemplate must match the variable name declared in the output contract.

Could you plase rename "SKILL" to "Skills", define it as an array, and this should resolve your issue.

Best regards,

Charaf

Duh . . . Sorry again for my nubiness, after the suggested edits . . .

GetLanguageSkill-20230822115109.custom.json (1.7 KB)
I am getting a blank output box when testing but I can see the correct value in the JSON.

(upload://uE9XvGMKo5fKFcT1F9fhXUEQJyw.json) (1.7 KB)

After edit test result:

It displayed in white squares before the edit (just was missing the Value for skills.
Also on the skills array do i need to specify a slot to accomodate for the greatest number of skills that could be applied? or is that causing my problem in my response success outputs?

You don't need to specify any slots within the Skills array. Could you please remove all the slots you added and keep only one default Item1, as shown in the screenshot below:

that fixed it! Thank you Charaf! Now I am moving on to the call Script build & testing. I will respond if I run into trouble there.

Alright, embarrassingly I am stuck again, I am working thru getting the Language name.

For language, obtaining the name is straightforward. I created another data action that takes a languageId as input and returns the language name by calling:

GET /api/v2/routing/languages/{languageId}

I am assuming that getting confused with structuring the syntax on the sucess template of the response that will make the Name string display in the output box.

Here is my JSON -

SkillName-20230822152638.custom.json (953 Bytes)

Here is my test case output:

You can use the data actions that I attached in my initial post on this thread. Alternatively, you only need to modify the output variable name to name, specifying it as a string (rather than Language_Name).
For your response template, use the default template provided below:

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

Charaf,

Charaf that is Fixed,
thank you and my apologies you had already provided what I was trying to solve for and I missed it.

I am fully functional now.

Thank you SOO much for your detailed assistance. I think this will be a valuable thread to many out there in the dev community.

1 Like

I'm glad I could assist :slight_smile:
Feel free to mark it as solved

Did I do that right? Marking your first post as the solution?
I had all the content to solve at that point I just needed a bit more support. Thanks again for your insights and prompt support on this matter!