Free CRM API

Free CRM API

Less than a year ago, we introduced a free CRM system integrated with a free PBX. During this time, 14 companies and 000 employees have used it.
Now we offer an open API interface, in which most of the functions of ZCRM are available. The API allows you to use CRM for any sales channels.
Below we briefly describe the work with the API and the available functionality. A simple but useful and working example is also given: a script for creating a lead from a form on the site.

Briefly about free CRM

Let's refrain from explaining what CRM is. Free CRM Zadarma supports all standard customer data storage functions. The information is stored in the client's feed. Also, in addition to information about customers, a convenient task manager is available with a display for every taste (calendar, kanban, list). All this is available for 50+ employees and is fully integrated with telephony (including calls from a browser using WebRTC technology).
Free CRM API
What does free mean? There are no ZCRM tariffs or services that you have to pay for. The only thing you have to pay for is phone calls and numbers (according to special tariffs, for example, a monthly fee for a number in Moscow is 95 rubles or London is 1 euro). And if there are almost no calls? You almost don't have to pay.
Free CRM is active while free PBX Zadarma is active. After registration, the PBX is active for 2 weeks, in the future it is necessary to replenish the account for any amount 1 time in 3 months. It is difficult to imagine an office that needs CRM and PBX, but no number or calls are needed at all.

Why you need an API for free CRM

The development of ZCRM does not stop for a minute, many large and small functions have appeared. But we understand that in order to present a truly functional system, and not just a smart notebook, telephony integration is not enough.
The more contacts with the client, the better, and contacts can be very different. Thanks to the API, you can automatically enter (or, on the contrary, receive) information about the client / lead and tasks without any problems. Thanks to this, it becomes possible to connect any channels of communication with customers and any other automation systems.
Thanks to the API, free ZCRM can be used in any way, either in whole or in part. For example, as a convenient interface for working with a corporate customer base, or as a simple convenient scheduler.
Below is an example of such a channel - connecting to CRM lead forms on the site. Later on the site we will give other examples, for example, creating a task to call the client back (deferred call).

Basic ZCRM API Methods

Since there are 37 methods available in the ZCRM API, we will refrain from describing all of them, we will describe only their main groups with examples.
A complete list with examples is available on the website at Description of the CRM API.

It is possible to work with the following groups of methods:

  • Clients (general list, separate selections, editing, deleting)
  • Tags and additional properties of clients
  • Customer feed (viewing, editing, deleting entries in customer feeds)
  • Employees of the client (since the client is usually a legal entity, it may have quite a few employees)
  • Tasks (all functionality for working with tasks)
  • Leads (similarly, all functions)
  • CRM users (displaying a list of users, their rights, settings, contacts and working hours)
  • Calls (returns a list of calls)

Since the existing Zadarma API structure is used, libraries in PHP, C#, Python are already available for it on Github.

API Usage Example

The simplest yet most useful example is creating a lead from a form. To keep the code to a minimum, this example contains only the basic lead data. A similar example, but with comments from the client (usually present in every form) is available on the blog Online. Script examples are written in PHP without frameworks and therefore easily embedded.
An example of an html form for creating a lead:

<form method="POST" action="/en/zcrm_leads">
   <label for="name">Name:</label>
   <br>
   <input type="text" id="name" name="name" value="">
   <br>
   <label for="phone">Phone:</label><br>
   <input type="text" id="phone" name="phones[0][phone]" value="">
   <br>
   <label for="phone">Email:</label><br>
   <input type="text" id="email" name="contacts[0][value]" value="">
   <br>
   <br>
   <input type="submit" value="Submit">
</form>

This form is extremely simple so as not to overload the article. It has no design, no captcha, no comment field. A version with a comment field is available on our blog (the comment is added to the client's feed after the lead is created).

And actually a PHP example for creating a lead with data from the form:

<?php
$postData = $_POST;
if ($postData) {
   if (isset($postData['phones'], $postData['phones'][0], $postData['phones'][0]['phone'])) {
       $postData['phones'][0]['type'] = 'work';
   }
   if (isset($postData['contacts'], $postData['contacts'][0], $postData['contacts'][0]['value'])) {
       $postData['contacts'][0]['type'] = 'email_work';
   }
   $params = ['lead' => $postData];
   $params['lead']['lead_source'] = 'form';

   $leadData = makePostRequest('/v1/zcrm/leads', $params);
   var_dump($leadData);
}
exit();

function makePostRequest($method, $params)
{
   // Π·Π°ΠΌΠ΅Π½ΠΈΡ‚Π΅ userKey ΠΈ secret Π½Π° ваши ΠΈΠ· Π»ΠΈΡ‡Π½ΠΎΠ³ΠΎ ΠΊΠ°Π±ΠΈΠ½Π΅Ρ‚Π°
   $userKey = '';
   $secret = '';
   $apiUrl = 'https://api.zadarma.com';

   ksort($params);

   $paramsStr = makeParamsStr($params);
   $sign = makeSign($paramsStr, $method, $secret);

   $curl = curl_init();
   curl_setopt($curl, CURLOPT_URL, $apiUrl . $method);
   curl_setopt($curl, CURLOPT_CUSTOMREQUEST, 'POST');
   curl_setopt($curl, CURLOPT_POST, true);
   curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, 10);
   curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
   curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
   curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);
   curl_setopt($curl, CURLOPT_POSTFIELDS, $paramsStr);
   curl_setopt($curl, CURLOPT_HTTPHEADER, [
       'Authorization: ' . $userKey . ':' . $sign
   ]);

   $response = curl_exec($curl);
   $error = curl_error($curl);

   curl_close($curl);

   if ($error) {
       return null;
   } else {
       return json_decode($response, true);
   }
}

/**
* @param array $params
* @return string
*/
function makeParamsStr($params)
{
   return http_build_query($params, null, '&', PHP_QUERY_RFC1738);
}

/**
* @param string $paramsStr
* @param string $method
* @param string $secret
*
* @return string
*/
function makeSign($paramsStr, $method, $secret)
{
   return base64_encode(
       hash_hmac(
           'sha1',
           $method . $paramsStr . md5($paramsStr),
           $secret
       )
   );
}

As you can see, working with the API is quite simple, plus there are examples of working on PHP, C#, Python. Thus, without any problems, you can fit a simple free CRM into any workflow, having received automation with little blood.
ZCRM is constantly evolving and almost all new features will be available through the API.
We also invite you to integrate your existing system systems with free CRM and PBX Zadarma.

Source: habr.com

Add a comment