Interface ServiceDeskCallback<TPersistedStateType>

This interface represents the operations that a service desk integration can call on web chat when it wants web chat to do something. When a service desk integration instance is created, web chat will provide an implementation of this interface to the integration for it to use.

interface ServiceDeskCallback<TPersistedStateType = unknown> {
    agentEndedChat(): Promise<void>;
    agentJoined(profile: AgentProfile): Promise<void>;
    agentLeftChat(): Promise<void>;
    agentReadMessages(): Promise<void>;
    agentTyping(isTyping: boolean): Promise<void>;
    beginTransferToAnotherAgent(profile?: AgentProfile): Promise<void>;
    persistedState(): TPersistedStateType;
    screenShareEnded(): Promise<void>;
    screenShareRequest(): Promise<ScreenShareState>;
    sendMessageToUser(
        message:
            | string
            | MessageResponse<GenericItem<Record<string, unknown>>[]>,
        agentID?: string,
    ): Promise<void>;
    setErrorStatus(errorInfo: ServiceDeskErrorInfo): Promise<void>;
    setFileUploadStatus(
        fileID: string,
        isError?: boolean,
        errorMessage?: string,
    ): Promise<void>;
    updateAgentAvailability(availability: AgentAvailability): Promise<void>;
    updateCapabilities(capabilities: Partial<ServiceDeskCapabilities>): void;
    updatePersistedState(
        state: DeepPartial<TPersistedStateType>,
        mergeWithCurrent?: boolean,
    ): void;
}

Type Parameters

  • TPersistedStateType = unknown

Methods

  • Informs the chat widget that the agent has ended the conversation.

    Returns Promise<void>

  • Informs the chat widget that an agent has joined the chat.

    Parameters

    Returns Promise<void>

  • Informs the chat widget that the agent has left the conversation. This does not end the conversation itself, rather the only action that occurs is the visitor receives the agent left status message. If the user sends another message, it is up to the service desk to decide what to do with it.

    Returns Promise<void>

  • Informs the chat widget that the agent has read all the messages that have been sent to the service desk.

    Returns Promise<void>

  • Tells the chat widget if an agent has started or stopped typing.

    Parameters

    • isTyping: boolean

      If true, indicates that the agent is typing. False indicates the agent has stopped typing.

    Returns Promise<void>

  • Informs the chat widget that a transfer to another agent is in progress. The agent profile information is optional if the service desk doesn't have the information available. This message simply tells the chat widget that the transfer has started. The service desk should inform the widget when the transfer is complete by sending a agentJoined message later.

    Parameters

    Returns Promise<void>

  • Informs web chat that a screen sharing session has ended or been cancelled. This may occur while waiting for a screen sharing request to be accepted or while screen sharing is in progress.

    Returns Promise<void>

  • Requests that the user share their screen with the agent. This will present a modal dialog to the user who must respond before continuing the conversation. This method returns a Promise that resolves when the user has responded to the request or the request times out.

    Returns Promise<ScreenShareState>

    Returns a Promise that will resolve with the state the of the request. This Promise will reject if no chat with an agent is currently running.

  • Sends a message to the chat widget from an agent.

    Note: The text response type from the standard Watson API is supported in addition to the web chat specific MessageResponseTypes.INLINE_ERROR response type.

    Parameters

    • message: string | MessageResponse<GenericItem<Record<string, unknown>>[]>

      The message to display to the user. Note, the ability to pass a string for the message was added in web chat 6.7.0. Earlier versions of web chat will not work if you pass just a string.

    • OptionalagentID: string

      The ID of the agent who is sending the message. If this is not provided, then the ID of the last agent who joined the conversation will be used.

    Returns Promise<void>

  • Sets the state of the given error type.

    Parameters

    Returns Promise<void>

  • Updates the status of a file upload. The upload may either be successful or an error may have occurred. The location of a file upload may be in one of two places. The first occurs when the user has selected a file to be uploaded but has not yet sent the file. In this case, the file appears inside the web chat input area. If an error is indicated on the file, the error message will be displayed along with the file and the user must remove the file from the input area before a message can be sent.

    The second occurs after the user has sent the file and the service desk has begun to upload the file. In this case, the file no longer appears in the input area but appears as a sent message in the message list. If an error occurs during this time, an icon will appear next to the message to indicate an error occurred and an error message will be added to the message list.

    Parameters

    • fileID: string

      The ID of the file upload to update.

    • OptionalisError: boolean

      Indicates that the upload has an error or failed to upload.

    • OptionalerrorMessage: string

      An error message to display along with a file in error.

    Returns Promise<void>

  • Sends updated availability information to the chat widget for a user who is waiting to be connected to an agent (e.g. the user is number 2 in line). This may be called at any point while waiting for the connection to provide newer information.

    Note: Of the fields in the AgentAvailability object, only one of position_in_queue and estimated_wait_time can be rendered in the widget. If both fields are provided, estimated_wait_time will take priority and the position_in_queue field will be ignored.

    Parameters

    Returns Promise<void>

  • Updates web chat with the capabilities supported by the service desk. Some of these capabilities may support being changed dynamically and can be updated at any time.

    Parameters

    • capabilities: Partial<ServiceDeskCapabilities>

      The set of capabilities to update. Only properties that need to be changed need to be included.

    Returns void

  • Allows the service desk to store state that may be retrieved when web chat is reloaded on a page. This information is stored in browser session storage which has a total limit of 5MB per origin so the storage should be used sparingly. Also, the value provided here must be JSON serializable.

    When web chat is reloaded, the data provided here will be returned to the service desk via the ServiceDeskFactoryParameters.persistedState property. This data may also be retrieved by using the persistedState method.

    Parameters

    • state: DeepPartial<TPersistedStateType>

      The state to update.

    • OptionalmergeWithCurrent: boolean

      Indicates if the new state should be merged into the existing state. If false, then the existing state will be fully replaced with the new state. Merging with existing state expects the state to be an object. This argument is true by default.

    Returns void

MMNEPVFCICPMFPCPTTAAATR