job router classification policy powerfx expression not working as expected

Debajyoti Sarma 0 Reputation points
2025-08-06T18:43:08.09+00:00

We are following document https://learn.microsoft.com/en-us/azure/communication-services/how-tos/router-sdk/job-classification?pivots=programming-language-javascript to create job and route to various queue using classification policy.

using npm dependency "@azure-rest/communication-job-router": "1.1.0-beta.2" in our nodejs project.

Classification policy that we are using


{

    "id": "bjs_default_Routing-test-ACS2",

    "name": "Routing-test-ACS2",

    "fallbackQueueId": "default_ACS_Stage_4",

    "queueSelectorAttachments": [

      {

        "kind": "conditional",

        "condition": {

          "kind": "expression",

          "language": "powerFx",

          "expression": "job.skillsNeeded = \"default_acs_skill_3\""

        },

        "queueSelectors": [

          {

            "key": "Id",

            "labelOperator": "equal",

            "value": "default_ACS_Stage_3"

          }

        ]

      },

      {

        "kind": "conditional",

        "condition": {

          "kind": "expression",

          "language": "powerFx",

          "expression": "job.skillsNeeded = \"default_acs_skill_1\""

        },

        "queueSelectors": [

          {

            "key": "Id",

            "labelOperator": "equal",

            "value": "default_ACS_Stage_1"

          }

        ]

      }

    ],

    "workerSelectorAttachments": [

      {

        "kind": "static",

        "workerSelector": {

          "expedite": false,

          "status": "active",

          "key": "status",

          "labelOperator": "equal",

          "value": "available"

        }

      }

    ],

    "etag": "\"000092e5-0000-0700-0000-68935fd10000\""

  }

Job after submitting


{

    "id": "deba-test-19",

    "status": "queued",

    "enqueuedAt": "2025-08-06T14:32:42.2124525+00:00",

    "channelId": "voice",

    "classificationPolicyId": "bjs_default_Routing-test-ACS2",

    "queueId": "default_ACS_Stage_1",

    "priority": 1,

    "requestedWorkerSelectors": [

      {

        "expedite": false,

        "status": "active",

        "key": "default_acs_skill_4",

        "labelOperator": "greaterThan",

        "value": 1

      }

    ],

    "attachedWorkerSelectors": [

      {

        "expedite": false,

        "status": "active",

        "key": "status",

        "labelOperator": "equal",

        "value": "available"

      }

    ],

    "labels": {

      "callConnectionId": "58006580-a9f9-4c8c-a3e1-30142cbdc5d5",

      "serverCallId": "aHR0cHM6Ly9hcGkuZmxpZ2h0cHJveHkuc2t5cGUuY29tL2FwaS92Mi9jcC9jb252LXVzZWEyLTAyLXByb2QtYWtzLmNvbnYuc2t5cGUuY29tL2NvbnYvUHpYSmxWTjBLa09tWXVXZ2ZnUEhuUT9pPTEwLTYwLTEzNi0zJmU9NjM4ODk0MjMyMjg5MzM0NTE4",

      "correlationId": "90249802-4e34-4069-86f6-24de5bfba821",

      "fromNumber": "+12765660711",

      "toNumber": "+13097392188",

      "ivrContext": "{\"membername\":{\"value\":\"Daniel\",\"type\":\"PUBLIC\"},\"Intent\":{\"value\":\"Demo To Jeetu\",\"type\":\"PUBLIC\"},\"SREContact\":{\"value\":\"Sreekanth\",\"type\":\"PUBLIC\"},\"dueDate\":{\"value\":\"2022/07/28\",\"type\":\"PUBLIC\"},\"membershipid\":{\"value\":\"77777777\",\"type\":\"PUBLIC\"},\"ticketnumber\":{\"value\":\"9\",\"type\":\"PUBLIC\"},\"skillsNeeded\":{\"value\":[\"default_acs_skill_4\"],\"type\":\"PUBLIC\"},\"callFrom\":{\"value\":\"+12765660711\",\"type\":\"PUBLIC\"},\"callTo\":{\"value\":\"+13097392188\",\"type\":\"PUBLIC\"},\"clientName\":{\"value\":\"BJS\",\"type\":\"PUBLIC\"},\"accountId\":{\"value\":\"DEFAULT\",\"type\":\"PUBLIC\"},\"callStartTime\":{\"value\":\"20250806143219496425\",\"type\":\"PUBLIC\"},\"interaction-uuid\":{\"value\":\"deba-test-19\",\"type\":\"PUBLIC\"},\"interaction-timestamp\":{\"value\":\"20250806143219496425\",\"type\":\"PUBLIC\"}}",

      "skillsNeeded": "default_acs_skill_4"

    },

    "assignments": {},

    "tags": {},

    "notes": [],

    "matchingMode": {

      "kind": "queueAndMatch"

    },

    "etag": "\"00000002-0000-0000-ed8b-241af6d4dd08\""

  }

queue selector conditional powerfx expression should not have selected queueId default_ACS_Stage_1 because "skillsNeeded": "default_acs_skill_4" is not matching the expression.

We have observe intermittent working of classification policy when "skillsNeeded": "default_acs_skill_1" sometimes queue id default_ACS_Stage_1 got selected sometime some other queue got selected. Sometimes a queue got selected which is not part of the classification policy itself.

In our job submission code snippet is as following


const jobRequest = {

    channelId: 'voice',

    priority: 1,

    requestedWorkerSelectors: generatedRequestedWorkerSelectors,

    classificationPolicyId: 'bjs_default_Routing-test-ACS2',

    labels: {

      callConnectionId,

      serverCallId,

      correlationId,

      fromNumber: from?.phoneNumber?.value,

      toNumber: to?.phoneNumber?.value,

      ivrContext: JSON.stringify(tfsContext.ivrContext),

      skillsNeeded: tfsContext.ivrContext.skillsNeeded?.value[0],

    },

  };

  const response = await client.path('/routing/jobs/{jobId}', jobId).patch({

    body: jobRequest,

    contentType: 'application/merge-patch+json',

  });

Questions

  1. What is wrong with out code or classification policy?
  2. Is the azure document does not give correct example? which document to follow?
  3. We were trying more complex example with ParseJSON. How do we write powerfx expression to check if default_acs_skill_4 is present inside ivrContext strinfigied json's skillsNeeded value array?
  4. Is there a way to test the expression in playground https://microsoft.github.io/PowerApps-TestEngine/learning/playground/
Azure Communication Services
0 comments No comments
{count} votes

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.