From Bright Pattern Documentation
Jump to: navigation, search
• 5.19


onWebScreenPopCustom

This callback allows you to customize the web screen pop handler and override the default web screen pop behavior with a browser popup. If your listener returns true, then default behavior will be prevented. If your listener returns false, the default handler will process the data after you.

Request

Syntax

on('ON_WEB_SCREEN_POP_CUSTOM', handler: OnWebScreenPopCustomHandler): void


type OnWebScreenPopCustomHandler = (itemId: string, webScreenPop: WebScreenPop) => SyncAsyncResult<boolean>


type WebScreenPop = {

    action: 'OPEN_WEB_PAGE' | 'DISPLAY_TEXT'     url: string     content: string     label: string     popUponAnswer: boolean     keepPopupOpenAfterFinish: boolean     popup: boolean     secondaryUrls?: {

        [key: number]: WebScreenPopSecondaryUrl

    }

}


type WebScreenPopSecondaryUrl = {

    label?: string     url?: string

}


Parameters

Parameter Parameter Values Data Type Optional/Required Description
itemId String Required The ID of the item originating this screen pop
webScreenPop
action String Required The type of screen pop; options are as follows:
  • ‘OPEN_WEB_PAGE’
  • ‘DISPLAY_TEXT’
url String Required The main url; used only for the action option ‘OPEN_WEB_PAGE’
content String Required The text to display; used only for the action option ‘DISPLAY_TEXT’
label String Required The heading for this screen pop
popUponAnswer Boolean Required If set to true, the screen pop will pop when the interaction is routed to the agent; if set to false, the screen will pop only after the agent has accepted the interaction.
keepPopupOpenAfterFinish Boolean Required If set to true, the screen pop will remain open after the interaction is finished; if set to false, the screen pop will close when the interaction is finished.
popup Boolean Required If set to true, the screen pop is a pop-up window; if set to false, the screen pop is an inline screen pop.
secondaryUrls Optional The object with values of additional URLs for multiple, simultaneous screen pops

Example Request

function webScreenPopCustomHandler(itemId: string, screenPopData: WebScreenPop) {

window.open(screenPopData.url, "_blank");

return true;	
}
}
adApi.on("ON_WEB_SCREEN_POP_CUSTOM", webScreenPopCustomHandler);

Return Value

Returns a Boolean value of true or false, depending on whether you want to prevent default handler behavior or not.

< Previous