Skip to content

Commit c71cd59

Browse files
authored
Create handle-offer.md
Add public docs for handling offer and following job actions.
1 parent dec8f52 commit c71cd59

File tree

1 file changed

+108
-0
lines changed

1 file changed

+108
-0
lines changed
Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
---
2+
title: Handle an offer in Job Router
3+
titleSuffix: An Azure Communication Services how-to guide
4+
description: Use Azure Communication Services SDKs to manage the job offer
5+
author: marcma
6+
ms.author: marcma
7+
ms.service: azure-communication-services
8+
ms.topic: how-to
9+
ms.date: 01/18/2022
10+
ms.custom: template-how-to
11+
12+
#Customer intent: As a developer, I want to handle job offers when coming in.
13+
---
14+
15+
# Handle an offer
16+
17+
This guide outlines the steps to observe and response a Job Router offer.
18+
19+
[!INCLUDE [Private Preview Disclaimer](../../includes/private-preview-include-section.md)]
20+
21+
## Prerequisites
22+
23+
- An Azure account with an active subscription. [Create an account for free](https://azure.microsoft.com/free/?WT.mc_id=A261C142F).
24+
- A deployed Communication Services resource. [Create a Communication Services resource](../../quickstarts/create-communication-resource.md).
25+
- Optional: Complete the quickstart to [get started with Job Router](../../quickstarts/router/get-started-router.md)
26+
27+
## Query the worker to observe the job offers
28+
Following the quickstart, use the Job Router client connection to query the Worker and observe the ID of the Job against the ID
29+
30+
```csharp
31+
var result = await client.GetWorkerAsync(edmontonWorker.Value.Id);
32+
33+
Console.WriteLine(
34+
$"Job Offer ID: {result.Value.Offers[0]} offered to {edmontonWorker.Value.Id} ");
35+
36+
```
37+
38+
## Accept a job offer
39+
40+
The worker can accept the job offer by using the client connection
41+
42+
```csharp
43+
var offer = (await client.GetWorkerAsync(edmontonWorker.Value.Id)).Value.Offers[0];
44+
var result = await client.AcceptJobOfferAsync(edmontonWorker.Value.Id, offer.Id);
45+
46+
```
47+
48+
## Decline a job offer
49+
50+
The worker can decline the job offer by using the client connection if worker is not willing to take the job.
51+
52+
```csharp
53+
var offer = (await client.GetWorkerAsync(edmontonWorker.Value.Id)).Value.Offers[0];
54+
var result = await client.DeclineJobOfferAsync(edmontonWorker.Value.Id, offer.Id);
55+
56+
```
57+
58+
## Complete a job
59+
60+
To complete an assigned job by using the client connection with the **assignment ID** provided when acceptting the job offer and **job ID**.
61+
62+
```csharp
63+
var offer = (await client.GetWorkerAsync(edmontonWorker.Value.Id)).Value.Offers[0];
64+
var assignmentId = (await client.AcceptJobOfferAsync(edmontonWorker.Value.Id, offer.Id)).Value.AssignmentId;
65+
66+
await client.CompleteJobAsync(offer.JobId, assignmentId);
67+
68+
```
69+
70+
> [!NOTE]
71+
> To comfirm the job is complete, subscribe to events to observe the **job completed event**, check [subscript events doc](./subscribe-events.md) on how to subscript events.
72+
73+
74+
## Close a job
75+
76+
To close a completed job by using the client connection with the **job ID** and **assignment ID**. Optionally, pass in a **disposition code** to indicate the outcome of the job, pass **release time** to indicate when to release the capacity.
77+
78+
```csharp
79+
var offer = (await client.GetWorkerAsync(edmontonWorker.Value.Id)).Value.Offers[0];
80+
var assignmentId = (await client.AcceptJobOfferAsync(edmontonWorker.Value.Id, offer.Id)).Value.AssignmentId;
81+
82+
await client.CloseJobAsync(offer.JobId, assignmentId, "job completed", DateTime.Now.AddDays(1));
83+
84+
```
85+
86+
## Cancel a job
87+
88+
To cancel a job by using the client connection with the **job ID**. Optionally, pass in a **disposition code** to indicate the outcome of the job, pass **note** to record notes.
89+
90+
```csharp
91+
var offer = (await client.GetWorkerAsync(edmontonWorker.Value.Id)).Value.Offers[0];
92+
93+
await client.CancelJobAsync(offer.JobId, "job cancelled", "should recreate later");
94+
95+
```
96+
97+
## Delete a job
98+
99+
To delete a job and all of its traces using the client connection.
100+
101+
```csharp
102+
var offer = (await client.GetWorkerAsync(edmontonWorker.Value.Id)).Value.Offers[0];
103+
104+
await client.DeleteJobAsync(offer.JobId);
105+
106+
```
107+
108+

0 commit comments

Comments
 (0)