Interface for managing task-related operations in the contact center Extends IEventEmitter to support event-driven task updates

interface ITask {
    autoWrapup?: default;
    data: TaskData;
    state?: any;
    uiControls: TaskUIControls;
    webCallMap: Record<string, string>;
    accept(): Promise<TaskResponse>;
    cancelAutoWrapupTimer(): void;
    consult(consultPayload): Promise<TaskResponse>;
    consultConference(): Promise<TaskResponse>;
    decline(): Promise<TaskResponse>;
    emit(event, ...args): boolean;
    end(): Promise<TaskResponse>;
    endConsult(consultEndPayload): Promise<TaskResponse>;
    exitConference(): Promise<TaskResponse>;
    hold(mediaResourceId?): Promise<TaskResponse>;
    off(event, listener): this;
    on(event, listener): this;
    once(event, listener): this;
    pauseRecording(): Promise<TaskResponse>;
    resume(mediaResourceId?): Promise<TaskResponse>;
    resumeRecording(resumeRecordingPayload): Promise<TaskResponse>;
    switchCall(): Promise<TaskResponse>;
    toggleMute(): Promise<void>;
    transfer(transferPayload, options?): Promise<TaskResponse>;
    transferConference(): Promise<TaskResponse>;
    wrapup(wrapupPayload): Promise<TaskResponse>;
}

Hierarchy (view full)

Implemented by

Properties

autoWrapup?: default

Auto-wrapup timer for the task This is used to automatically wrap up tasks after a specified duration as defined in AutoWrapup

data: TaskData

Event data received in the Contact Center events. Contains detailed task information including interaction details, media resources, and participant data as defined in TaskData

state?: any
uiControls: TaskUIControls

Latest UI controls derived from the state machine. Each control has isVisible and isEnabled flags computed from current task state. Subscribe to TASK_EVENTS.TASK_UI_CONTROLS_UPDATED for change notifications.

webCallMap: Record<string, string>

Map associating tasks with their corresponding call identifiers.

Methods

  • Cancels the auto-wrapup timer for the task. This method stops the auto-wrapup process if it is currently active. Note: This is supported only in single session mode. Not supported in multi-session mode.

    Returns void

    void

  • Initiates a consultation with another agent or queue.

    Parameters

    • consultPayload: ConsultPayload

      Consultation details including destination and type

    Returns Promise<TaskResponse>

    Promise

    Example

    await task.consult({ to: "agentId", destinationType: "agent" });
    
  • Places the current task on hold.

    Parameters

    • Optional mediaResourceId: string

      Optional media resource ID to use for the hold operation. If not provided, uses the task's current mediaResourceId

    Returns Promise<TaskResponse>

    Promise

    Example

    // Hold with default mediaResourceId
    await task.hold();

    // Hold with custom mediaResourceId
    await task.hold('custom-media-resource-id');
  • Parameters

    • event: string
    • listener: ((...args) => void)
        • (...args): void
        • Parameters

          • Rest ...args: any[]

          Returns void

    Returns this

  • Parameters

    • event: string
    • listener: ((...args) => void)
        • (...args): void
        • Parameters

          • Rest ...args: any[]

          Returns void

    Returns this

  • Resumes a task that was previously on hold.

    Parameters

    • Optional mediaResourceId: string

      Optional media resource ID to use for the resume operation. If not provided, uses the task's current mediaResourceId from interaction media

    Returns Promise<TaskResponse>

    Promise

    Example

    // Resume with default mediaResourceId
    await task.resume();

    // Resume with custom mediaResourceId
    await task.resume('custom-media-resource-id');
  • Toggles between consult call and main call during consulting. If on consult leg, switches to main call (holds consult). If on main call, switches to consult (resumes consult). Only available when in CONSULTING state.

    Returns Promise<TaskResponse>

    Promise

    Example

    await task.switchCall();
    
  • Toggles mute/unmute for the local audio stream during a WebRTC task.

    Returns Promise<void>

    Promise

    Example

    await task.toggleMute();
    
  • Transfers the task to another agent or queue.

    Parameters

    • transferPayload: TransferPayLoad

      Transfer details including destination and type

    • Optional options: TransferOptions

    Returns Promise<TaskResponse>

    Promise

    Example

    await task.transfer({ to: "queueId", destinationType: "queue" });
    
  • Initiates wrap-up process for the task with specified details.

    Parameters

    • wrapupPayload: WrapupPayLoad

      Wrap-up details including reason and auxiliary code

    Returns Promise<TaskResponse>

    Promise

    Example

    await task.wrapup({
    wrapUpReason: "Customer issue resolved",
    auxCodeId: "RESOLVED"
    });