|
Nikrad eComms API is a set of facilities provided to link your enterprise platform with other communication devices and systems. The main feature which is designed to be used on VoIP platforms such as Asterisk is capturing Caller ID of income phone calls which your customers make.
The first step is obtaining an eComms API Key and registering it into the system by referring to the section "Settings \ System Settings \ System Information". eComms service will start serving once you define a valid api key. We set the parameter "apikey" while sending requests to the server. This example shows how to send information of a phone call to the server.
It is possible sending data to a server by using a web browser and a URL with query parameters.
[Server Address]/nep/api/ecomms/[Command].jsp[?param1=value¶m2=value...]
Response will be formed in XML format which is so clear to understand and applicable by xml manipulating libraries. We can also deal with xml content as simple text by parsing its elements. The example below shows a query to a server with invalid or missing api key:
http://demo.csa.nikrad.com/nep/api/ecomms/call.receive.jsp?num=5175812901
As you can see, the response is too clear to understand, following a standard style defined through all the eComms api commands. The main tag is named as "packet" containing different sub elements. We must always check for the value "up" in the tag "status" saying that the service for the command (e.g. "call.receive") is available and we can process the rest of the response content. We also need to control If the tag "result" contains "error" we must stop processing the xml considering the reason lied in the tag "data" (e.g. "invalid api key"). If the tag "result" contains other values (e.g. "done") we can use all the information provided in the tag "data".
Installing cURL is easy. If it was not on your system when you last compiled Asterisk, after installing it you’ll need to recompile Asterisk so that it can locate the cURL dependencies and compile the func_curl.so module.
On Debian, Ubuntu, Mint:
apt-get install libcurl4-openssl-dev
On CentOS, RHEL, Fedora:
yum -y install libcurl-devel
For more information related to cURL module please read documentation provided by the asterisk wiki or search through the internet.
The final step is configuring the dialplan to send income phone numbers into the enterprise system through the eComms api system. The style of this configuration is up to you, however we provide a sample to approach this aim:
exten => s, n, Set(foo=${CURL(http://[Server Address]/nep/api/ecomms/call.receive.jsp?num=${CALLERID(num)}&areacode=MyAreaCode&apikey=MyAPIKey)})
exten => s, n, NoOp(${foo})
The first line is all we need to set. The second line is optional and we can use it to display the result of the query registered in foo. The sample texts "MyAreaCode" and "MyAPIKey" must be replaced by the valid values. The CURL command gets the caller id via the ${CALLERID(num)} and posts it to the nikrad enterprise platform using the "call.receive" api command.
On the platform side, the access privilege for "Callers List" should be given to the desired users. Therefore, they can refer to the relevant section through the system main sub-menu. In this list, users will find known phone numbers linked to relevant crm accounts.
That's it.