Caller ID
As people recognize names more than numbers, it’s a good practice for your integration to retrieve the caller identity which can be implemented in two different ways:
- Adding the notification about the call using the Call event method. This method performs a search for the caller ID and creates a notification connected to the card with this phone number if it exists
- Using the Get contact list request filtering by phone number with
queryparameter:
curl --request GET \
--url 'https://subdomain.kommo.com/api/v4/contacts?query=$phone_number' \
--header 'accept: application/json' \
--header 'authorization: Bearer XXXX'Each way uses a different algorithm to perform the search, and each one considers a different number of digits from the phone number as an input to the search process. The Call event uses the last 8 digits and searches first for a contact then for a company. It may return a lead according to the case. While the Get contacts by phone method uses the last 7 digits and searches first for a company then for a contact. It also may return a lead according to different considerations.
const FALLBACK_FN = () => undefined;
const PHONE_CUSTOM_FIELD_CODE = "PHONE";
const searchContactByPhone = async (phone, callbacks = {}) => {
const { onSuccess = FALLBACK_FN, onError = FALLBACK_FN } = callbacks;
if (!phone) {
return;
}
try {
const contactsData = await $.ajax(`/api/v4/contacts?query=${phone}`, {
method: "GET",
});
onSuccess(contactsData);
return contactsData._embedded.contacts;
} catch (error) {
onError(error);
}
};
Updated about 8 hours ago