Controlling LeadDesk from within Customer Contact Card

A customized contact card can communicate with LeadDesk using a simple postMessage Javascript command. For example:

function hangUp() {
parent.postMessage(JSON.stringify({“action”:“hangup”}), document.referrer);


function selectReason(reasonId) {

parent.postMessage(JSON.stringify({“action”:“select_reason”,“params”: {“id”: reasonId}}), document.referrer);


Please note that as the document.referrer is used, one the user traverses to another page inside the original IFrame, the original document.referrer value must be passed to that page and also to next pages. That way the targetOrigin parameter of postMessage can be set accordingly and the messages reach the intended target. Supported commands

Action (“action”) Parameters (“params”) Description
call {“params”: {“phone_number”: “{phone}”, call_id”: {call_logs_id}, “customer_id”: {customers_id}, “auto_call”: true} Making a call with phone number OR OR
hangup   Hang up the active call
close {“target”: “call_dialog”} Close the call dialog
close {“target”: “full_window_campaign_url”} Close the full window (call dialog remains open)
select_reason {“id”: } Select a call ending reason by id
continue_call_recording   Continue call recording
pause_call_recording   Pause call recording
start_voice_receipt_recording   Start voice receipt recording
stop_voice_receipt_recording   Stop voice receipt recording
request_full_window   Request full window display for the iframe (will be displayed when call dialog opens if there is a call ongoing). So the iframe page can safely request this immediately after loading.
force_full_window   Force full window display for the iframe immediately (even if there is no call ongoing). This should not be generally used as this can break the UI in certain situations. Use “request_full_window” instead.
delete_call_log {“call_log_id”: } Deletes row from call_logs by given id (Call state must be no_answer)

  Events delivered by postMessage

Type (“type”) Data (“data”) Description
callLineRinging {call_log_id: } Event sent when phone call changes to ringing state.
callLineIdle {call_log_id: } Event sent when phone call changes to idle state. This happens every time page is initialized and when hangup is called.
callLineOn {call_log_id: } Event sent when phone call changes to online (answered) state.
recStarted {file: } Event sent when order receipt recording is started
recStopped {file: } Event sent when order receipt recording is stopped
recCancelled {file: } Event sent when order receipt recording is cancelled