작업 예약

콜 센터라는 컨텍스트에서는 고객이 나중에 예약된 콜백을 받고 싶어할 수 있습니다. 따라서 작업 라우터에 예약된 작업을 만들어야 합니다.

필수 조건

ScheduleAndSuspendMode를 사용하여 작업 만들기

다음 예제에서는 scheduleAt 매개 변수를 사용하여 MatchingModeScheduleAndSuspendMode에 설정함으로써 지금부터 3분 후로 예약된 작업을 만듭니다. 이 예제에서는 queueId가 Callback큐를 만들었고Voice 채널에 가용한 용량을 갖춘 상태로 큐에 등록된 활성 작업자가 있는 것으로 가정합니다.

await client.CreateJobAsync(new CreateJobOptions(jobId: "job1", channelId: "Voice", queueId: "Callback")
{
    MatchingMode = new ScheduleAndSuspendMode(scheduleAt: DateTimeOffset.UtcNow.Add(TimeSpan.FromMinutes(3)))
});
await client.path("/routing/jobs/{jobId}", "job1").patch({
    body: {
        channelId: "Voice",
        queueId: "Callback",
        matchingMode: {
            kind: "scheduleAndSuspend",
            scheduleAt: new Date(Date.now() + 3 * 60000)
        }
    },
    contentType: "application/merge-patch+json"
});
client.upsert_job(
    job_id = "job1",
    channel_id = "Voice",
    queue_id = "Callback",
    matching_mode = ScheduleAndSuspendMode(schedule_at = datetime.utcnow() + timedelta(minutes = 3)))
client.createJob(new CreateJobOptions("job1", "Voice", "Callback")
    .setMatchingMode(new ScheduleAndSuspendMode(OffsetDateTime.now().plusMinutes(3))));

참고 항목

예약된 후 작업의 상태는 처음에는 PendingSchedule이며 작업 라우터가 작업을 성공적으로 예약하면 상태가 Scheduled로 업데이트됩니다.

예약된 시간에 도달할 때까지 기다린 다음 작업을 큐에 배치합니다.

예약된 시간에 도달하면 작업 상태가 WaitingForActivation으로 업데이트되고 작업 라우터가 RouterJobWaitingForActivation 이벤트를 Event Grid에 내보냅니다. 이 이벤트를 구독한 경우 작업을 작업자에 연결하도록 설정하기 전에 몇 가지 필요한 작업이 수행될 수 있습니다. 예를 들어 연락 센터라는 컨텍스트에서라면 아웃바운드 전화를 걸어 고객이 콜백을 수락할 때까지 기다리는 것이 이러한 작업에 해당할 수 있습니다. 필요한 작업이 완료되면 UpdateJobAsync 메서드에 MatchingModeQueueAndMatchMode로 설정하고 우선 순위를 100으로 설정하여 적격인 작업자를 빠르게 찾아 호출함으로써 해당 작업을 큐에 배치할 수 있으며 이렇게 하면 해당 작업의 상태가 queued로 업데이트됩니다.

// Event Grid Event Handler code omitted
if (eventGridEvent.EventType == "Microsoft.Communication.RouterJobWaitingForActivation")
{
    // Perform required actions here

    await client.UpdateJobAsync(new RouterJob(jobId: eventGridEvent.Data.JobId)
    {
        MatchingMode = new QueueAndMatchMode(),
        Priority = 100
    });
}
// Event Grid Event Handler code omitted
if (eventGridEvent.EventType == "Microsoft.Communication.RouterJobWaitingForActivation")
{
    // Perform required actions here

    await client.path("/routing/jobs/{jobId}", eventGridEvent.data.jobId).patch({
      body: {
          matchingMode: { kind: "queueAndMatch" },
          priority: 100
      },
      contentType: "application/merge-patch+json"
    });
}
# Event Grid Event Handler code omitted
if (eventGridEvent.event_type == "Microsoft.Communication.RouterJobWaitingForActivation")
{
    # Perform required actions here

    client.upsert_job(
        job_id = eventGridEvent.data.job_id,
        matching_mode = queue_and_match_mode = {},
        priority = 100)
}
// Event Grid Event Handler code omitted
if (eventGridEvent.EventType == "Microsoft.Communication.RouterJobWaitingForActivation")
{
    // Perform required actions here

    job = client.updateJob(eventGridEvent.getData().toObject(new TypeReference<Map<String, Object>>() {
}).get("JobId").toString(), BinaryData.fromObject(new RouterJob()
        .setMatchingMode(new QueueAndMatchMode())
        .setPriority(100)), null).toObject(RouterJob.class);
}

다음 단계

i