abaezag | 2023-09-06 10:20:20 UTC | #1
Hi,
We are carrying out a development for the management of schedules using the workforcemanagement API. We have performed shift updates for an agent following the documentation https://developer.genesys.cloud/useragentman/workforcemanagement/upload-update-schedule#headers without errors.
We have problems when an agent's activities need to be updated when an activity already exists in that date range. We have read that we are going to receive a validation error, for example these depending on the case:
"AgentShift: overlapping intervals found at 2023-12-07T14:15:00.000Z",
"Shift must contain contiguous activities without any gaps or overlaps"
But, what is the correct way to modify an existing agent shift? Should we delete it first? Is there a way to indicate it in the upload json schema? We have the same problem if we want to delete an existing agent shift.
Thank you very much for the help
brian.trezise | 2023-09-06 15:22:16 UTC | #2
Hey thanks for reaching out. It looks like you've got the general flow figured out for updating a schedule, so sounds like you just need a few general tips.
Editing an agent's schedule is currently done at the shift level of granularity, not the activity. That means you have the options to delete an entire shift, add a new shift (with all activities), or update a shift (with all activities). To resolve the validation errors you're seeing, you'll need to adjust all of the activities such that they no longer overlap.
A couple of additional notes:
- If your shift overlaps another shift (say a shift that crosses midnight runs into an early shift for the same agent the next day) you'll have to update both shifts to avoid overlap.
- Similar to the above, if you have an "8th day" shift that crosses into the next week's schedule, that shift cannot overlap a shift in that next week's schedule if that schedule is published.
abaezag | 2023-09-11 10:21:50 UTC | #3
Thanks for your answer.
We are working on an API integration, and we have not found any API in the Worforce Manager API to be able to delete a shift and add a shift with all activities. Could you tell us which one?
mostafaawad | 2023-09-11 11:05:51 UTC | #4
Hi @abaezag ,
If I understood well, here below is the flow of requests you need to follow:
- POST /api/v2/workforcemanagement/businessunits/{businessUnitId}/weeks/{weekId}/schedules/import/uploadurl
- You will receive an uploadUrl in the response from #1 so you have to make a PUT request to it to upload your schedule data.
- Then POST /api/v2/workforcemanagement/businessunits/{businessUnitId}/weeks/{weekId}/schedules/import to process your uploaded schedule
You can also follow this developer's guide explaining in more details.
abaezag | 2023-09-11 11:11:51 UTC | #5
Yes, these are the requests that I mentioned that we were using to add a schedule. When we create it new or without overlap there is no error. But we have the problem when we want to update a schedule and there is an overalap in the established shifts
mostafaawad | 2023-09-11 11:54:01 UTC | #6
As long as this already happens from Workforce Management Admin UI it will definitely cause errors from API side as well because it doesn't allow shift overlap between schedules as far as I understand
abaezag | 2023-09-11 12:17:38 UTC | #7
Yes, we have already verified that from the API it doesn't allow shift overlap between schedules. I return to my initial question in the forum. Is it impossible to modify the established shifts of an agent in a schedule if it exists? For example, an agent had an activity planned and now we want to update that that day will have a vacation. Through the API, is it necessary to delete the entire schedule to modify a single shift?
mostafaawad | 2023-09-11 14:05:28 UTC | #8
I didn't try it before from APIs but I think you can follow a similar process of API calls to do what you need but this time it's not importing, it's updating the schedule:
- Create an uploadUrl request by POST /api/v2/workforcemanagement/businessunits/{businessUnitId}/weeks/{weekId}/schedules/{scheduleId}/update/uploadurl
2.Then POST /api/v2/workforcemanagement/businessunits/{businessUnitId}/weeks/{weekId}/schedules/{scheduleId}/update
abaezag | 2023-09-11 14:35:05 UTC | #9
As I said in my first message, we are following those steps to update the schedule according to the documentation https://developer.genesys.cloud/useragentman/workforcemanagement/upload-update-schedule#headers We have tried these steps and from the API it gives error "Shift must contain contiguous activities without any gaps or overlaps"
For example, we send this json and there is already a shift for that agent at that time but with another activity code. { ... "agentSchedules":[ { "userId":"e3477921-c38e-413f-92a2-d1f034901077", "shifts":[ { "activities":[ { "startDate": "2023-12-04T12:15:00Z", "lengthMinutes": 120, "description": "", "activityCodeId": "1", "paid": true } ], ....
brian.trezise | 2023-09-11 17:02:06 UTC | #10
A brief explanation on how to edit an individual shift:
- To edit an existing shift - while keeping the shift ID the same, simply replace all the activities contained within that shift when constructing your update request. You do not need to pass data for shifts you do not intend to modify.
- To add a new shift, simply specify the shift in its entirety, only omitting the "id" field, and we will add it (pending validation) to the agent's schedule.
- To delete a shift, specify
"delete": true on an agent's shift in the json body to signal to completely delete that shift. Note I just identified that this field is missing in the developer center documentation, I'll create an internal ticket to rectify that documentation error. Note that this should only be done if you are truly stating the agent should not work that day,, not just to recreate it with a new shift.
abaezag | 2023-09-12 09:38:24 UTC | #11
Great, it's just what we need.
Thank you so much
alberto.castany | 2023-09-27 09:13:42 UTC | #12
I'm facing a similar problem. I'm able to update the schedule, but I'm unable to delete the shift to specify a day off. When you mention that we need to specify "delete": true for the shift in the json, where would that be exactly? do you think you could share an example?
brian.trezise | 2023-09-27 12:27:38 UTC | #13
The documentation change I mentioned in my earlier post is now live so I'll just show you the docs. Also if you are using the SDK be sure to update to the latest version for your respective language.
On this route:
POST /api/v2/workforcemanagement/businessunits/{businessUnitId}/weeks/{weekId}/schedules/{scheduleId}/update/uploadurl
Go to the bottom of the docs, and expand the "API Responses" section. Under that, expand the "201" response.
Under there, expand uploadBodySchema > agentSchedules > shifts. Under there, you'll see the "delete" flag for removing a shift. Alternately, you could replace the shift with a time off activity, whichever makes more sense.
system | 2023-10-28 12:27:49 UTC | #14
This topic was automatically closed 31 days after the last reply. New replies are no longer allowed.
This post was migrated from the old Developer Forum.
ref: 21861