|
| 1 | +--- |
| 2 | +title: Accept or decline an offer in Job Router |
| 3 | +titleSuffix: An Azure Communication Services how-to guide |
| 4 | +description: Use Azure Communication Services SDKs to accept or decline a job offer in Job Router. |
| 5 | +author: marche0133 |
| 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 accept/decline job offers when coming in. |
| 13 | +--- |
| 14 | + |
| 15 | +# Accept or decline a Job Router offer |
| 16 | + |
| 17 | +This guide outlines the steps to observe a Job Router offer, and then to accept the job offer or delete the job 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 Azure 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 | +## Observe the offer issued event |
| 28 | + |
| 29 | +After you create a job, observe the [offer issued event](subscribe-events.md#microsoftcommunicationrouterworkerofferissued), which contains the worker ID and the job offer ID: |
| 30 | + |
| 31 | +```csharp |
| 32 | +var workerId = event.data.workerId; |
| 33 | +var offerId = event.data.offerId; |
| 34 | +Console.WriteLine($"Job Offer ID: {offerId} offered to worker {workerId} "); |
| 35 | + |
| 36 | +``` |
| 37 | + |
| 38 | +## Accept a job offer |
| 39 | + |
| 40 | +Then, the worker can accept the job offer by using the SDK: |
| 41 | + |
| 42 | +```csharp |
| 43 | +var result = await client.AcceptJobOfferAsync(workerId, offerId); |
| 44 | + |
| 45 | +``` |
| 46 | + |
| 47 | +## Decline a job offer |
| 48 | + |
| 49 | +Alternatively, the worker can decline the job offer by using the SDK if worker isn't willing to take the job: |
| 50 | + |
| 51 | +```csharp |
| 52 | +var result = await client.DeclineJobOfferAsync(workerId, offerId); |
| 53 | + |
| 54 | +``` |
| 55 | + |
| 56 | +## Next steps |
| 57 | + |
| 58 | +- Review how to [manage a Job Router queue](manage-queue.md). |
| 59 | +- Learn how to [subscribe to Job Router events](subscribe-events.md). |
0 commit comments