Category Archives: API

Simple API example – walk-through

This simple example will popup a window that displays the DT events as they happen. It works in conjunction with a phonecall form.

1.  Make a file with Notepad called dt_SimpleEG.js and paste in the following code:

var wndEvents = null; // A variable to hold the popup window reference.
var fnDTEventHandler = function (ev) { //Our DynamicsTelephony Event Handler.
 try {
 if (wndEvents == null) {
 //first time per call, wndEvents will be null, and the popup window will need to be re-created
 wndEvents ='', 'dtEventsWindow', 'menubar=1,resizable=1,status=1,width=750,height=250');
 wndEvents.document.body.innerHTML = '<h1>Dynamics Telephony Events</h1>';
 // add this event to the list...
 wndEvents.document.body.innerHTML += '<div>' + ev.dtEventArgs.toString() + '</div>';
 } catch (e) { }
// Register for Events with DynamicsTelephony using our Handler 'fnDTEventHandler'.

2.  Go to CRM > Settings > Customizations > Customize the system and add the above file as a Webresource, per this snap:



3. Add the above javascript library, and the core DT javascript library to the phonecall form, per this snap:



4. Publish all customizations

5. Run DT and do a click-to-dial or take an inbound call or an outbound campaigncall. NOTE these need to be configured to pop the phonecall form for the javascript to run.




DT Server Entities for integration

The following entities can be used for reports or triggered on for server-side integration.

cts_dialerCall – one entry for each phone call processed by DT. The same entry is used for the lifetime of the phone call. Can be linked to the associated CRM phone call. Fields include: agent (CRM user), calls, no answers, busies, connects, didConnect, direction, phone number, phone call ID, status (open, retry, closed), subject (e.g. campaign name), to (full name), computedOutcome (for your use – to change the outcome), aborts (selected an outcome that did not connect and isConnectXorAbort true on the selected outcome)

cts_dialerCallEvent – one entry for each event including: talk, ring, idle, error on dial, busy, no answer,  with fields: direction, duration, event name, phone number and dialer call ID in cts_dialerCall.

cts_dialerCallResult – one entry every time a call gets an outcome with fields including: agent (CRM user), dialer call ID in cts_dialerCall, direction, phone number, result (outcome as chosen by agent or automatically), and subject (e.g. campaign name)



DT Client API Overview

For a quick get-started with a simple API walk-through, see here

The following can be used by javascript running in any DT call tab. Any data refers to the call currently (or most recently) active in that call tab. All method calls are pre-pended with “DynamicsTelephony.”  For example to register for DT events:

// Create a Callback Function to be triggered 
// on call events
var fn = function (evtData) {
var oCall = DynamicsTelephony.parseEventArgs(evtData)
   TODO: implement your code here

// Register for events...

Or to get the details of the current call:

var oCall = DynamicsTelephony.GetCallDetails();
Dynamics Telephony Methods

Registers to receive telephony callbacks from DT in the function “fnEventHandler”. “fnEventHandler” should have the format:

var fn = function (evtData) {};

Where the evtData is the event payload passed from DT which can be objectified using the method “parseEventArgs()” below.


Convert an events payload (evtData in the above EG)  into a javascript object with the following properties:

  • state – The current state of the call
  • stateTime – The Datetime this state occurred
  • type – always “phonecall” at present
  • id – the guid of the CRM phonecall for this call
  • direction – one of  inbound, outbound, clicktocall, transfer or ccOutbound
  • phone – The phone number associated with the current call
  • outcome – No Answer, Voice Mail, etc. Any configured outcome
  • fromType – agent, lead, contact, account, case etc…
  • fromId – ID for above
  • toType – agent, lead, contact, account, case etc…
  • toId – ID for above
  • dtCallId – ID to link to dialerCalls table to get attempts, for example
  • isCallback – true or false, indicating where the call is a callback.
  • retryDatetime – The retry date/time of the call (Format “YYYY-MM-DDTHH:MM:SSZ”)
  • dnis – ^The number the customer originally dialed
  • queueDn – ^The phone number of the queue in the Contact Center
  • agentId – ^The agent ID in the Contact Center
  • extension – ^When available, the agents phone number that the call is on.

^When Available

Returns data on the current call,  in an object the same as described in parseEventArgs() above.

Dials the “number” passed on the current call tab.


Holds / Resumes the call on the current call tab.


Blind transfers the call on the current call tab to the “number” provided.


Consult transfers the call on the current call tab to the “number” provided.


Completes the transfer of the call on the current call tab to the call on the call tab provided. The current call tab must have a call in the active (not held) state and the call on the provided call tab must be on hold for successful transfer.


Conferences the call on the call tab provided to the call  on the current call tab. The current call tab must have a call in the active (not held) state and the call on the provided call tab must be on hold for successful conference.


Answer the call on the current call tab.


Release / Hang-up  the call on the current call tab.


Put the agent in ready state.


Put the agent in not ready state.


Plays the file “filename” into the call on the current call tab.


Sends the DTMF tone(s) in “digit” into the call on the current call tab. “digit” can be one or more of the following: 0123456789*#

Telephony Events

The event handler is triggered for each of the following telephony state changes:

  • preview – DT or CC Dialer call presented to agent and preview timer started
  • incoming – Inbound call or CC Dialer call presenting to agent
  • ringing – An outbound call is dialed and waiting for the customer to answer
  • talk – the call is active
  • idle – The call has been released, wrap timer may be running
  • end – The wrap time has expired or agent has manually moved on to the next call

The event payload contains the same data as returned from DynamicsTelephony.GetCallDetails() and this can be parsed to a javascript object using:

var oCall = DynamicsTelephony.parseEventArgs(evtData);


See here for code samples.