Skip to main content
8x8 Support

ContactNow: Using Ajax.php API Endpoint to Read Agent Status

Objective

To use Ajex.php API Endpoint to read an Agent's current Status on the dialer.

API Ajax Endpoint is used to read agent statuses from outside the standard ContactNow agent or admin interface.

Note-Icon.png Note: 8x8 does not provide programming support for the ContactNow API. However, further API reference material is linked in the Additional Information section at the bottom of this article.

Applies To

  • ContactNow
  • API
  • Ajax.php

Procedure

Access the ContactNow API URL

To access any ContactNow API interface, requests need to have an access token. The token will authorize requests for a particular account for a fixed period of time. By default, these requests are restricted to the internet address that requests the token.

The API URL to retrieve agent live status is:

https://api-106.dxi.eu/agent.php?token=[Token]&action=[Action]&agentid=[agentid]&raw=1

The ajax API has a number of available functions. The request arguments should be passed as HTTP Post or Get variables. The payload/response from the API can be formatted in either json or xml format. The default is json but this can be modified by the format argument below:

  • Formatxml or json

The API will output a number of optional values depending on the request made.

  • Success: This shows whether the request succeeded. It will contain a true or false value for json or a 1 or 0  for xml.
  • Account ID: This shows the authenticated account that ran the API call.
  • Total: Number of records affected.
  • Bad: Number of records that failed.
  • Key: The unique ID that is returned when creating a new record.
  • Error: If the request failed, this field will contain a description of the fault.

Example of JSON Response:

{"success":true}

Example of XML Response:

<?xml version="1.0" encoding="ISO-8859-1"?>
<result> 
    <success>1</success> 
</result>

Read an Agent State Using the Ajax API Endpoint    

This will log an agent in by ringing their phone with the provided argument as their number and return its success state and a unique key or any errors in the request. 

  • HTTP Request: POST/GET
  • Action: read
  • Arguments: agent (Optional, will be the agent ID), mode (Optional, currently ignores offline/use all to get offline agents)

GET API call with json: 

ajax.php?token=[Token]&action=read&method=agents&format=[Format]&raw=1

The Json Response:

{success: true,
total: 1,
list: [{
        uid: "1226353",
        name: "Administrator",
        moh: "none",
        status: "offline",
        statuscode: "Home",
        time: "1550245970",
        srvtime: "1550247582",
        ccname: "Ion_Test",
        customer: "0",
        call: [ ]
        }]
}

The XML Response:

<result>
    <success>1</success>
    <total>1</total>
    <list>
        <agent>
            <uid>1226353</uid>
            <name>Administrator 1</name>
            <moh>none</moh>
            <status>offline</status>
            <statuscode>Home</statuscode>
            <time>1550245970</time>
            <srvtime>1550247699</srvtime>
            <ccname>Ion_Test</ccname>
            <customer>0</customer>
            <call/>
        </agent>
   </list>
</result>

Additional Information

To create access tokens for the ContactNow API, you will need to create a case with 8x8 Technical Support to obtain an API username and key. Once you have the username and key, you can use the instructions on the following link to create a token for using the API functionality.