CRM telephony: how not to miss a single call

The sales in most companies, online stores, or organizations are directly linked to phone conversations. Special scripts for the communication with customers are developed for managers, and training courses are conducted. But even these measures don’t exclude human errors.

Read also the article about automation with Bitrix24

To minimize the loss of new or current customers, many companies switch to IP telephony. After all, it allows monitoring all stages of communication, thereby analyzing the level of service (for example, listening to recorded manager conversations). After such measures are taken, the employees have a better attitude toward their work, because they understand that their conversations are under constant control, and they can’t avoid communicating.

In order not to lose potential customers, we will use the Bitrix API. We have to create a functional mechanism to keep in mind each customer and timely contact him/her. Let’s figure out how we can do that using Bitrix24 and its telephony.

First of all, it is a virtual ATS, which can help you distribute the “waiting line” of incoming calls between employees. You can record all conversations and then conduct a selective customer service quality control in the form of listening to the records by the line managers. And additionally, you can customize your “greeting message”, “on hold” tunes, as well as redirect calls, keep tracking calls from customers, save the recordings of conversations, etc.

To process the call, we will use the onCallEnd event (the event is called when the conversation ends (writing to the history)): https://dev.1c-bitrix.ru/api_hel.... We create the event handler:

  1. AddEventHandler(“voximplant”, “onCallEnd”, “AddTaskSkipCall”);
  2. function AddTaskSkipCall($arFields){} // array $arFields the data array gets to the

We check the value of the CALL_FAILED_CODE parameter: if it equals 304 (missed call), we keep on processing:

  1. if($arFields[‘CALL_FAILED_CODE’] == ‘304’){};

To find out whether the caller is in our database, we search for him/her by phone number:

  1. if(CModule::IncludeModule(‘crm’)){
  2. $arFilterPhone = array(“TYPE_ID” => “PHONE”, “VALUE_TYPE” => “WORK”, “VALUE” => $arFields[‘PHONE_NUMBER’]);
  3. $obFields = CCrmFieldMulti::GetList(array(), $arFilterPhone);
  4. while($arField = $obFields->Fetch()){
  5. if ($arField[‘ENTITY_ID’] == ‘CONTACT’) {
  6. $contact_id = $arField[‘ELEMENT_ID’];
  7. }
  8. }
  9. if($contact_id){
  10. $obCRMContacts = CCrmContact::GetList($arOrder = array(‘DATE_CREATE’ => ‘DESC’), $arFilter = array(“ID”=>$contact_id), $arSelect = array(‘NAME’, ‘LAST_NAME’, ‘ASSIGNED_BY_ID’), false);
  11. $arContact = $obCRMContacts->Fetch();
  12. $contact = $arContact[‘NAME’].’ ‘.$arContact[‘LAST_NAME’]; // we get the full name
  13. $responsible_id = $arContact[‘ASSIGNED_BY_ID’]; // we get the employee responsible
  14. }
  15. }

In order not to hang the task up, we will establish the deadline of one day. To do this, we get the object with the date of the call from the $arFields array. On the basis of the data obtained, we determine the deadline for the task:

  1. $refValue = new \ReflectionClass($arFields[‘CALL_START_DATE’]);
  2. $propValue = $refValue->getProperty(‘value’);
  3. $propValue->setAccessible(true);
  4. $value = $propValue->getValue($arFields[‘CALL_START_DATE’]);
  5. $sDate = $value->date;
  6. $arDate = explode(‘.’, $sDate);
  7. $date = new DateTime($arDate[0]);
  8. $date->add(new DateInterval(‘P1D’));
  9. $deadline = $date->format(‘m/d/Y h:i:s a’); // our deadline

We add the task title:

  1. $taskTitle = “Skipped call fr om “.$arFields[‘PHONE_NUMBER’]; // task title

Based on whether the contact is in our database, we come up with a task description, along with the employee responsible if he/she has not been specified yet:

  1. if ($contact) {
  2. $description = “Call back to <a href=”/crm/contact/show/”>”.$contact.”</a>. The call was skipped at “.$arDate[0];
  3. }else{
  4. $description = “Call back to <a href=”jav * ascript:void(0)” oncl=”” ick=”BXIM.phoneTo(“.$arFields[“>”.$arFields[‘PHONE_NUMBER’].”</a>. The call was skipped at “.$arDate[0];
  5. $responsible_id = TASK_CREATED_BY; //the employee responsible (the default one is admin)
  6. }

Using the CTaskItem::Add method (https://dev.1c-bitrix.ru/api_hel..., we create the task:

  1. $task = new \Bitrix\Tasks\Item\Task(0, TASK_CREATED_BY);
  2. // array with fields for task
  3. $task[‘TITLE’] = $taskTitle; // task title
  4. $task[‘DESCRIPTION’] = $description; // task description
  5. $task[‘RESPONSIBLE_ID’] = $responsible_id; // the employee responsible
  6. $task[‘CREATED_BY’] = TASK_CREATED_BY; // admin id
  7. $task[‘DEADLINE’] = $deadline; // deadline
  8. // create the task
  9. $result = $task->save();

We can also add ACCOMPLICES to the task. If the interactive voice response (IVR) system is configured, we can assign specific user groups responsible for an action to specific response buttons. It is these groups that we can use as the task accomplices to assign the responsibilities more accurately. In this case, we will have to get the call log from the database by the call ID ($arFields[‘CALL_ID’]):

  1. global $DB;
  2. $ob = $DB->Query(“SEL ECT F.CALL_LOG FR OM b_voximplant_statistic F WH ERE F.CALL_ID = ‘“.$arFields[‘CALL_ID’].”’”);
  3. $res = $ob->Fetch();
  4. $urlCallLog = $res[‘CALL_LOG’]; // log address

We will pull out the code of the button pressed from the log file itself, and, accordingly, determine the users by previously specified IDs of the groups they are in:

  1. $find_str = ‘Received tone ‘;
  2. $str = file_get_contents($urlCallLog);
  3. $pos = strpos($str, $find_str);
  4. $ivrButton = substr($str, $pos+strlen($find), 1);
  5. if ($ivrButton == 2) {
  6. $userGroup = CGroup::GetGroupUser(SUPPORT_GROUP_ID);
  7. }elseif ($ivrButton == 1) {
  8. $userGroup = CGroup::GetGroupUser(SALES_GROUP_ID);
  9. }elseif ($ivrButton == 3) {
  10. $userGroup = CGroup::GetGroupUser(BILLING_GROUP_ID);
  11. }
  12. We add the following to the array before creating the task:
  13. $task[‘ACCOMPLICES’] = $userGroup; // task accomplices

In the end, I’d like to add that you can always add the handler to the given code to create the task. Even if the call was successful, you can see all of your calls and supplement the tasks with their results to see a broader picture.

That’s all. Now you won’t miss a single call, and your customers will be in good hands ))

Written by

Senior PR Manager in Avivi IT Company

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade