Skip to content

Commit 235dfad

Browse files
authored
Merge pull request #229153 from cparisineti/main
Update public docs with latest sdk changes
2 parents 4a1c13f + 9d57502 commit 235dfad

File tree

12 files changed

+305
-256
lines changed

12 files changed

+305
-256
lines changed

articles/communication-services/concepts/router/exception-policy.md

Lines changed: 37 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -44,19 +44,23 @@ In the following example, we configure an Exception Policy that will cancel a jo
4444
::: zone pivot="programming-language-csharp"
4545

4646
```csharp
47-
await client.SetExceptionPolicyAsync(
48-
id: "policy-1",
49-
name: "My Exception Policy",
50-
rules: new List<ExceptionRule>
51-
{
52-
new ExceptionRule(
53-
id: "rule-1",
54-
trigger: new QueueLengthExceptionTrigger(threshold: 100),
55-
actions: new List<ExceptionAction>
47+
await routerClient.CreateExceptionPolicyAsync(
48+
new CreateExceptionPolicyOptions(
49+
exceptionPolicyId: "policy-1",
50+
exceptionRules: new List<ExceptionRule>
5651
{
57-
new CancelExceptionAction("cancel-action")
52+
new ExceptionRule(
53+
id: "rule-1",
54+
trigger: new QueueLengthExceptionTrigger(threshold: 100),
55+
actions: new List<ExceptionAction>
56+
{
57+
new CancelExceptionAction("cancel-action")
58+
})
5859
})
59-
});
60+
{
61+
Name = "My exception policy"
62+
}
63+
);
6064
```
6165

6266
::: zone-end
@@ -89,26 +93,30 @@ In the following example, we configure an Exception Policy with rules that will:
8993
::: zone pivot="programming-language-csharp"
9094

9195
```csharp
92-
await client.SetExceptionPolicyAsync(
93-
id: "policy-1",
94-
name: "My Exception Policy",
95-
rules: new List<ExceptionRule>
96-
{
97-
new ExceptionRule(
98-
id: "rule-1",
99-
trigger: new WaitTimeExceptionTrigger(TimeSpan.FromMinutes(1)),
100-
actions: new List<ExceptionAction>
101-
{
102-
new ManualReclassifyExceptionAction(id: "action1", priority: 10)
103-
}),
104-
new ExceptionRule(
105-
id: "rule-2",
106-
trigger: new WaitTimeExceptionTrigger(TimeSpan.FromMinutes(5)),
107-
actions: new List<ExceptionAction>
96+
await routerClient.CreateExceptionPolicyAsync(
97+
new CreateExceptionPolicyOptions(
98+
exceptionPolicyId: "policy-1",
99+
exceptionRules: new List<ExceptionRule>
108100
{
109-
new ManualReclassifyExceptionAction(id: "action2", queueId: "queue-2")
101+
new ExceptionRule(
102+
id: "rule-1",
103+
trigger: new WaitTimeExceptionTrigger(TimeSpan.FromMinutes(1)),
104+
actions: new List<ExceptionAction>
105+
{
106+
new ManualReclassifyExceptionAction(id: "action1", priority: 10)
107+
}),
108+
new ExceptionRule(
109+
id: "rule-2",
110+
trigger: new WaitTimeExceptionTrigger(TimeSpan.FromMinutes(5)),
111+
actions: new List<ExceptionAction>
112+
{
113+
new ManualReclassifyExceptionAction(id: "action2", queueId: "queue-2")
114+
})
110115
})
111-
});
116+
{
117+
Name = "My Exception Policy"
118+
}
119+
);
112120
```
113121

114122
::: zone-end

articles/communication-services/concepts/router/matching-concepts.md

Lines changed: 21 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -33,21 +33,28 @@ In the following example we register a worker to
3333
::: zone pivot="programming-language-csharp"
3434

3535
```csharp
36-
var worker = await client.RegisterWorkerAsync(
37-
id: "worker-1",
38-
queueIds: new[] { "queue-1", "queue-2" },
39-
totalCapacity: 2,
40-
channelConfigurations: new List<ChannelConfiguration>
41-
{
42-
new ChannelConfiguration(channelId: "voice", capacityCostPerJob: 2),
43-
new ChannelConfiguration(channelId: "chat", capacityCostPerJob: 1)
44-
},
45-
labels: new LabelCollection()
36+
var worker = await client.CreateWorkerAsync(
37+
new CreateWorkerOptions(
38+
workerId: "worker-1",
39+
totalCapacity: 2)
4640
{
47-
["Skill"] = 11,
48-
["English"] = true,
49-
["French"] = false,
50-
["Vendor"] = "Acme"
41+
QueueIds = new Dictionary<string, QueueAssignment>()
42+
{
43+
["queue-1"] = new QueueAssignment(),
44+
["queue-2"] = new QueueAssignment()
45+
},
46+
ChannelConfigurations = new Dictionary<string, ChannelConfiguration>()
47+
{
48+
["voice"] = new ChannelConfiguration(2),
49+
["chat"] = new ChannelConfiguration(1)
50+
},
51+
Labels = new Dictionary<string, LabelValue>()
52+
{
53+
["Skill"] = new LabelValue(11),
54+
["English"] = new LabelValue(true),
55+
["French"] = new LabelValue(false),
56+
["Vendor"] = new LabelValue("Acme")
57+
},
5158
}
5259
);
5360
```

articles/communication-services/concepts/router/router-rule-concepts.md

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,11 @@ In this example a `StaticRule`, which is a subtype of `RouterRule` can be used t
4242
::: zone pivot="programming-language-csharp"
4343

4444
```csharp
45-
await client.SetClassificationPolicyAsync(
46-
id: "my-policy-id",
47-
prioritizationRule: new StaticRule(5)
48-
);
45+
await routerAdministration.CreateClassificationPolicyAsync(
46+
new CreateClassificationPolicyOptions(classificationPolicyId: "my-policy-id")
47+
{
48+
PrioritizationRule = new StaticRule(new LabelValue(5))
49+
});
4950
```
5051

5152
::: zone-end
@@ -71,10 +72,11 @@ In this example a `ExpressionRule`, which is a subtype of `RouterRule` can be us
7172
::: zone pivot="programming-language-csharp"
7273

7374
```csharp
74-
await client.SetClassificationPolicyAsync(
75-
id: "my-policy-id",
76-
prioritizationRule: new ExpressionRule("If(job.Urgent = true, 10, 5)")
77-
);
75+
await routerAdministration.CreateClassificationPolicyAsync(
76+
new CreateClassificationPolicyOptions(classificationPolicyId: "my-policy-id")
77+
{
78+
PrioritizationRule = new ExpressionRule("If(job.Escalated = true, 10, 5)") // this will check whether the job has a label "Escalated" set to "true"
79+
});
7880
```
7981

8082
::: zone-end
@@ -86,7 +88,7 @@ await client.upsertClassificationPolicy({
8688
id: "my-policy-id",
8789
prioritizationRule: {
8890
kind: "expression-rule",
89-
expression: "If(job.Urgent = true, 10, 5)"
91+
expression: "If(job.Escalated = true, 10, 5)"
9092
}
9193
});
9294
```

articles/communication-services/how-tos/router-sdk/accept-decline-offer.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@ ms.custom: kr2b-contr-experiment
1616

1717
This guide lays out the steps you need to take to observe a Job Router offer. It also outlines how to accept or decline job offers.
1818

19-
[!INCLUDE [Private Preview Disclaimer](../../includes/private-preview-include-section.md)]
20-
2119
## Prerequisites
2220

2321
- An Azure account with an active subscription. [Create an Azure account for free](https://azure.microsoft.com/free/?WT.mc_id=A261C142F).

articles/communication-services/how-tos/router-sdk/azure-function.md

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,6 @@ ms.service: azure-communication-services
1414

1515
# Azure function rule engine
1616

17-
[!INCLUDE [Private Preview Disclaimer](../../includes/private-preview-include-section.md)]
18-
1917
As part of the customer extensibility model, Azure Communication Services Job Router supports an Azure Function based rule engine. It gives you the ability to bring your own Azure function. With Azure Functions, you can incorporate custom and complex logic into the process of routing.
2018

2119
## Creating an Azure function
@@ -64,9 +62,12 @@ public static class GetPriority
6462
Inspect your deployed function in the Azure portal and locate the function Uri and authentication key. Then use the SDK to configure a policy that uses a rule engine to point to that function.
6563

6664
```csharp
67-
await client.SetClassificationPolicyAsync(
68-
"policy-1",
69-
prioritizationRule: new AzureFunctionRule("<insert function uri>", new AzureFunctionRuleCredential("<insert function key>")));
65+
await client.CreateClassificationPolicyAsync(
66+
options: new CreateClassificationPolicyOptions("policy-1")
67+
{
68+
PrioritizationRule = new FunctionRule("<insert function uri>", new FunctionRuleCredential("<insert function key>"))
69+
}
70+
);
7071
```
7172

7273
When a new job is submitted or updated, this function will be called to determine the priority of the job.

articles/communication-services/how-tos/router-sdk/customize-worker-scoring.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,6 @@ ms.service: azure-communication-services
1414

1515
# How to customize how workers are ranked for the best worker distribution mode
1616

17-
[!INCLUDE [Private Preview Disclaimer](../../includes/private-preview-include-section.md)]
18-
1917
The `best-worker` distribution mode selects the workers that are best able to handle the job first. The logic to rank Workers can be customized, with an expression or Azure function to compare two workers. The following example shows how to customize this logic with your own Azure Function.
2018

2119
## Scenario: Custom scoring rule in best worker distribution mode

articles/communication-services/how-tos/router-sdk/escalate-job.md

Lines changed: 62 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@ ms.custom: template-how-to
1616

1717
This guide shows you how to escalate a Job in a Queue by using an Exception Policy.
1818

19-
[!INCLUDE [Private Preview Disclaimer](../../includes/private-preview-include-section.md)]
20-
2119
## Prerequisites
2220

2321
- An Azure account with an active subscription. [Create an account for free](https://azure.microsoft.com/free/?WT.mc_id=A261C142F).
@@ -35,43 +33,58 @@ Create an exception policy, which you will attach to the regular queue, which is
3533

3634
```csharp
3735
// create the exception policy
38-
await client.SetExceptionPolicyAsync(
39-
id: "Escalate_XBOX_Policy",
40-
name: "Add escalated label and reclassify XBOX Job requests after 5 minutes",
41-
rules: new List<ExceptionRule>()
42-
{
43-
new (
44-
id: "Escalated_Rule",
45-
trigger: new WaitTimeExceptionTrigger(TimeSpan.FromMinutes(5)),
46-
actions: new List<ExceptionAction>
36+
await routerClient.CreateExceptionPolicyAsync(
37+
new CreateExceptionPolicyOptions(
38+
exceptionPolicyId: "Escalate_XBOX_Policy",
39+
exceptionRules: new Dictionary<string, ExceptionRule>()
4740
{
48-
new ReclassifyExceptionAction("EscalateReclassifyExceptionAction")
4941
{
50-
LabelsToUpsert = new LabelCollection(
51-
new Dictionary<string, object>
52-
{
53-
["Escalated"] = true,
54-
})
42+
["Escalated_Rule"] = new ExceptionRule(new WaitTimeExceptionTrigger(300),
43+
new Dictionary<string, ExceptionAction>()
44+
{
45+
"EscalateReclassifyExceptionAction" = new ReclassifyExceptionAction(
46+
classificationPolicyId: "<classification policy id>",
47+
labelsToUpsert: new Dictionary<string, LabelValue>()
48+
{
49+
["Escalated"] = new LabelValue(true),
50+
})
51+
})
5552
}
5653
}
57-
)
58-
});
54+
))
55+
{
56+
Name = "My exception policy"
57+
}
58+
);
5959
```
6060

6161
## Classification policy configuration
6262

6363
Create a Classification Policy to handle the new label added to the Job. This policy will evaluate the `Escalated` label and assign the Job to either Queue. The policy will also use the [RulesEngine](../../concepts/router/router-rule-concepts.md) to increase the priority of the Job from `1` to `10`.
6464

6565
```csharp
66-
await client.SetClassificationPolicyAsync(
67-
id: "Classify_XBOX_Voice_Jobs",
68-
name: "Classify XBOX Voice Jobs",
69-
queueSelector: new QueueIdSelector(
70-
new ExpressionRule(
71-
"If(job.Escalated = true, \"XBOX_Queue\", \"XBOX_Escalation_Queue\")")),
72-
workerSelectors: null,
73-
prioritizationRule: new ExpressionRule("If(job.Escalated = true, 10, 1)"),
74-
fallbackQueueId: "Default");
66+
await routerAdministrationClient.CreateClassificationPolicyAsync(
67+
options: new CreateClassificationPolicyOptions("Classify_XBOX_Voice_Jobs")
68+
{
69+
Name = "Classify XBOX Voice Jobs",
70+
PrioritizationRule = new ExpressionRule("If(job.Escalated = true, 10, 1)"),
71+
QueueSelectors = new List<QueueSelectorAttachment>()
72+
{
73+
new ConditionalQueueSelectorAttachment(
74+
condition: new ExpressionRule("If(job.Escalated = true, true, false)"),
75+
labelSelectors: new List<QueueSelector>()
76+
{
77+
new QueueSelector("Id", LabelOperator.Equal, new LabelValue("XBOX_Escalation_Queue"))
78+
}),
79+
new ConditionalQueueSelectorAttachment(
80+
condition: new ExpressionRule("If(job.Escalated = false, true, false)"),
81+
labelSelectors: new List<QueueSelector>()
82+
{
83+
new QueueSelector("Id", LabelOperator.Equal, new LabelValue("XBOX_Queue"))
84+
})
85+
},
86+
FallbackQueueId = "Default"
87+
});
7588
```
7689

7790
## Queue configuration
@@ -83,36 +96,37 @@ Create the necessary Queues for regular and escalated Jobs and assign the Except
8396
8497
```csharp
8598
// create a queue for regular Jobs and attach the exception policy
86-
await client.SetQueueAsync(
87-
id: "XBOX_Queue",
88-
name: "XBOX Queue",
89-
distributionPolicyId: "Round_Robin_Policy",
90-
exceptionPolicyId: "XBOX_Escalate_Policy"
91-
);
99+
await routerAdministrationClient.CreateQueueAsync(
100+
options: new CreateQueueOptions("XBOX_Queue", "Round_Robin_Policy")
101+
{
102+
Name = "XBOX Queue",
103+
ExceptionPolicyId = "XBOX_Escalate_Policy"
104+
});
92105

93106
// create a queue for escalated Jobs
94-
await client.SetQueueAsync(
95-
id: "XBOX_Escalation_Queue",
96-
name: "XBOX Escalation Queue",
97-
distributionPolicyId: "Round_Robin_Policy"
98-
);
107+
await routerAdministrationClient.CreateQueueAsync(
108+
options: new CreateQueueOptions("XBOX_Escalation_Queue", "Round_Robin_Policy")
109+
{
110+
Name = "XBOX Escalation Queue",
111+
});
99112
```
100113

101114
## Job lifecycle
102115

103116
When you submit the Job, specify the Classification Policy ID as follows. For this particular example, the requirement would be to find a worker with a label called `XBOX_Hardware`, which has a value greater than or equal to the number `7`.
104117

105118
```csharp
106-
await client.CreateJobWithClassificationPolicyAsync(
107-
channelId: ManagedChannels.AcsVoiceChannel,
108-
classificationPolicyId: "Classify_XBOX_Voice_Jobs",
109-
workerSelectors: new List<LabelSelector>
119+
await routerClient.CreateJobAsync(
120+
options: new CreateJobWithClassificationPolicyOptions(
121+
jobId: "<jobId>",
122+
channelId: ManagedChannels.AcsVoiceChannel,
123+
classificationPolicyId: "Classify_XBOX_Voice_Jobs")
110124
{
111-
new (
112-
key: "XBOX_Hardware",
113-
@operator: LabelOperator.GreaterThanEqual,
114-
value: 7)
115-
}
125+
RequestedWorkerSelectors = new List<WorkerSelector>
126+
{
127+
new WorkerSelector(key: "XBOX_Hardware", labelOperator: LabelOperator.GreaterThanEqual, value: new LabelValue(7))
128+
}
129+
});
116130
);
117131
```
118132

0 commit comments

Comments
 (0)