Skip to content

Conversation

@adhmenon
Copy link
Contributor

@adhmenon adhmenon commented Nov 19, 2025

COMPLETES #< AD-HOC >

This pull request addresses

  • EPIC team reported an issue that was happening with the widgets.
  • Whenever a user got the AgentOutboundFailed event, the widgets was not properly cleaning up the call and so the user was not able to do further outdials.
  • Further triaging found that this was because the SDK was clearing the task object on receiving this event and hence subsequent wrapup was not being shown.

by making the following changes

  • Now we simply emit TASK_REJECT on receiving the AgentOutboundFailed event and on subsequent events from the backend, we end task and show wrapup.
  • Code was also added to ensure that rejecting the outdial event clears up the task and older flows remain unaffected.
  • Other task clear ups also work.

Vidcast (EXTENSION) - https://app.vidcast.io/share/604f2f25-55ea-4446-950b-68777ce8f6a3
Vidcast (BROWSER) - https://app.vidcast.io/share/25857bee-9aa8-4539-b411-5b4c4808d1d3

Change Type

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation update
  • Tooling change
  • Internal code refactor

The following scenarios were tested

  • Tested outdial on both EXTENSION and BROWSER
  • Tested for both working outdial and failing.
  • Tested user rejecting outdial call.
  • Tested basic call to see all flows worked.

The GAI Coding Policy And Copyright Annotation Best Practices

  • GAI was not used (or, no additional notation is required)
  • Code was generated entirely by GAI
  • GAI was used to create a draft that was subsequently customized or modified
  • Coder created a draft manually that was non-substantively modified by GAI (e.g., refactoring was performed by GAI on manually written code)
  • Tool used for AI assistance (GitHub Copilot / Other - specify)
    • Github Copilot
    • Cursor
  • This PR is related to
    • Feature
    • Defect fix
    • Tech Debt
    • Automation

I certified that

  • I have read and followed contributing guidelines
  • I discussed changes with code owners prior to submitting this pull request
  • I have not skipped any automated checks
  • All existing and new tests passed
  • I have updated the documentation accordingly

Make sure to have followed the contributing guidelines before submitting.

@adhmenon adhmenon requested a review from a team as a code owner November 19, 2025 09:49
@adhmenon adhmenon added the validated If the pull request is validated for automation. label Nov 19, 2025
case CC_EVENTS.AGENT_OUTBOUND_FAILED:
// We don't have to emit any event here since this will be result of promise.
if (task.data) {
this.removeTaskFromCollection(task);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This here was the root cause of the issue, have removed it - it was old code.

if (task.data) {
this.removeTaskFromCollection(task);
}
task = this.updateTaskData(task, payload.data);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here we simply update the task, post metrics and then emit the TASK_REJECTED event so users can handle it. Agent Desktop also does the same (shows a modal).
I preferred re-using this event as opposed to simply sending another event from the SDK.

if (task.data.interaction.state === 'new' || isSecondaryEpDnAgent(task.data.interaction)) {
// Only remove tasks in 'new' state or isSecondaryEpDnAgent immediately. For other states,
// retain tasks until they complete wrap-up, unless the task disconnected before being answered.
const isOutdial = task?.data?.interaction?.outboundType === 'OUTDIAL';
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These are new conditions. Open to suggestions if I can do it it a better way but this is the cleanest way I saw.

Let me explain - basically we only need to clear the task for outdial cases where the user rejects it (i.e agent rejects it). In the case where we get AgentOutboundFailed - we ALWAYS get ContactEnded AND AgentWrapup in the same sequence. Hence once the user wraps up the task clears up automatically.
The change I made ensures these cases are handled with as minimal changes to the SDK flow. Otherwise we might need more checks and I wanted to do this as a pure SDK change and no widgets change needed.

// If terminated, keep task for wrap-up flow (CONTACT_ENDED → AGENT_WRAPUP)
// For non-OUTDIAL: remove if state is 'new'
// Always remove if secondary EpDn agent
if ((isNew && !(isOutdial && isTerminated)) || isSecondaryEpDnAgent(task.data.interaction)) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Another point - I've tested this with widgets against older flows and nothing breaks.
All old calls will follow the same flow and the check specifcially checks for both isOutdial and isTerminated.

});

it('should remove currentTask from taskCollection on AGENT_OUTBOUND_FAILED event', () => {
it('should NOT remove OUTDIAL task from taskCollection on AGENT_OUTBOUND_FAILED when terminated (wrap-up flow)', () => {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added some tests for checking the clearing of the task and also the case where we do not want to clear the task object.

@adhmenon adhmenon requested a review from Kesari3008 November 24, 2025 11:16
@adhmenon adhmenon merged commit 40edfe2 into webex:next Nov 24, 2025
11 checks passed
@adhmenon adhmenon deleted the outdial-fail branch November 24, 2025 13:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

validated If the pull request is validated for automation.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants