From Bright Pattern Documentation
< 5.19:AgentDesktop-client-side-javascript-api-specification
Revision as of 04:01, 29 May 2024 by BpDeeplTranslateMaintenance (talk | contribs) (Updated via BpDeleteTranslateTags script)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search
• 5.19


onRequestTransferData

This handler will be invoked when the Agent Desktop application wants to receive additional data for transfer from one agent to another agent.

The data for the transfer can be anything that you need to transfer between CRM integrations in addition to internal interaction info. This data then will be moved through the Agent Desktop application to the CRM integration of another agent (i.e., if the second agent uses the same CRM integration). The Agent Desktop application doesn't read this data, it simply transfers.


Notes:

  • If you set multiple handlers which all return some data, only the result from the last handler will be used.
  • The callbacks onRequestTransferData and onLoadTransferData work in tandem and allow an API user to send arbitrary data between two agents on an interaction transfer.

Request

Syntax

on('ON_REQUEST_TRANSFER_DATA', handler: OnRequestTransferDataHandler): void


type OnRequestTransferDataHandler = (interactionId: string) => DataToTransfer | Promise<DataToTransfer>


type DataToTransfer = any

Parameters

Parameter Parameter Values Data Type Optional/Required Description
interactionId String Required The ID of the transferred interaction

Example Request

function requestTransferDataHandler(interactionId: string) {

const currentUserConversationHistory = conversations[interactionId];

return currentUserConversationHistory;

}

adApi.on("ON_REQUEST_TRANSFER_DATA", requestTransferDataHandler);

Return Value

The return value can be anything you wish to transfer with the interaction in order to restore the interaction’s state with this data to another agent with the same CRM integration.

Example

When Agent 1 is about to transfer an interaction to Agent 2, the callback onRequestTransferData will be triggered on Agent 1’s side, as if asking if the transfer should include some context information for Agent 2.

If Agent 1 wants to transfer some data (e.g., the URL of the current page), the data are passed as returning values of the onRequestTransferData callback.

When the transferred call is received by Agent 2, the callback onLoadTransferData will be triggered with data from onRequestTransferData that was passed from Agent 1.

// This executes on the side of an agent who transfer an interaction

jsApi.on("ON_REQUEST_TRANSFER_DATA", function (interactionId) {

    return {url: window.location.origin};

});

// This executes on the side of an agent to whom the interaction was transferred

jsApi.on("ON_LOAD_TRANSFER_DATA", function (interactionId, transferredData) {

    const transferredUrl = transferredData.url;

    window.open(transferredUrl);

});

< Previous | Next >